How to set the dpiAware property in the manifest of a Windows application to "on the monitor" in Visual Studio?

I need to be able to set the dpiAware property in the manifest of my application to "on the monitor." Available property options are simply to enable or disable DPI awareness. None of these settings work for me. I can get the behavior that I want for my application if I do not embed the manifest in exe and then edit the manifest manually. I want to automatically generate and implement a manifest. Is there something I'm missing? (I am using Visual Studio 2013.)

+7
source share
3 answers

This manifest works, but the <dpiAware>True/PM</dpiAware>most important part:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
    </application>
  </compatibility>

  <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <asmv3:windowsSettings
         xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>True/PM</dpiAware>
    </asmv3:windowsSettings>
  </asmv3:application>

</asmv1:assembly>
+11
source

New in Windows 10 is the dpi value as well as dpiAware , so we need to update this example a bit. Now this is normal, because if dpi does not exist, then the settings will be inherited from dpiAware .

To include the fullness of DPI information, with the latest Win10 support (see the Ref URL for other options), which includes " permonitor " and " permonitorv2 ", which I will use instead of "system" because your question asks question.

<asmv3:application>
  <asmv3:windowsSettings>
    <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- legacy -->
    <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to pm if pmv2 is not available -->
  </asmv3:windowsSettings>
</asmv3:application>

, ( dpiAwareness ):

<asmv3:application>
  <asmv3:windowsSettings>
    <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">unaware</dpiAware>
  </asmv3:windowsSettings>
</asmv3:application>

"gdiScaling", GDI .

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

: Microsoft DPI. Windows 10 ( , DPI , )

+9

Windows 10 1607 dpiAwareness. DPI dpiAware, . , DPI.

DPI 2 Windows 10 1607+, DPI- Windows 8.1+ DPI- Windows 7:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <assemblyIdentity type="win32" name="MyApplication" version="1.0.0.0" processorArchitecture="amd64"/>

    <asmv3:application>
        <asmv3:windowsSettings>
            <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
            <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
            <gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling> <!-- enables GDI DPI scaling -->
        </asmv3:windowsSettings>
    </asmv3:application>
</assembly>

DPI, DPI ( ) dpiAware false.

Also, pay attention to the property gdiScalingthat was added in Windows 10 1607. It enables automatic scaling of GDI, if set true. This is very useful if your application uses GDI to draw things.


References:
High DPI DPI scaling with Windows 10 1607
Recording DPI-enabled
applications Applications show up

+6
source

Source: https://habr.com/ru/post/1539811/


All Articles