Advertisement
Java_Volume1 Miscellaneous #90438

Drag a form WITHOUT a title bar!

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

AI

AI 摘要: 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.

源代码
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
原始评论 (3)
从 Wayback Machine 恢复