对于分辨率为1536x960的单台显示器上Windows 10桌面应用程序的最大化活动窗口,我通过以下方式检索其坐标:
IntPtr hwnd = GetForegroundWindow();
Rectangle bounds = GetWindowRect(hwnd);
Console.WriteLine("Left: " + bounds.Left);
Console.WriteLine("Right: " + bounds.Right);
Console.WriteLine("Top: " + bounds.Top);
Console.WriteLine("Bottom: " + bounds.Bottom);
这将输出:
Left: 0
Right: -2080342032
Top: 0
Bottom: 695
右坐标如此混乱的可能原因是什么?
1条答案
按热度按时间slmsl1lt1#
您调用
GetWindowRect
的方式不正确。请尝试执行以下操作,注意它返回了一个bool
,边界在out
参数中给出:就像这样称呼它: