7

I am developing Windows form application using C# on Visual Studio 2010. I found that this application is scaled if I used high dpi display setting. But if I activate file property "disable display scaling on high dpi settings" by mouse right click menu on windows explorer, it seems that it is not scaled.

Is there a way to activate "disable display scaling on high dpi settings" programatically on Visual Studion 2010 C# or upper version ?

I tried to set application manifest file but not set it up successfully yet.

Infinity Challenger
  • 1,090
  • 10
  • 19
Shoji Urashita
  • 826
  • 2
  • 11
  • 22

1 Answers1

7

Using manifest file (app.manifest under Visual C# project) resolved this issue for me. For example:

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

Of course this should be inside your main "assembly" section.

P.S. I verified this when debugging GitExtensions.

P.P.S. I understand that the question is old, but may be someone still needs the info.

Update: however it may lead to automatical undesired resizing of components on the windows form.

Do-do-new
  • 794
  • 8
  • 15
  • 1
    With Frameworks .NET Framework 4.6 and higher the code is automatically generated in app.manifest. It is commented out, so you have to uncomment it, but if you are at 4.6 and higher you also need to adjust app.Config where you " set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true'" – amalgamate Nov 26 '19 at 14:34
  • 1
    BTW, using this technique to disable display scaling was highly effective for me. Extremely useful when targeting a single screen resolution. – amalgamate Nov 26 '19 at 16:32