Dim dragabled As Boolean, oldx As Single, oldy As Single Private Sub cmdDrag_Click() dragabled = Not dragabled cmdDrag.Caption = IIf(dragabled, "cmdDrag disabled", "cmdDrag enabled") End SubPrivate Sub Form_Load() cmdDrag.Caption = "cmdDrag enabled" End SubPrivate Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If dragabled Then oldx = X + Left oldy = Y + Top Image1.Drag 1 End If End SubPrivate Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If dragabled Then Image1.Drag 2 End SubPrivate Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single) Source.Move Left + X - oldx, Top + Y - oldy End Sub
Private Sub cmdDrag_Click()
dragabled = Not dragabled
cmdDrag.Caption = IIf(dragabled, "cmdDrag disabled", "cmdDrag enabled")
End SubPrivate Sub Form_Load()
cmdDrag.Caption = "cmdDrag enabled"
End SubPrivate Sub Image1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If dragabled Then
oldx = X + Left
oldy = Y + Top
Image1.Drag 1
End If
End SubPrivate Sub Image1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If dragabled Then Image1.Drag 2
End SubPrivate Sub Picture1_DragDrop(Source As Control, X As Single, Y As Single)
Source.Move Left + X - oldx, Top + Y - oldy
End Sub
拖动IMAGE好像不难
难得是放大以后 拖动闪的很厉害