明次 发表于 2009-4-6 12:09

vb鼠标拖动picture

Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function ReleaseCapture Lib "user32" () As Long

Dim blnDragging As Boolean
Dim offsetX As Single, offsetY As Single

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If blnDragging Then
Picture1.Move X - offsetX, Y - offsetY
End If
End Sub

Private Sub Form_mouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
blnDragging = False
ReleaseCapture
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
blnDragging = True
SetCapture Me.hwnd
offsetX = X
offsetY = Y
End If
End Sub

shoujing 发表于 2009-4-6 18:53

windows的坐标。

zq784161329 发表于 2009-5-13 15:48

顶,感谢楼主
页: [1]
查看完整版本: vb鼠标拖动picture