Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Const HTCAPTION = 2 Private Const WM_NCLBUTTONDOWN = &HA1 Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then ReleaseCapture SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0& End If End Sub
然后在mouse_down中
用绝对坐标减相对坐标~
作为form的top和left属性
Private Declare Function ReleaseCapture Lib "user32" () As LongPrivate Const HTCAPTION = 2
Private Const WM_NCLBUTTONDOWN = &HA1
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
End If
End Sub