2
votes

I'm having trouble to get my Delphi (10.1 Berlin Update 2) application behave correctly in high DPI on Windows 10, April 2018 update. The whole application is by default blurry (scaled by the OS), but if I change the DPI-settings (properties of the exe) to 'application' it behaves correctly. The manifest file of my executable looks like:

sigcheck -m exectuable.exe

Sigcheck v2.60 - File version and signature viewer
Copyright (C) 2004-2017 Mark Russinovich
Sysinternals - www.sysinternals.com

C:\...\executable.exe:
        Verified:       Unsigned
        Link date:      12:05 13-8-2018
        Publisher:      n/a
        Company:        
        Description:    
        Product:        
        Prod version:   
        File version:   
        MachineType:    32-bit
        Manifest:
<?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>
        <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
        <dpiAware>true</dpiAware>
    </windowsSettings>
  </application>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"
        />
        </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
        <application>
                <!--The ID below indicates app support for Windows Vista -->
                <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
                <!--The ID below indicates app support for Windows 7 -->
                <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
                <!--The ID below indicates app support for Windows 8 -->
                <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
                <!--The ID below indicates app support for Windows 8.1 -->
                <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
                <!--The ID below indicates app support for Windows 10 -->
                <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
        </application>
  </compatibility>
</assembly>

This manifest is used in the DPR with {$R 'app.res' 'app.rc'} and the resource file contains only one line:

1 24 .\HighDPI.manifest

I don't want to do anything in runtime, but let the manifest determine the DPI scaling. Can anybody provide me with a solution to prevent Windows scaling my application in high DPI?

2
I have noticed on my own programs, that if I run them from within the IDE, they do not run HighDPI, but if I run them outside the IDE, they properly detect and use HighDPI. Could it be something like this you have encountered?HeartWare
The app uses HighDPI if I run it from the IDE, but ONLY if I use the IDE in HighDPI (eg. changing the DPI-settings from bds.exe). Outside the IDE it never uses high DPI.Laurens
You are not executing your application (outside the IDE) using a non-HighDPI application? It is run directly from Explorer / Command Line? If so, I cannot explain what you are seeing.HeartWare
Outside the IDE, my application refuses to use high DPI (unless changing the properties) and the OS is always scaling my app. It looks like the IDE spawns my application process using the same (overridden) DPI-settings and therefore it works from within the IDE, but not outside. So, my questions still remains how to get the manifest working (or something else), to get my app using HighDPI without overruling the default settings of the executable.Laurens
What is your system setting under "Advanced scaling settings" option "Fix scaling for apps": "Let Windows try and fix apps so they're not blurry" set to on? (search for Scaling in Windows Settings, select "change ..." then Advanced scaling settings under the % drop down.Brian

2 Answers

1
votes

dpiAware tag also needs xmlns property. I use following manifest as a template:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity
    name="MyApp"
    processorArchitecture="*"
    version="1.0.0.0"
    type="win32"
  />
  <description>My Application description</description>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="*"
        publicKeyToken="6595b64144ccf1df"
        language="*"
      />
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="asInvoker"
          uiAccess="false"
        />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <application xmlns="urn:schemas-microsoft-com:asm.v3">
    <windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">
PerMonitorV2, PerMonitor</dpiAwareness>
    </windowsSettings>
  </application>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
    </application>
  </compatibility>
</assembly>

P.S. Make sure to upgdare to latest Delphi, they have added a ton of HiDPI fixes over Berlin Update 2.

0
votes

The problem you are encountering here is that Windows 10 is primarily reading manifest file that is embeded in executable rather than external manifest file.

From Windows Vista and beyond embeded mainfest has higher priortiy than the external one as it was on Windows XP

https://stackoverflow.com/a/17876811/3636228

So if you want the properties of your external manifest to take into effect you will have to remove the embeded manifest file from the executable.