For Newbie

Tuesday, 15 November 2011

Window From Point delphi

Window From Point


Tricks to know the window handle, class name and caption / text based on cursor position.

Function used is:
WindowFromPoint function (Point: TPoint): HWND;

Example of use:
TForm1.FormCreate procedure (Sender: TObject);
begin
   Timer1.Interval: = 10;
end;

TForm1.Timer1Timer procedure (Sender: TObject);
var
   PNT: TPoint;
   HND: hWnd;
   clsName, stamp: array [0 .. 255] of Char;
begin
   GetCursorPos (PNT);
   HND: = WindowFromPoint (PNT);
   Label2.Caption: = IntToStr (HND);
   GetClassName (HND, clsName, 256);
   Label4.Caption: = clsName;
   GetWindowText (HND, stamp, 256);
   Label6.Caption: = stamp;
end;

Share on Facebook
Share on Twitter
Share on Google+

Related : Window From Point delphi