3

I tried all possible combinations of gdiScaling and dpiAware, still no luck.

If I manually right click app.exe and set "Override high DPI scaling" to "System (Enhanced)", it works great.

<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>
      <dpiAware>False</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>

</assembly>
Alex
  • 34,581
  • 26
  • 91
  • 135
  • @magicandre1981 didn't help – Alex Mar 23 '19 at 17:46
  • ok, I extracted the manifest of mmc.exe and this must work as it works for device manager in windows 10. – magicandre1981 Mar 23 '19 at 18:20
  • Try to log off Windows, and log back in, restart the application with new DPI settings. – Barmak Shemirani Mar 24 '19 at 05:17
  • System Enhanced compatibility setting is stored in registry HKCU\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers (or HKLM if you want it to be machine wide). There's a key with the app path and a string: https://superuser.com/questions/1230346/overriding-high-dpi-scaling-from-the-command-line. Also many frameworks used for developing UI try to do "smart" things that sometimes get in the way between you and Windows. So it can depend on your app, how it's written, etc. – Simon Mourier Mar 24 '19 at 09:38

3 Answers3

3

Try this manifest:

<asmv3:application>
   <asmv3:windowsSettings>
        <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
        <gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling>
   </asmv3:windowsSettings>
</asmv3:application>

it is ripped from MMC.exe of Windows 10 1809 which hosts device manager and this must work:

The Microsoft Management Console (mmc.exe) will be GDI scaled, by default, in the Creators Update. This means that many in-box Windows snap ins, such as Device Manager, will benefit from this feature in the Creators Update.

If this also doesn't work, enable it via code with SetProcessDpiAwarenessContext function and DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALEDwhich is defined in "Include\10.0.BUILDNUMBER.0\shared\windef.h" as

#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED    ((DPI_AWARENESS_CONTEXT)-5)
magicandre1981
  • 27,895
  • 5
  • 86
  • 127
  • Thanks for this. It really should work. My hello.rc is `1 24 "hello.exe.manifest"`, I compile it with `i686-w64-mingw32-windres hello.rc -O coff -o hello.res`, then I add `hello.res` to the gcc arg list. – Alex Mar 23 '19 at 18:27
  • But it doesn't. – Alex Mar 23 '19 at 18:35
  • use [resourcehacker](http://angusj.com/resourcehacker/) to see if the manifest is added correctly. – magicandre1981 Mar 23 '19 at 18:42
  • if this also doesn't work, [enable it via code](https://stackoverflow.com/a/51748836/1466046) with **SetProcessDpiAwarenessContext** function and **DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED** – magicandre1981 Mar 23 '19 at 18:48
  • also try to compile the code with VS2017 community edition, maybe you hit a MinGW bug – magicandre1981 Mar 23 '19 at 18:50
  • My windef.h doesn't have DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED, could you please write its value? – Alex Mar 24 '19 at 09:34
  • I see it in \Include\10.0.17763.0\shared\windef.h with **#define DPI_AWARENESS_CONTEXT_UNAWARE_GDISCALED ((DPI_AWARENESS_CONTEXT)-5)** – magicandre1981 Mar 24 '19 at 12:11
  • again, install VS2017 with Win10 17763 SDK to have the up to date headers. – magicandre1981 Mar 24 '19 at 12:12
0
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
        <dpiAware>false</dpiAware>
    </windowsSettings>
</application>
</assembly>

And make sure you don't have a dpiAwareness tag at all. Check for manifest merging; strings works adequately for inspecting the manifest of the final binary. The dpiAware tag contents are case sensitive. However, since false is the default if the tag is missing, I am lead to believe that rather SetProcessDpiAware or SetProcessDpiAwareness is being called by something. Check with strings to verify that you have no references to SetProcessDpiAware.

You could attempt to fight fire with fire by a call to SetProcessDpiAwareness(PROCESS_DPI_UNAWARE); right before you create your first window; however this is a bad idea.

All information is drawn from MSDN Setting the default DPI awareness for a process, MSDN SetProcessDPIAwareness, and personal experience dealing with this material.

Joshua
  • 40,822
  • 8
  • 72
  • 132
0

Make sure your manifest ID is 1. I managed to get it working with Dev-C++ 5.11/MinGW 4.9.2 with an .exe named win32opengl.exe. Here are my file contents:

resource.h

#ifndef RESOURCE_H
#define RESOURCE_H
#define ID_MANIFEST 1
#endif

resource.rc

#include "resource.h"
ID_MANIFEST 24  "win32opengl.exe.manifest"

win32opengl.exe.manifest

<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>
Andrew Lim
  • 196
  • 3
  • 9