Drag form without titlebar

By | 2017-08-06

Drag a form that has no titlebar! Add the routine listed below, and call it in the ‘MouseDown’ event of the form (or a control on the form):

MoveWindow Me.Hwnd

Windows API/Global Declarations:

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

Code

Public Sub MoveWindow(TheHwnd As Long)

    ReleaseCapture
    SendMessage TheHwnd, &HA1, 2, 0&

End Sub

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.