Hello,
shall we resize a shape control[rectangle] through mouse move. If possible how to write the code.
code help please.
Thanks
Thendral
Printable View
Hello,
shall we resize a shape control[rectangle] through mouse move. If possible how to write the code.
code help please.
Thanks
Thendral
You will have to figure out, through code, whether the mouse is in an area that you want the user to be able to click on to begin resizing. If you were to use the MouseDown & MouseMove events of a control, it won't help much if user is over a border since that area is generally not reported back to VB. The shape control has no mouse events anyway
Tip: It might prove easier to not worry about MouseDown events for the control, but rather the MouseDown/MouseMove events for the container the control is on. When the MouseDown event occurs check its X,Y coordinate against the bounds of your control if its in an area you say is acceptable, set a flag and cache the X,Y coordinates. From that point on, it will be the same principle used to move image/label controls during runtime. The only difference is you won't be moving, you will be resizing.
Searching the forum can help there, search for: move label image
Something as silly as this very quick sample may work for you...
You may need to restrict refion for mouse to allow/disallow resizing (just like toolbar or form have).Code:Option Explicit
Private StillDragging As Boolean
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
StillDragging = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Not StillDragging Then Exit Sub
If X < Shape1.Left Then Exit Sub
If Y < Shape1.Top Then Exit Sub
Shape1.Move Shape1.Left, Shape1.Top, X - Shape1.Left, Y - Shape1.Top
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
StillDragging = False
End Sub