Applies to  VB4+ 

Dragging a Form Without a Title Bar

Code

Normally, a user moves a window by dragging its title bar. If your form doesn't have a title bar, you can instead let the user drag its client area (the "main" part of a window). Just add a couple of lines to the MouseDown event:

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, _
                           X As Single, Y As Single)
    ReleaseCapture
    SendMessage hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0
End Sub

Here are the required API declarations (available in Win32.tlb):

Comments

When the user presses a mouse button, Visual Basic automatically "captures" the mouse so that all mouse input goes to your form. Windows won't begin a dragging operation while the mouse is captured, so you must first call ReleaseCapture. You can then send the WM_NCLBUTTONDOWN (non-client left button down) message to simulate a mouse-button press inside the title bar.

See Also

Microsoft Knowledge Base

1