简体   繁体   中英

Enhanced system DPI scaling with VS2017

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.

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?

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?

Add the gdiScaling setting to your application's manifest to tell Windows to apply GDI scaling on all monitors.

  1. Create a new file GdiScaling.manifest in your project.
<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. 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.

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 : manifest authoring warning 81010002: Unrecognized Element "gdiScaling" in namespace " http://schemas.microsoft.com/SMI/2017/WindowsSettings ".

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM