In general, moving a form requires the mouse to be placed on the title bar to drag the form, what is the title bar? In fact, we can use a clever way to implement the mouse to be placed on the form and drag the form, let's see the implementation code. Declaration of "private" partial in Form1:
Add the following code in the private section: procedure wmnchittest (var msg: twmnchittest); message wm_nchittest; Add the following code in a program part: procedure TForm1.wmnchittest (var msg: twmnchittest); begin inherited; if (htclient = msg.result) then msg .result: = htcaption; end; The key code above is only two lines, but it achieves the purpose of the mouse directly drag the form. The principle of the code is the use of the form's WM_NCHITTEST message, which occurs when the cursor moves, the mouse is pressed or released, when the program detects the message in the mouse in the form (the value is htclient), The mouse is passed to the message (value htcaption) generated when the mouse is pressed, so that the clever spoofer considers that the title bar is pressed, of course, can drag the form.