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: (sanctified, Win2000 Delphi test)
// 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's PARENT when 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; Beginif (Form1.top <= 3) or (Form1.Left> = Screen.Width-Form1.Width-3) THEN / / Judgment Begin getCursorpos (WinPOS) ; // Get the coordinates of the current mouse pointer on the screen
// When the Name of the form of the mouse pointer is equal to Form1.Name = getFormNameat (winpos.x, winpos.y) THEN {here we can take a special name for Form1 to prevent other The form name is the same as it} begin form1.timer2.enabled: = false; // deactivate Timer2 Form1.top:=0; // Form1 TOP and screen align end else form1.timer2.enabled: = true; // Open TIMER2END; End; Procedure TForm1.Timer2Timer (Sender: TOBJECT); Begin if Form1.top <= 20 THEN FORM1.TOP :=-(Form1.Height-10); / / FORM1 is moved upward, show 10 on the screen Pixel END;