|
-
Oct 11th, 2001, 01:32 AM
#1
Thread Starter
PowerPoster
Moving/Draggin Image Box???
hey all,
How do you drag/move and image box on a form??
thanks
b
-
Oct 11th, 2001, 02:52 AM
#2
Hyperactive Member
is it the actual box that you want to move, or is it the image inside the box?
"...They even have the internet on computers..." :- Homer Simpson
"Second Place is First Looser" :- No Fear
-
Oct 11th, 2001, 02:57 AM
#3
Retired VBF Adm1nistrator
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
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Oct 11th, 2001, 03:12 AM
#4
PowerPoster
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!!!
-
Oct 11th, 2001, 03:12 AM
#5
Thread Starter
PowerPoster
The actual box!
Cool ta jamie!
-
Oct 11th, 2001, 03:14 AM
#6
Thread Starter
PowerPoster
-
Oct 11th, 2001, 03:14 AM
#7
Retired VBF Adm1nistrator
bollox beachbum 
n/p beacon.
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|