Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 665
Edward Brey Avatar asked Sep 26 '17 13:09

Edward Brey


People also ask

What does enable high DPI Scaling do?

High-DPI scaling improvements on Windows 10 The new option is called "System (Enhanced)," and when enabled the text and interface will look crispier and elements will be sized correctly. Though, some parts of the app may continue to look a little blurry, but it's still a significant improvement.

How do I fix DPI scaling issues for Visual Studio 2019?

There are three options to resolve the display problem: Restart Visual Studio as a DPI-unaware process. Add a registry entry. Set your display scaling setting to 100%

How do you override high DPI scaling behavior?

Select Display > Change the size of text, apps, and other items, and then adjust the slider for each monitor. Right-click the application, select Properties, select the Compatibility tab, and then select the Disable display scaling on high DPI settings check box.

What is DPI scaling Windows 10?

DPI setting controls the size of the text, apps and icons. A lower DPI setting will make them appear smaller and a higher setting will make them appear bigger. By default Windows has setting of 96 DPI.


1 Answers

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.

like image 59
Edward Brey Avatar answered Sep 20 '22 13:09

Edward Brey