Why is a winform shown different on the same 4k monitor

Maybe you are aware of this, but it was not mentioned before:

There are 3 kinds of applications:

  • Not DPI aware
  • System DPI aware
  • Per monitor DPI aware

Details here: https://msdn.microsoft.com/de-de/library/windows/desktop/dn469266(v=vs.85).aspx

You can set the DPI-awareness on your application in app.config:

<appSettings>
    <add key="EnableWindowsFormsHighDpiAutoResizing" value="false" />
</appSettings>

and app.manifest:

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

When you have a DPI >= 150% scaling can additionally controlled via RMB on application -> Properties -> Compatibility -> Scaling on high DPI

For Windows Forms the default is DPI-Scaling disables for high DPI. So everything shoud work out of the box. Maybe one of this settings is not on default? Especially the configuration in the RMB properties on the exe?


Microsoft is aware of this problem and fixed it with the .Net 4.7 Framework:

https://blogs.msdn.microsoft.com/dotnet/2017/04/05/announcing-the-net-framework-4-7/

Tags:

C#

Winforms