本文介绍了如何确定实际的Windows窗体大小(与所有非工作区元素)运行Aero的时候?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图来定位自己的状态precisely上面的任务栏。不幸的是我的努力得到了 this.Height 在我的形式返回一个值比实际的形式10像素更小(与所有的边框,标题栏等的事实制约)。我运行Windows 7的Aero。当航空被关闭(和边框更薄),所有的作品如预期。该表格​​边框样式为 FixedSingle 。我不希望实施航空专用的黑客。我能做些什么,以获得正确的高度?

I'm trying to position my form precisely above the taskbar. Unfortunately my efforts are hampered by the fact that this.Height on my form returns a value which is 10 pixels smaller than the actual form (with all the borders, title bar, etc). I'm running Windows 7 with Aero. When Aero is turned off (and the borders are thinner), all works as expected. The form border style is FixedSingle. I don't want to implement Aero-specific hacks. What can I do to get the correct height?

推荐答案

是的,航空距离我们大约用GetWindowRect返回窗口大小()。这是一个比较重要的appcompat黑客攻击,没有它有太多的项目将有一个客户端区域太小。不幸的是有没有一个API调用,也可以用来关闭谎言清单条目。唯一的办法是设置Windows版本中的EXE文件头并标记Vista兼容。

Yes, Aero lies about the window size returned by GetWindowRect(). It is a rather important appcompat hack, without it far too many programs would have a client area that's too small. Unfortunately there's neither an API call nor a manifest entry that can be used to turn off the lie. The only way is to set the Windows version in the EXE header and mark it Vista compatible.

您可以这样做与Editbin.exe在postbuild事件:

You can do so with Editbin.exe in a postbuild event:

set pathsave=%path%
set path=$(devenvdir);$(devenvdir)..\..\vc\bin
editbin.exe /subsystem:windows,6.0 "$(targetfilename)"
set path=%pathsave%

要注意的是你的程序将在XP后,再此不运行。

Beware that your program will not run in XP anymore after this.

更新:这是现在默认在VS2012做了,而如果你的目标.NET 4.5

UPDATE: this is now done by default in VS2012 and up when you target .NET 4.5

这篇关于如何确定实际的Windows窗体大小(与所有非工作区元素)运行Aero的时候?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 15:09