将代码从 Visual Studio 6 移植到 Visual Studio 2013 后对话框边框不同

我刚刚将一个基于对话框的 MFC 程序从 Visual Studio 6 移植到 Visual Studio 2013.没有重大问题,程序在 VS 2013 下编译后运行完美.

I have just ported a dialog based MFC program from Visual Studio 6 to to Visual Studio 2013. There were no major issues and the program runs perfectly once compiled under VS 2013.

唯一可见的区别是对话框边框的粗细(参见下面在 Windows 7 下制作的屏幕截图).

The only visible difference is the thickness of the dialog's borders (see screen shots below made under Windows 7).

更多事实:

  • 这不是清单问题,新旧版本的清单完全相同.
  • .rc 在 VS2012 项目转换过程中没有被弄乱.如果我用 VS6 再次编译转换后的项目,我会得到细边框.
  • 我可以在 Visual Studio 6 中使用新生成的向导程序重现该问题.
  • 使用 AfxMessageBox 显示的消息框在使用 VS6 编译时也具有细边框,在编译时具有粗边框使用 VS2013.
  • It's not a manifest issue, both manifests in the old and new versions are strictly the same.
  • The .rc hasn't been messed up during the conversion of the project by VS2012. If I compile the converted project again with VS6 I get thin borders.
  • I can reproduce the issue with a freshly wizard generated program in Visual Studio 6.
  • A message box shown with AfxMessageBox also has a thin border when compiled with VS6 and a thick border when compiled with VS2013.

推荐答案

我也遇到过类似的问题,和PE header的subsystem flag有关.

I have experienced similar issue and it was related with subsystem flag of PE header.

我需要稍微调试 Windows 才能找到原因:函数 win32k!_GetWindowBorders 根据 6.0 检查 PE 标志(可能是为了支持新标志 SM_CXPADDEDBORDER).

I needed to debug Windows a bit to find the reason: the function win32k!_GetWindowBorders checks that PE flag against 6.0 (probably to support new flag SM_CXPADDEDBORDER).

另见:

  • 回归:::GetSystemMetrics 提供不同的值

相关文章