devxlogo

Move a Form Without a Title Bar

Move a Form Without a Title Bar

Enter this code in a BAS module to let users move a window without a title bar:

 Declare Function ReleaseCapture Lib "user32" () As LongDeclare Function SendMessage Lib "user32" _	Alias "SendMessageA" ( _	ByVal hwnd As Long, ByVal wMsg As Long, _	ByVal wParam As Long, lParam As Any) As LongPublic Const HTCAPTION = 2Public Const WM_NCLBUTTONDOWN = &HA1

To give users a way to begin the move, place a little colored PictureBox in one corner of the form and let its MouseDown event begin the process:

 Private Sub Picture1_MouseDown(Button As _	Integer, Shift As Integer, X As Single, Y As Single)	ReleaseCapture	SendMessage hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&End Sub
See also  Comparing different methods of testing your Infrastructure-as-Code
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist