使用 FindWindow() 检索窗口句柄并使用 GetWindowRect() 获得坐标:
var
NotepadHandle: hwnd;
WindowRect: TRect;
begin
NotepadHandle := FindWindow(nil, 'Untitled - Notepad');
if NotepadHandle <> 0 then
GetWindowRect(NotepadHandle, WindowRect)
end;
Run Code Online (Sandbox Code Playgroud)
尝试使用该GetWindowRect
功能
var
lpRect: TRect;
begin
GetWindowRect(Edit1.Handle,lpRect);
ShowMessage(Format('%d,%d',[lpRect.Left,lpRect.Top]));
end;
Run Code Online (Sandbox Code Playgroud)