I don't know how everyone thinks how it is the ability to indent the extended function when using QQ? The key to achieving this effect is how to determine that the form below the current mouse pointer is not our program form. GetCursorpos () is an API function that can get the coordinates of the mouse pointer on the screen, which can easily get the VCL visual component under the mouse pointer with the combination of FindvCLWindow ().
But when there is a VCL visual component in a form, for example, there may be TPANEL, TMEMO, etc., then we must find their Parent level, eventually get TFORM, that means our program form. Follow this idea I have customized the getFormNameat () function, which can get the name of the form below the current mouse pointer. The main implementation code of the program is provided below, for your reference:
/ / Customize the function getFormNameat, get the Name of the form of the form
Function GetFormNameat (x, y: integer): String;
VAR
P: tpoint;
W: TwinControl;
Begin
P.x: = x;
P.y: = y;
W: = FindvCLWindow (P); // Get the VCL visual component under the mouse pointer
IF (NIL <> w) THEN
Begin
While W.Parent <> nil do // Continue to find it when the super-level PARENT is not empty
W: = w.parent;
Result: = w.Name; // Last Name Name Name
end
Else
Begin
Result: = '';
END;
END;
Procedure TFORM1.TIMER1TIMER (Sender: TOBJECT);
VAR
Winpos: tpoint;
Begin
GetCursorpos (WinPOS); // Get the coordinates of the current mouse pointer on the screen
// When the Name of the form under the mouse pointer is equal to FORM1.NAME
if Form1.Name = getFormNameat (WinPos.x, WinPos.y) THEN
{Here we can take a special name for Form1 to prevent other form names with it.
Begin
Form1.timer2.enabled: = false; // Disable Timer2
Form1.top:=0; // Form1 TOP is aligned with the screen
end
Else
Form1.timer2.enabled: = true; // Open Timer2
END;
Procedure TFORM1.TIMER2TIMER (Sender: TOBJECT);
Begin
IF Form1.top <= 20 THEN
Form1.top:=-(Form1.Height-10); // Displace Form1 upward, 10 pixels on the screen
END;