本文介绍了使用 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.

  1. 在您的项目中创建一个新文件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>
  1. 在项目设置中,在 Manifest Tool 中,将 Additional Manifest Files 设置为 GdiScaling.manifest.这会将您的 GDI 缩放设置合并到生成的清单的其余部分.
  1. 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".

幸运的是,Windows 并不关心并识别出该设置.

Fortunately, Windows doesn't care and recognizes the setting anyway.

这篇关于使用 VS2017 增强系统 DPI 缩放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-04 14:15