1

I have an old-school ordinary WinForms app in VS2019, for which the tabs on a tab control are vertically squished on a high-DPI monitor. In fact, if the app is opened on a high-DPI monitor and dragged to a regular monitor, the tabs remain squished. I want the app to automatically scale the controls properly. As a user, I can make that happen post-installation by adjusting Compatibility Settings on the executable: [Properties->Compatibility->Change high DPI settings->High DPI scaling Override->Override high DPI scaling behavior. Scaling performed by System (Enhanced)]. I don't want the user to have to do that -- I'd rather fix it in the source code.

I've read dozens and dozens of articles on this subject and it seems they are all outdated, as the 'recommended method' has changed several times over the past few years (and none of them seem to work). The bottom line is that it seems likeI need to do the opposite of what most of them advise -- specifying that the app is DPI-aware (i.e. turning 'DPI-awareness' 'on'). It is NOT DPI-aware, but the 'System (Enhanced)' scaling (seemingly intended precisely for non-DPI-aware apps) works great. But maybe I misunderstand what 'DPI-awareness' means.

What is currently the best practice for specifying programmatically (or via the manifest) that 'this app does not have any provisions for scaling itself or being aware of how many pixels per inch your monitor has, but allowing "System (Enhanced)" scaling from Windows 10 works great. Please do that.'?

Jimbo1987
  • 111
  • 1
  • 16
  • Note the following seems to contain *a* right answer, but it seems pretty obscure, and I wonder if there is a *better* answer. I don't know how anybody ever came up with that one. https://stackoverflow.com/questions/46428510/enhanced-system-dpi-scaling-with-vs2017 – Jimbo1987 Jan 20 '22 at 22:03
  • Here's another mention of that same answer (manifest is indeed the way to communicate compatibility mode requests to the OS) and also has a code-based solution: https://stackoverflow.com/a/55316969/103167 – Ben Voigt Jan 20 '22 at 22:45
  • Note that your app isn't High-DPI-unaware -- it is aware of exactly what scaling algorithm should be in effect. – Ben Voigt Jan 20 '22 at 22:47
  • Add `system` to the manifest. https://learn.microsoft.com/en-us/windows/win32/hidpi/setting-the-default-dpi-awareness-for-a-process#setting-default-awareness-with-the-application-manifest – Hans Passant Jan 21 '22 at 01:24
  • Thanks Hans and Ben. I did figure out how to do it via the manifest, but the following Microsoft resource tells me " Important: In previous versions of the .NET Framework, you used the manifest to add high DPI support. This approach is no longer recommended, since it overrides settings defined on the app.config file." : https://docs.microsoft.com/en-us/dotnet/desktop/winforms/high-dpi-support-in-windows-forms?view=netframeworkdesktop-4.8 . I tried setting it in the app.config file instead, per Microsoft's 'updated' guidance' to no avail. I tried 'system' as well as PerMonitorV2'. No love. – Jimbo1987 Jan 22 '22 at 11:43

0 Answers0