Private Type POINTAPI X As Long Y As Long End Type
Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function ReleaseCapture Lib "user32" () As Long Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Dim Pt As POINTAPI Private bM As Boolean, oldX As Long, oldY As Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) SetCapture Form1.hwnd bM = True GetCursorPos Pt oldX = Pt.X oldY = Pt.Y End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Not bM Then Exit Sub GetCursorPos Pt Form1.Left = Form1.Left + (Pt.X - oldX) * Screen.TwipsPerPixelX Form1.Top = Form1.Top + (Pt.Y - oldY) * Screen.TwipsPerPixelY oldX = Pt.X oldY = Pt.Y End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) ReleaseCapture bM = False End Sub