hey all,
How do you drag/move and image box on a form??
thanks
b:)
Printable View
hey all,
How do you drag/move and image box on a form??
thanks
b:)
is it the actual box that you want to move, or is it the image inside the box?
To move the box :
VB Code:
Private prevX As Single, prevY As Single Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Image1.Move Image1.Left - (prevX - X), Image1.Top - (prevY - Y) End Sub Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) prevX = X prevY = Y End Sub
hi
Another way is to use drag drop so as to only display the outline and hence stop any flickering of the image control
Regards
Stuart
VB Code:
Dim fsngDragOrigTop As Single Dim fsngDragOrigLeft As Single Dim fsngDragOrigX As Single Dim fsngDragOrigY As Single Private Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) With Image1 fsngDragOrigTop = .Top fsngDragOrigLeft = .Left fsngDragOrigX = X fsngDragOrigY = Y .Drag vbBeginDrag End With End Sub Private Sub image1_DragDrop(Source As Control, X As Single, Y As Single) 'In case user doesnt move out of area of image control With Image1 .Left = fsngDragOrigLeft + (X - fsngDragOrigX) .Top = fsngDragOrigTop + (Y - fsngDragOrigY) .Drag vbEndDrag End With End Sub Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single) On Error Resume Next With Source .Left = (X - fsngDragOrigX) .Top = (Y - fsngDragOrigY) .Drag vbEndDrag End With End Sub
PS. And Jamie, don't swear at me this time like the last few posts!!! :D
The actual box!
Cool ta jamie!:D
nah swear at him!!
hehe
thanks Stuart!
I'll give em both a go!:D :D :D
all :D here!
bollox beachbum :)
n/p beacon.