If you have a need to find out the name of the parent window of a window or control at a given X and Y position, you maybe able to use the following "GetParentWindowNameAt()" function:
function GetParentWindowNameAt
( X, Y : integer ) : string;
var
P : TPoint;
W : TWinControl;
begin
P.X := X;
P.Y := Y;
W := FindVCLWindow( P );
if( nil <> W )then
begin
Result := W.Name;
end else
begin
Result := '';
end;
end;
( X, Y : integer ) : string;
var
P : TPoint;
W : TWinControl;
begin
P.X := X;
P.Y := Y;
W := FindVCLWindow( P );
if( nil <> W )then
begin
Result := W.Name;
end else
begin
Result := '';
end;
end;
Listing #1 : Delphi code. Download winname (0.3 KB).
strName :=
GetParentWindowNameAt( 250, 300 );
GetParentWindowNameAt( 250, 300 );
Listing #2 : Delphi code. Download demo1 (0.17 KB).
0 comments:
Post a Comment