Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
fX = X
fY = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button > 0 Then Me.Move Me.Left - fX + X, Me.Top - fY + Y
End Sub
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)
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HIT_CAPTION, 0
End Sub
Option Explicit
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 GetCapture Lib "user32" () As Long
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private blnIsDown As Boolean
Private blnIsCtrlDown As Boolean
Private xpoint As POINTAPI
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 17 Then
blnIsCtrlDown = True
End If
End Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)
If KeyCode = 17 Then
blnIsCtrlDown = False
End If
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
MouseManange x, y
blnIsDown = True
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
MouseManange x, y
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
MouseManange x, y
If blnIsCtrlDown Then
If blnIsDown Then
GetCursorPos xpoint
Me.Top = xpoint.y * 15
Me.Left = xpoint.x * 15
blnIsDown = False
End If
End If
End Sub
Private Sub MouseManange(x As Single, y As Single)
If blnIsCtrlDown Then
If GetCapture() <> Me.hWnd Then SetCapture Me.hWnd
ElseIf ((x < 0) Or (y < 0) Or (x > Me.Width) Or (y > Me.Height)) Then
ReleaseCapture
End If
End Sub