|
-
Nov 5th, 2000, 10:28 AM
#1
How do i drag labels and/or picture boxes across a form?
-
Nov 5th, 2000, 10:56 AM
#2
Fanatic Member
Simply set the picturebox or label's dragmode property to "1-Automatic". Then paste the follow code onto the form:
Code:
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Left = X
Source.Top = Y
End Sub
www.RealisticGraphics.net
Running VS.Net Enterprise & VB 6
Other Languages: JavaScript, VBScript, VBA, HTML, CSS, ASP, SQL, XML
MSN Messenger: kmsheff
-
Nov 5th, 2000, 12:53 PM
#3
Hyperactive Member
Good one, Metthew, but I think this would be better:
Code:
Private Sub Form_DragDrop(Source As Control, X As Single, Y As Single)
Source.Top = Y - Source.Height / 2
Source.Left = X - Source.Width / 2
End Sub
-
Nov 5th, 2000, 01:01 PM
#4
_______
<?>
'Picture box is the the same situtation.
[code]
'Allowing a form control to be movable (DRAG AND DROP)
'...ie drag label1
Option Explicit
Public globalX As Integer
Public globalY As Integer
Private Sub Form_DragDrop(Source As Control, X As _
Single, Y As Single)
Label1.Move X - globalX, Y - globalY
End Sub
Private Sub Label1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Label1.Drag vbBeginDrag
globalX = X
globalY = Y
End Sub
[code]
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Nov 5th, 2000, 02:27 PM
#5
Code:
Dim prevX As Long
Dim prevY As Long
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
prevX = X: prevY = Y
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then Picture1.Move Picture1.Left + (X - prevX), Picture1.Top + (Y - prevY)
End Sub
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
|