ha:hwnd;
i:integer;
begin
ha:=findwindow(nil,pchar(excelapplication1.caption));
showmessage(inttostr(ha));
getwindowrect(ha,posi);
showmessage(inttostr(posi.TopLeft.X));
为何 posi.left,posi.topleft.x 的值均为零,不能正确返回excel窗口的正确位置,
不知道代码错在那里?
i:integer;
begin
ha:=findwindow(nil,pchar(excelapplication1.caption));
showmessage(inttostr(ha));
getwindowrect(ha,posi);
showmessage(inttostr(posi.TopLeft.X));
为何 posi.left,posi.topleft.x 的值均为零,不能正确返回excel窗口的正确位置,
不知道代码错在那里?
var
Rect:TRect;
begin
GetWindowRect(Handle,Rect);
ShowMessage(inttostr(Rect.Left));
end;我这个代码是可以的,有可能是你的posi没有定义成TRect;