Private Sub Form_DragOver(Source As Control, X As Single, Y As Single, State As Integer)
Source.Caption = "Jag har blivit dragen!"
Source.BackColor = vbRed
If X > Me.ScaleWidth - Source.Width Then
X = Me.ScaleWidth - Source.Width
End If
Source.Left = X
If Y > Me.ScaleHeight - Source.Height Then
Y = Me.ScaleHeight - Source.Height
End If
Source.Top = Y
End Sub
Private Sub lblDrag_DragDrop(Source As Control, X As Single, Y As Single)
Source.Caption = "Jag blev dragen och släppt!"
Source.BackColor = vbBlue
End Sub
Private Sub mnuDD_Click()
If Not mnuDD.Checked Then
lblDrag.DragMode = 1 'Med automatik
Else
lblDrag.DragMode = 0 'Manuell
End If
mnuDD.Checked = Not mnuDD.Checked
End Sub