1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
Option Explicit
Dim XVal As Single
Dim YVal As Single
Dim TopVal As Single
Dim LeftVal As Single
Dim MoveObj As Boolean
Sub CommandButton1_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
XVal = X
YVal = Y
TopVal = CommandButton1.Top
LeftVal = CommandButton1.Left
MoveObj = True
End Sub
Private Sub CommandButton1_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
If MoveObj Then
CommandButton1.Left = LeftVal + (X - XVal)
CommandButton1.Top = TopVal + (Y - YVal)
End If
End Sub
Sub CommandButton1_MouseUp(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
CommandButton1.Left = LeftVal + (X - XVal)
CommandButton1.Top = TopVal + (Y - YVal)
MoveObj = False
End Sub |
Partager