VS2017增强了系统DPI缩放 [英] Enhanced system DPI scaling with VS2017

查看:1269
本文介绍了VS2017增强了系统DPI缩放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个MFC应用程序,该应用程序具有默认的MFC DPI支持:它对DPI的了解很高,但对每个监视器的DPI却不了解. Windows 10版本1703添加了对

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. 在项目设置中的清单工具中,将其他清单文件"设置为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:/中无法识别的元素"gdiScaling" /schemas.microsoft.com/SMI/2017/WindowsSettings ".

幸运的是,Windows不在乎并且仍然可以识别该设置.

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