Advertisement
2_2002-2004 Miscellaneous #117585

Drag a form WITHOUT a title bar!

With this code you can easily drag a form without a titlebar.

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
'code
Private Sub FormDrag(frm As Form)
  ReleaseCapture
  Call SendMessage(frm.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub

'usage:
'put in MouseDown even of almost anything.
'a form a label, a command button, anything will work.
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
  If Button = 1 Then Call FormDrag(Me)
End Sub
'If you dont add If Button = 1 etc.. 
'then if you left click, then right 
'click the form will continue to 
'move even though you arent clicking,
'its like the form is stuck to your mouse
Original Comments (3)
Recovered from Wayback Machine