Mega Code Archive

 
Categories / Delphi / Forms
 

How to move your form by clicking anywhere

Title: How to move your form by clicking anywhere. Question: How do you move your form by clicking anywhere instead of clicking of the title bar. Answer: It's very simple. Just put the following procedure in the private part of the declaration of your form. private {private declarations} procedure MoveForm(var Msg: TWMNChittest); message WM_NChittest; then in the procedure you put: procedure TForm1.MoveForm(var Msg: TWMNChittest); begin DefaultHandler(Msg); if Msg.Result = HTCLIENT then Msg.Result := HTCAPTION; end; This way Windows will respond as if you would have clicked on the titlebar of the form.