如何使物件可以用滑鼠拖曳移動?

首先請準備Picture1,然後輸入:

Dim CX As Single, CY As Single

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
 CX = X
 CY = 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 - CX, Picture1.Top + Y - CY
End Sub


上一頁