Resizing a control with the mouse during runtime 
Author Message
 Resizing a control with the mouse during runtime

I am trying to resize a picture box on a form using solely the mouse during
RUNTIME. I'm talking about how the cursor can be changed to a NE or EW,
indicating that the object can be resized by clicking and dragging.

I can only succeed as far as making the cursor change at the right places to
depict the direction the user can click and drag, but I don't know how to
capture the mouse input the user is doing.

I tried getting the X and Y in MouseDown and MouseMove events, it didn't
work very well. That or I didn't do it right. Does anybody have a real
simple snippet for this, perhaps with just a form and a control (any kind of
control) that can be resized during runtime in the way I described?

Thanks.

David O.



Thu, 31 Aug 2000 03:00:00 GMT  
 Resizing a control with the mouse during runtime

Did anybody answer you? If not let me know because I'm working on some code
right now that does this, and I can send you the relevant part that you
need.

--
****************************************************************************
Mohammed AlQuraishi
SiteBuilder Level 2
ClubIE Team 4
Independent Microsoft Beta Tester
TechWeb/Microsoft 2nd Place ActiveX Contest Winner (Business)
http://www.advancednetsolutions.com

"It is the bias of our society that creates the smart and the stupid." a
*Smart* guy.
"To war is not only to win, it's also to fight."
****************************************************************************

Quote:
>I am trying to resize a picture box on a form using solely the mouse during
>RUNTIME. I'm talking about how the cursor can be changed to a NE or EW,
>indicating that the object can be resized by clicking and dragging.

>I can only succeed as far as making the cursor change at the right places
to
>depict the direction the user can click and drag, but I don't know how to
>capture the mouse input the user is doing.

>I tried getting the X and Y in MouseDown and MouseMove events, it didn't
>work very well. That or I didn't do it right. Does anybody have a real
>simple snippet for this, perhaps with just a form and a control (any kind
of
>control) that can be resized during runtime in the way I described?

>Thanks.

>David O.




Fri, 01 Sep 2000 03:00:00 GMT  
 Resizing a control with the mouse during runtime

Sorry, I don't have a code snippet for you... I am working on the same
kind of problem.

I'll keep you posted if I find out anything....




Quote:
> I am trying to resize a picture box on a form using solely the mouse
during
> RUNTIME. I'm talking about how the cursor can be changed to a NE or EW,
> indicating that the object can be resized by clicking and dragging.

> I can only succeed as far as making the cursor change at the right places
to
> depict the direction the user can click and drag, but I don't know how to
> capture the mouse input the user is doing.

> I tried getting the X and Y in MouseDown and MouseMove events, it didn't
> work very well. That or I didn't do it right. Does anybody have a real
> simple snippet for this, perhaps with just a form and a control (any kind
of
> control) that can be resized during runtime in the way I described?

> Thanks.

> David O.




Sun, 03 Sep 2000 03:00:00 GMT  
 Resizing a control with the mouse during runtime

I finally got it, Greg, with the help of some good fellow who also frequents
the newsgroup.

My end result, although clean with a picture box, is limited to a picture
box because I need a hWnd *AND* the Scalexxxxx properties. Only a picturebox
(and a form, but who cares about resizing a form) possess such attributes.

If you interested to look at what I did, just let me know and I'll send it
to you via email.

Yes, I would be interested to see how you would do it, too.

Thanks.

David O.

Quote:

>Sorry, I don't have a code snippet for you... I am working on the same
>kind of problem.

>I'll keep you posted if I find out anything....




>> I am trying to resize a picture box on a form using solely the mouse
>during
>> RUNTIME. I'm talking about how the cursor can be changed to a NE or EW,
>> indicating that the object can be resized by clicking and dragging.

>> I can only succeed as far as making the cursor change at the right places
>to
>> depict the direction the user can click and drag, but I don't know how to
>> capture the mouse input the user is doing.

>> I tried getting the X and Y in MouseDown and MouseMove events, it didn't
>> work very well. That or I didn't do it right. Does anybody have a real
>> simple snippet for this, perhaps with just a form and a control (any kind
>of
>> control) that can be resized during runtime in the way I described?

>> Thanks.

>> David O.




Sun, 03 Sep 2000 03:00:00 GMT  
 Resizing a control with the mouse during runtime

You can "simulate" a grab handle using an image control or a picturebox.

The code below is from a usercontrol that can be sized at runtime via this
size handle, a picturebox called imgSizeHandle.  It has the proper
mousepointer arrow and uses the Marlett font, size 10, to draw the grab
handle appearance.  It's like the one in the lower right corner (eg on a
statusbar).

