有一个WinForms设置为可调整大小
在Windows 8中,的 DesktopBounds
属性告诉正确的值:
Having a WinForms form with form border style set to Sizable
on Windows 8, the DesktopBounds
property tells the correct values:
相反,具有 FixedDialog
的形式边框样式时,该值是错误的:
In contrast, when having a form border style of FixedDialog
, the values are wrong:
在Windows XP中,值始终是正确的:
On Windows XP, the values are always correct:
我的问题是:
如何获得一个窗口的实际大小,包括完整的非客户区?
How to get the real size of a Window including the complete non-client area?
更新1:
似乎是关系到这太问题。我会尝试,看看这是否会解决我的问题也在这里。
Seems that it is related to this SO question. I'll try and see whether this would solve my issue here, too.
更新2:
只是为了完整性,这里有来自VMware的Windows 7的结果:
Just for completeness, here are the results from a VMware Windows 7:
更新3:
终于找到,其中包括使用的 DwmGetWindowAttribute
功能一起的 DWMWA_EXTENDED_FRAME_BOUNDS
值。我会后下面的答案。
Finally found a solution which involves using the DwmGetWindowAttribute
function together with the DWMWA_EXTENDED_FRAME_BOUNDS
value. I'll post an answer below.
推荐答案
要回答我的问题,我终于发现,其中包括使用的 DwmGetWindowAttribute
功能一起的 DWMWA_EXTENDED_FRAME_BOUNDS
值
To answer my own question, I finally found a solution which involves using the DwmGetWindowAttribute
function together with the DWMWA_EXTENDED_FRAME_BOUNDS
value
答案的灵感来自于这个来源$ C $ C 其中presents功能,似乎工作的所有系统。其核心是一个功能
The answer was inspired by this source code which presents a function that seems to work on all system. The core is a function
public static Rectangle GetWindowRectangle(IntPtr handle)
{
if (Environment.OSVersion.Version.Major < 6)
{
return GetWindowRect(handle);
}
else
{
Rectangle rectangle;
return DWMWA_EXTENDED_FRAME_BOUNDS(handle, out rectangle)
? rectangle
: GetWindowRect(handle);
}
}
下面是的code 的全引擎收录。
相关推荐
最新文章