寻找外部窗口的位置?

Jef*_*eff 4 windows delphi window-handles

如何在 Delphi 中找到窗口句柄的屏幕相对位置?(X,Y)

kar*_*lip 6

使用 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)


RRU*_*RUZ 5

尝试使用该GetWindowRect功能

var
  lpRect: TRect;
begin
   GetWindowRect(Edit1.Handle,lpRect);  
   ShowMessage(Format('%d,%d',[lpRect.Left,lpRect.Top]));
end;
Run Code Online (Sandbox Code Playgroud)