Visual Studio 2015 CreateWindowEx() 使用不同的单位 Debug/Release Windows API C++
Visual Studio 2015 CreateWindowEx() uses different units for Debug/Release Windows API C++
我在 Visual Studio 2015 年使用 C++ 和 Windows API 制作了一个简单的基础转换器。一切顺利,但是当我在调试和发布模式下测试它时,我发现了一些奇怪的东西。
这是我的 window 在 Debug 中测试时的样子:
Debug Screenshot
但这是相同的代码,只是在发布模式下编译:Release Screenshot
创建 window 的代码完全相同:
hWnd = CreateWindowEx(NULL, lpszWndClassName, lpszWndTitle, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 225, 350, NULL, NULL, hInstance, NULL);`
但是同样的代码,只有一个在 Debug 中编译,一个在 Release 中编译,怎么会产生不同的结果呢?
在CreateWindow()
的文档中,第六个参数(nWidth
)描述为:
The width, in device units, of the window. For overlapped windows,
nWidth is either the window's width, in screen coordinates, or
CW_USEDEFAULT. If nWidth is CW_USEDEFAULT, the system selects a
default width and height for the window; the default width extends
from the initial x-coordinate to the right edge of the screen, and the
default height extends from the initial y-coordinate to the top of the
icon area. CW_USEDEFAULT is valid only for overlapped windows; if
CW_USEDEFAULT is specified for a pop-up or child window, nWidth and
nHeight are set to zero.
在这种情况下 "device units" 是什么?它们是像素吗?为什么 Debug/Release 的单位不同?
感谢@DavidHeffernan 和@HarryJohnston 的评论,问题现已解决。问题是因为在调试配置中,平台工具集设置为 Visual Studio,但在发布中它是 Visual Studio - Windows XP。 XP 配置一定影响了主图 window.
我在 Visual Studio 2015 年使用 C++ 和 Windows API 制作了一个简单的基础转换器。一切顺利,但是当我在调试和发布模式下测试它时,我发现了一些奇怪的东西。
这是我的 window 在 Debug 中测试时的样子: Debug Screenshot
但这是相同的代码,只是在发布模式下编译:Release Screenshot
创建 window 的代码完全相同:
hWnd = CreateWindowEx(NULL, lpszWndClassName, lpszWndTitle, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, 225, 350, NULL, NULL, hInstance, NULL);`
但是同样的代码,只有一个在 Debug 中编译,一个在 Release 中编译,怎么会产生不同的结果呢?
在CreateWindow()
的文档中,第六个参数(nWidth
)描述为:
The width, in device units, of the window. For overlapped windows, nWidth is either the window's width, in screen coordinates, or CW_USEDEFAULT. If nWidth is CW_USEDEFAULT, the system selects a default width and height for the window; the default width extends from the initial x-coordinate to the right edge of the screen, and the default height extends from the initial y-coordinate to the top of the icon area. CW_USEDEFAULT is valid only for overlapped windows; if CW_USEDEFAULT is specified for a pop-up or child window, nWidth and nHeight are set to zero.
在这种情况下 "device units" 是什么?它们是像素吗?为什么 Debug/Release 的单位不同?
感谢@DavidHeffernan 和@HarryJohnston 的评论,问题现已解决。问题是因为在调试配置中,平台工具集设置为 Visual Studio,但在发布中它是 Visual Studio - Windows XP。 XP 配置一定影响了主图 window.