第一种:
利用API移动,代码如下:
Private Declare Function ReleaseCapture Lib “user32” () As Long
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 Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
ReleaseCapture
SendMessage hWnd, &HA1, 2, 0&
End If
End Sub
第二种:
Dim Fx As Single, Fy As Single
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Fx = X: Fy = Y
Me.Move Me.Left + (X - Fx), Me.Top + (Y - Fy)
End Sub