Mega Code Archive

 
Categories / Delphi / System
 

Get the position of the current active window

procedure TForm1.Button1Click(Sender: TObject); var hWindow: HWnd; r: TRect; begin hWindow := GetForegroundWindow; GetWindowRect(hWindow, r); Memo1.Clear; with Memo1.Lines do begin Add('Top : ' + IntToStr(r.Top)); Add('Left : ' + IntToStr(r.Left)); Add('Bottom: ' + IntToStr(r.Bottom)); Add('Right : ' + IntToStr(r.Right)); end; end;