High DP scaling override winforms

65 Views Asked by At

We have an application which displays fine when using windows display settings 100% but not when for example set to 125%. It is a lot of work to fix this in code (setting AutoScaleMode etc; also have some older 3rd party controls which might be a problem) so looking for another solution.

There is a setting for an application in properties/compatibility to "High DPI scaling override". For example Application (will not scale and remain the same size as with 100%) or "System" or "System (enhanced)". If I change to use for example System (enhanced) the application will scale fine and all labels and controls are correctly scaled.

However since this application is deployed using click-once we can't use that. So looking to to the same with code or app.config settings.

I am aware of the DpiAwareness config settings but does not give same result as using "High DPI scaling override". It looks a lot better but not as good as with "High DPI Scaling override". And AFAIK there is no setting which well let you set the equivalent of High DP override= Application.

So what I am looking is to be able to do the same as "High DPI Scaling override" does but with code / app.config/ manifest setting.

I have also tried to add this to manifest file which is almost working:

  <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>

This almost works with one exception. We have one form with an embedded browser and that does not display correctly (which it does when using the "High DPI scaling override").

Another option is to use a registry hack (setting "High DPI scaling override" actually set a registry setting) in AppCompatFlags\Layers. But if I can do it other than setting this in registry it would be better.

Edit:

I was wrong about "System enhanced" (set with "high DPI scaling override". Now when I run it it did show the same behavior as the above manifest setting (but when I first tried it did work. Don't understand why).

However I found a manifest setting which did work:

    <asmv3:windowsSettings>
      <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">false</dpiAware>
      <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">unaware</dpiAwareness>
   </asmv3:windowsSettings>
0

There are 0 best solutions below