Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ windows 8上的CreateWindow似乎创建的窗口太大_C++_Createwindow - Fatal编程技术网

C++ windows 8上的CreateWindow似乎创建的窗口太大

C++ windows 8上的CreateWindow似乎创建的窗口太大,c++,createwindow,C++,Createwindow,我在Windows8.1上调用CreateWindowEx(如下),其大小为1920x1080(本机分辨率),生成的窗口要大得多(可能是2倍) 我在文档中读到,尺寸参数应以设备单位表示。我的直觉是,这是问题的原因,但我没有找到关于如何转换或指定适当的单位或禁用它,以便我可以指定像素的文档 仅供参考,该设备是Surface Pro II。对于来自谷歌的任何人,我补充道: setProcessDPIaaWareness(过程\u DPI\u感知::过程\u系统\u DPI\u感知) 在我呼叫 Cre

我在Windows8.1上调用CreateWindowEx(如下),其大小为1920x1080(本机分辨率),生成的窗口要大得多(可能是2倍)

我在文档中读到,尺寸参数应以设备单位表示。我的直觉是,这是问题的原因,但我没有找到关于如何转换或指定适当的单位或禁用它,以便我可以指定像素的文档


仅供参考,该设备是Surface Pro II。

对于来自谷歌的任何人,我补充道:

setProcessDPIaaWareness(过程\u DPI\u感知::过程\u系统\u DPI\u感知)

在我呼叫
CreateWindow()


没有提到要链接哪个lib,但它应该是
shcore.lib

,这肯定是因为您的程序不是。因此,您的窗口会自动重新缩放,以匹配视频适配器的DPI,可能设置为150%或更高。感谢@HansPassant,这是我需要的SetProcessDpiAwareness功能。对于来自谷歌的任何人,我在调用CreateWindow()之前添加了SetProcessDPIaware(PROCESS\u DPI\u AWARE::PROCESS\u SYSTEM\u DPI\u AWARE)。“建议您通过应用程序清单设置流程默认DPI感知”(VS:“清单工具”->“输入和输出”->“DPI感知”)
    HWND windowHandle;

    DWORD style = WS_POPUP;
    DWORD exStyle = WS_EX_APPWINDOW;

    RECT rect;
    SetRect(&rect, left, top, right, bottom);
    ::AdjustWindowRectEx(&rect, style, false, exStyle); 

    windowHandle =
    ::CreateWindowEx(
        WS_EX_APPWINDOW,
        title,              //name of the window class
        title,              //title
        style,              //style flags 
        left, top, right - left, bottom - top,
        NULL,               //parent window
        NULL,               //menu
        applicationHandle,  //handle to application (given at WinMain)
        NULL);