You can expand this example to get eight if you really want <g>.

Jim Deutch
MS Dev MVP

Private Sub imgSizeHandle_MouseDown(Button As Integer, Shift As Integer, X
As Single, Y As Single)
    If Button = vbLeftButton Then Sizing = True
End Sub

Private Sub imgSizeHandle_MouseMove(Button As Integer, Shift As Integer, X
As Single, Y As Single)
    Static Alternator As Boolean
    Dim fTmp As Single
    Dim fCmp As Single

    If Alternator Then
        Alternator = False
        Exit Sub
    Else
        Alternator = True
    End If
    If Sizing Then
        '1st check that its valid
        If Picture1.Width + X - imgSizeHandle.Width < 40 Then Exit Sub
        If Picture1.Height + Y - imgSizeHandle.Height < 40 Then Exit Sub

        fTmp = UserControl.Width + X - imgSizeHandle.Width
        fCmp = Extender.Container.Width - Extender.Left
        If fTmp > fCmp Then fTmp = fCmp
        UserControl.Width = fTmp

        fTmp = UserControl.Height + Y - imgSizeHandle.Height
        fCmp = Extender.Container.Height - Extender.Top
        If fTmp > fCmp Then fTmp = fCmp
        UserControl.Height = fTmp

        RaiseEvent Resize(UserControl.Width, UserControl.Height)
    End If
End Sub

Private Sub imgSizeHandle_MouseUp(Button As Integer, Shift As Integer, X As
Single, Y As Single)
    If Sizing Then
        'through sizing
        Sizing = False
        'redraw
    End If
End Sub

Private Sub imgSizeHandle_Paint()
    If m_WindowState = vbNormal Then
        imgSizeHandle.ForeColor = vb3DHighlight
        imgSizeHandle.CurrentX = 0
        imgSizeHandle.CurrentY = 0
        imgSizeHandle.Print "o"
        imgSizeHandle.ForeColor = vb3DShadow
        imgSizeHandle.CurrentX = 0
        imgSizeHandle.CurrentY = 0
        imgSizeHandle.Print "p"
    End If
End Sub



Quote:
> Sorry, I don't have a code snippet for you... I am working on the same
> kind of problem.

> I'll keep you posted if I find out anything....




> > I am trying to resize a picture box on a form using solely the mouse
> during
> > RUNTIME. I'm talking about how the cursor can be changed to a NE or EW,
> > indicating that the object can be resized by clicking and dragging.

> > I can only succeed as far as making the cursor change at the right
places
> to
> > depict the direction the user can click and drag, but I don't know how
to
> > capture the mouse input the user is doing.

> > I tried getting the X and Y in MouseDown and MouseMove events, it
didn't
> > work very well. That or I didn't do it right. Does anybody have a real
> > simple snippet for this, perhaps with just a form and a control (any
kind
> of
> > control) that can be resized during runtime in the way I described?

> > Thanks.

> > David O.




Sun, 03 Sep 2000 03:00:00 GMT  
 Resizing a control with the mouse during runtime



Quote:
>Sorry, I don't have a code snippet for you... I am working on the same
>kind of problem.

There is a complete example of moving and resizing controls, including
light controls, at www.softcircuits.com
--
Richard Mason


Mon, 04 Sep 2000 03:00:00 GMT  
 Resizing a control with the mouse during runtime

Jim,

Do you know how to call the C runtime library from VB? I know your
name, which is why I asked, sorry it has nothing to do with this
thread.

I want to allow VB to call directly using a type library. I have a
working type library for the Win32 API and for OpenGL, but these C
libraries are contrary. Is it the calling convemtions?

I can read the exports of msvcrt.dll, and find my function. I use an
SDK header to declare it in the tlb (or as a last choice, to write a
VB 'Declare' statement). But it crashes VB.

Damn it, don't VB programmers need the C runtime library?

Or am I just dreaming digital nuggets again?



Tue, 05 Sep 2000 03:00:00 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. sstab control - resizing during runtime problem

2. Move resize drag controls in runtime using mouse...

3. Resizing controls at runtime with the mouse

4. resizing a form when a control resizes during execution

5. resizing a form when a control resizes during execution

6. resizing combo box during runtime

7. resize image in MSFlexGrid during runtime?

8. Q: Resize textbox at runtime with mouse?

9. Resizing a RichTextBox at Runtime with the mouse

10. Moving controls during resize event

11. Resizing controls during run-time?

12. Resize controls (labels or textboxes) during run-time

 

 
Powered by phpBB® Forum Software