Just paste this into your form code window. No API call is needed.
Press F5 & hold down mouse key & move it. The Form will move with the mouse also.
Dim pastx, pasty, presentx, presenty, bt As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
pastx = X
pasty = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
presentx = X
presenty = Y
bt = Button
moving
End Sub
Function moving()
xx = presentx - pastx
yy = presenty - pasty
If bt Then
Me.Left = Me.Left + xx
Me.Top = Me.Top + yy
End If
End Function
Actually, I didn't know about the below API before I coded that. It was long time ago when I started my programming in VB6. You can also move form using these APIs.
But using the above code, the below APIs are no longer needed.
Thanks to all.
Aslam Iqbal
Declare Function ReleaseCapture& Lib "user32" ()
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const HTCAPTION = 2