How can I find the Screen-relative position of a Window Handle in Delphi? (X,Y)
Use FindWindow() to retrieve the handle of the window and and GetWindowRect() to get the coordinates:
var
NotepadHandle: hwnd;
WindowRect: TRect;
begin
NotepadHandle := FindWindow(nil, 'Untitled - Notepad');
if NotepadHandle <> 0 then
GetWindowRect(NotepadHandle, WindowRect)
end;
try using the GetWindowRect
function
var
lpRect: TRect;
begin
GetWindowRect(Edit1.Handle,lpRect);
ShowMessage(Format('%d,%d',[lpRect.Left,lpRect.Top]));
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With