Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I move and resize an image box with the mouse at run time? 1

Status
Not open for further replies.

tedsmith

Programmer
Nov 23, 2000
1,762
AU
Cant see how to move or resize an image box at run time with the mouse.
I was hoping to be able to do it just the way you can when editing a form.

Mousemove(button,x,y) only gives the co-ordinates within the box so you can get the location on the form while the cursor is inside the box.

I tried a routine that detects when the cursor is near the inner edges but it jumps the box too much because the reference moves as you move the mouse.
 
Here are some routines I use to move a Picture Box called picPrices
Code:
[blue]General Declarations[/blue]
Private MouseIsDown                 As Boolean
Private MouseX                      As Single
Private MouseY                      As Single

Private Sub picPrices_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
    MouseIsDown = True
    Me.MousePointer = vbSizePointer
    MouseX = x
    MouseY = Y
End Sub

Private Sub picPrices_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
    If MouseIsDown Then
        picPrices.Move picPrices.Left + x - MouseX, picPrices.Top + Y - MouseY
    End If
End Sub

Private Sub picPrices_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
    MouseIsDown = False
    Me.MousePointer = vbDefault
End Sub

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top