Skip to content

Instantly share code, notes, and snippets.

@facebookegypt
Last active December 14, 2015 14:18
Show Gist options
  • Save facebookegypt/5099269 to your computer and use it in GitHub Desktop.
Save facebookegypt/5099269 to your computer and use it in GitHub Desktop.
Option Explicit
'API to move windowless form
Private Const HTCAPTION As Long = 2
Private Const WM_NCLBUTTONDOWN As Long = &HA1
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 Long
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Moving the form using mouse button from any location on the form held with mouse
If Button = 1 Then
ReleaseCapture
SendMessage Me.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, ByVal 0&
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment