Does it have to be the label that is used to drag the form? Here's an example (VB6) that lets you simply grab the form (anywhere on the form) and drag it.
This version won't work if you grab any controls (such as a label), but you can change it if necessary.
- Option Explicit
-
DefLng A-Z
-
Private Dragging As Boolean
-
Private DragX As Single, DragY As Single
-
-
-
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Dragging = True
-
DragX = X: DragY = Y
-
End Sub
-
-
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Dim OffsetX As Single, OffsetY As Single
-
Static Busy As Boolean
-
If Not Busy Then
-
Busy = True
-
If Dragging Then
-
OffsetX = X - DragX
-
OffsetY = Y - DragY
-
-
With Me
-
.Move .Left + OffsetX, Top + OffsetY
-
End With
-
DoEvents
-
End If
-
Busy = False
-
End If
-
End Sub
-
-
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
-
Dragging = False
-
End Sub