以编程方式或使用清单 (MinGW) 将 "Override high DPI scaling" 设置为 "System (Enhanced)"
Setting "Override high DPI scaling" to "System (Enhanced)" programmatically or with a manifest (MinGW)
我尝试了 gdiScaling
和 dpiAware
的所有可能组合,仍然没有运气。
如果我手动右键单击 app.exe 并将 "Override high DPI scaling" 设置为 "System (Enhanced)",效果很好。
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0">
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">
<gdiScaling>true</gdiScaling>
<dpiAware>False</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware>false</dpiAware>
</windowsSettings>
</application>
</assembly>
并确保您根本没有 dpiAwareness
标签。检查清单合并; strings
足以检查最终二进制文件的清单。 dpiAware
标签内容区分大小写。但是,由于 false
是缺少标签时的默认值,因此我相信 SetProcessDpiAware
或 SetProcessDpiAwareness
被某些东西调用了。检查 strings
以确认您没有对 SetProcessDpiAware
.
的引用
您可以在创建第一个 window 之前调用 SetProcessDpiAwareness(PROCESS_DPI_UNAWARE);
尝试以牙还牙;然而这是个坏主意。
所有信息均来自 MSDN Setting the default DPI awareness for a process, MSDN SetProcessDPIAwareness,以及处理此问题的个人经验 material。
试试这个清单:
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
</asmv3:windowsSettings>
</asmv3:application>
它是从 Windows 10 1809 的 MMC.exe 中截取的 hosts device manager and this must work:
The Microsoft Management Console (mmc.exe) will be GDI scaled, by
default, in the Creators Update. This means that many in-box Windows
snap ins, such as Device Manager, will benefit from this feature in
the Creators Update.
如果这也不起作用,启用它 with SetProcessDpiAwarenessContext 功能和 DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED
在 "Include.0.BUILDNUMBER.0\shared\windef.h"
中定义为
#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5)
确保你的清单 ID 是 1。我设法让它与 Dev-C++ 5.11/MinGW 4.9.2 一起工作,带有一个名为 win32opengl.exe 的 .exe。这是我的文件内容:
resource.h
#ifndef RESOURCE_H
#define RESOURCE_H
#define ID_MANIFEST 1
#endif
resource.rc
#include "resource.h"
ID_MANIFEST 24 "win32opengl.exe.manifest"
win32opengl.exe.清单
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
我尝试了 gdiScaling
和 dpiAware
的所有可能组合,仍然没有运气。
如果我手动右键单击 app.exe 并将 "Override high DPI scaling" 设置为 "System (Enhanced)",效果很好。
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" manifestVersion="1.0">
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">
<gdiScaling>true</gdiScaling>
<dpiAware>False</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware>false</dpiAware>
</windowsSettings>
</application>
</assembly>
并确保您根本没有 dpiAwareness
标签。检查清单合并; strings
足以检查最终二进制文件的清单。 dpiAware
标签内容区分大小写。但是,由于 false
是缺少标签时的默认值,因此我相信 SetProcessDpiAware
或 SetProcessDpiAwareness
被某些东西调用了。检查 strings
以确认您没有对 SetProcessDpiAware
.
您可以在创建第一个 window 之前调用 SetProcessDpiAwareness(PROCESS_DPI_UNAWARE);
尝试以牙还牙;然而这是个坏主意。
所有信息均来自 MSDN Setting the default DPI awareness for a process, MSDN SetProcessDPIAwareness,以及处理此问题的个人经验 material。
试试这个清单:
<asmv3:application>
<asmv3:windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
</asmv3:windowsSettings>
</asmv3:application>
它是从 Windows 10 1809 的 MMC.exe 中截取的 hosts device manager and this must work:
The Microsoft Management Console (mmc.exe) will be GDI scaled, by default, in the Creators Update. This means that many in-box Windows snap ins, such as Device Manager, will benefit from this feature in the Creators Update.
如果这也不起作用,启用它 DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED
在 "Include.0.BUILDNUMBER.0\shared\windef.h"
中定义为
#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5)
确保你的清单 ID 是 1。我设法让它与 Dev-C++ 5.11/MinGW 4.9.2 一起工作,带有一个名为 win32opengl.exe 的 .exe。这是我的文件内容:
resource.h
#ifndef RESOURCE_H
#define RESOURCE_H
#define ID_MANIFEST 1
#endif
resource.rc
#include "resource.h"
ID_MANIFEST 24 "win32opengl.exe.manifest"
win32opengl.exe.清单
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>