How to use the API function in Delphi to know the current form

xiaoxiao2021-03-06  41

/ / 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.CLICK (Sender: TOBJECT);

VAR

Winpos: tpoint;

Begin

GetCursorpos (WinPOS); // Get the coordinates of the current mouse pointer on the screen

Form1.name = getFormNameat (WinPos.x, WinPos.y)

END;

转载请注明原文地址:https://www.9cbs.com/read-59989.html

New Post(0)