Enhanced system DPI scaling with VS2017(使用 VS2017 增强系统 DPI 缩放)
问题描述
我有一个具有默认 MFC DPI 支持的 MFC 应用程序:它支持高 DPI,但不支持每个显示器的 DPI.Windows 10 版本 1703 添加了对 系统(增强)DPI 缩放.我从 Windows 资源管理器的 .exe 兼容性设置中启用了此模式,它适用于我的应用.
I have a MFC app that has default MFC DPI support: it is high DPI aware, but not per-monitor DPI aware. Windows 10 version 1703 added support for System (enhanced) DPI scaling. I enabled this mode from Windows Explorer in the .exe compatibility settings, and it works for my app.
理想情况下,我会让应用完全符合多显示器 DPI 的要求,但这是一项相当大的工作量.因此,如果操作系统支持,我想告诉操作系统为我的应用程序使用系统(增强)DPI 缩放.
Ideally, I'd make the app fully multi-monitor DPI compliant, but that's a fair amount of work. So instead, I want to tell the OS to use system (enhanced) DPI scaling for my app, if the OS supports it.
应用程序的清单是否启用此功能,如果启用,需要添加或更改什么?
Does the applications's manifest enable this, and if so, what needs to be added or changed?
另外,如何修改清单?目前,我正在使用默认的 Visual Studio 2017 MFC 项目结构,该结构在我的项目中没有清单文件.相反,清单的内容被指定为项目属性,并且清单是使用 mt.exe 生成的.我可以用 mt.exe 注入更改吗?如果我需要用自定义清单替换清单,最简单的方法是什么?
Additionally, how do I modify the manifest? Currently, I'm using the default Visual Studio 2017 MFC project structure, which doesn't have a manifest file in my project. Instead, the manifest's contents are specified as project properties, and the manifest is generated with mt.exe. Can I inject a change with mt.exe? If I need to replace the manifest with a custom one, what's the easiest way?
推荐答案
添加 gdiScaling 设置应用程序的清单,以告诉 Windows 在所有监视器上应用 GDI 缩放.
Add the gdiScaling setting to your application's manifest to tell Windows to apply GDI scaling on all monitors.
- 在您的项目中创建一个新文件
GdiScaling.manifest
.
<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>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
- 在项目设置中,在 Manifest Tool 中,将 Additional Manifest Files 设置为
GdiScaling.manifest
.这会将您的 GDI 缩放设置合并到生成的清单的其余部分.
- In project settings, in Manifest Tool, set Additional Manifest Files to
GdiScaling.manifest
. This will merge your GDI scaling settings into the rest of the generated manifest.
当您构建时,您会收到一条警告,指出 Microsoft 没有采取行动,但您已经知道这一点.:-) 警告的确切文本是这样的:
When you build, you will get a warning about Microsoft not having its act together, but you already knew that. :-) The exact text of the warning is this:
GdiScaling.manifest:清单创作警告 81010002:命名空间http:///schemas.microsoft.com/SMI/2017/WindowsSettings".
GdiScaling.manifest : manifest authoring warning 81010002: Unrecognized Element "gdiScaling" in namespace "http://schemas.microsoft.com/SMI/2017/WindowsSettings".
幸运的是,Windows 并不关心并识别出该设置.
Fortunately, Windows doesn't care and recognizes the setting anyway.
这篇关于使用 VS2017 增强系统 DPI 缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:使用 VS2017 增强系统 DPI 缩放
- 一起使用 MPI 和 OpenCV 时出现分段错误 2022-01-01
- 从python回调到c++的选项 2022-11-16
- C++ 协变模板 2021-01-01
- Stroustrup 的 Simple_window.h 2022-01-01
- 近似搜索的工作原理 2021-01-01
- 与 int by int 相比,为什么执行 float by float 矩阵乘法更快? 2021-01-01
- 静态初始化顺序失败 2022-01-01
- 如何对自定义类的向量使用std::find()? 2022-11-07
- STL 中有 dereference_iterator 吗? 2022-01-01
- 使用/clr 时出现 LNK2022 错误 2022-01-01