Description:
In my development environment, I have a machine with Windows 10 Creators Update operating system installed and a High Resolution monitor with a non default DPI (>96) setting applied. So, after I designed an application using this monitor, this application is downscaled when launched on a monitor with lower DPI settings. As a result, my application layout is completely broken. Is there a way to disable VisualStudio DPI awareness so my application targets default DPI (96) settings?
Answer:
Yes, there is an undocumented way to make VisualStudio DPI unaware. So, it's up to you whether or not to use this solution.
The main idea of this approach is to mark VisualStudio as DPI unaware by adding a specific flag to the System registry.
In the attachment, you can find the MakeVisualStudioDPIUnaware reg file.
This file is intended to mark only VisualStudio as DPI unaware and doesn't affect applications hosted by VisualStudio. As a result, it allows you to debug your applications more efficiently, because if your project is marked as DPI aware, it still takes DPI settings applied into account when launched under the VisualStudio debugger.
Important note.
The above mentioned solution works only on Windows 10 operating systems with the applied Creators Update (version 1703 and higher).
To check your operating system's version, open Settings and navigate to System > About. Here, you can see your operating system's edition (Home, Pro or Enterprise), version and build.
Note that Visual Studio 2017 build 15.8 and later provides a built-in way to disable DPI awareness. See the Disable DPI-awareness in Visual Studio article to learn more.
Visual Studio 2022 v17.8 and newer also supports the ForceDesignerDpiUnaware
option. This option enforces the DpiUnAware
mode for all WinForms designers in the project, regardless of the ApplicationHighDpiMode
, which continues to take effect during runtime. See Designer HighDpi mode at dotnet/winforms.