by Vicky (J) (2 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 30th December 2004
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Move a form without a title bar.
API Declarations
I see many requests for people wanting to know how to move a form either when the title bar is not visible or without using the title bar. All it takes is two API declarations, two constants, and two lines of code.
Insert this code in a module:
Lib "user32" () As Long
Declare Function SendMessage Lib _
"user32" Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Public Const HTCAPTION = 2
Public Const WM_NCLBUTTONDOWN = &HA1
'--end code block
Place this code in the MouseDown event in the Form, PictureBox, etc:
ReleaseCapture
SendMessage hwnd, _
WM_NCLBUTTONDOWN, _
HTCAPTION, 0&
'--end code block
Thats all there is to it.