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 gets 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 not only one VCL in a form can be When the components, such as TPANEL, TMEMO, etc., then we must find their PARENT level, and finally 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:
// Custom Function getFormNameat, get the NameFunction getFormNameat (x, y: integer) of the mouse needle finger: string; var p: tpoint; w: twinControl; begin px: = x; py: = y; w: = FindvCLWindow (P); // Get the VCL Visual Component IF under the Mouse Pointer (NIL <> W) Then Begin While W.Parent <> nil do // Continued to find W in W. : = W.Parent; Result: = w.Name; // Last return of the form Name End else begin result: = '; end; end;
Procedure tform1.timer1timer (sender: TOBJECT); VAR WINPOS: TPOINT; Begin getCursorpos (WINPOS); // Get the current mouse pointer on the screen / / When the Name of the form pointer is equal to FORM1.NAME, IF Form1.Name = getFormNameat (WinPos.x, winpos.y) THEN {We can take a special name for Form1 to prevent other form names with it} Begin Form1.Timer2.enabled: = false; // Deactivate Timer2 Form1.top:=0; // Form1 Top and screen align end else form1.timer2.enabled: = true; // Open Timer2nd;
Procedure TForm1.Timer2Timer (Sender: TOBJECT); Begin if Form1.top <= 20 THEN FORM1.TOP :=- (Form1.Height 10); // The FORM1 is moved upward, and 10 pixel end is exposed above the screen;