Visual Studio (2015 and upcoming 2017) is a “DPI aware” application. Even our own WinForms based product Royal TS is a “DPI aware” application. But if you are a WinForms developer and use Visual Studio on a high DPI system, you will be surprised how Visual Studio messes up all your WinForms in the designer.
The problem is that Visual Studio is DPI aware but unlike Royal TS, for example, it seemingly cannot run with “display scaling” enabled (display scaling means, the process will be rendered/scaled as it would on a 96 DPI screen).
There are a couple of ways to enable/disable display scaling:
- The Compatibility tab in the .exe file properties dialog
- A .exe.manifest file with true|false
- A Win32 API call SetProcessDPIAware() when the process starts
My MVP fellow Carlos Quintero wrote a great blog post a while back with lots of references.
The main problem with Visual Studio is, the devenv.exe.manifest file is embedded in the executable and therefore the DPI awareness is enforced and cannot be overridden using the above methods.
Solution
It is possible to set DPI awareness for a specific application in the registry if you want to make Visual Studio System DPI “unaware”:
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindows NTCurrentVersionImage File Execution Optionsdevenv.exe] "dpiAwareness"=dword:00000000
The above way is kind of “undocumented”. I did some research but couldn’t find any proper documentation about the dpiAwareness REG_DWORD in the Image File Execution Options key. Setting the REG_DWORD to 1 will make Visual Studio DPI aware again (requires a restart of Visual Studio).
Note: when Visual Studio is DPI “unaware” and display scaling is in effect, fonts and icons may look blurry but the WinForms designer will have no unwanted side-effects.
Attached you will find two .reg files which allows you to quickly switch display scaling on and off for Visual Studio (devenv.exe): Download devenv-dpi.zip
Thanks to Microsoft (Tanya) and to Carlos Quintero for helping me with this!
Co-Founder and CEO of Royal Apps GmbH and Windows lead developer for Royal TS, a multi platform, multi protocol remote management solution, for Windows, macOS and mobile supporting RDP, VNC, SSH, Telnet, and many more.
Long time Microsoft MVP (2010-2020) supporting communities on- and offline as well as speaking at user groups and conferences about DevOps and other software development topics.
Hello, you saved my day! This trick will save me a lot of time, uselessly spent of switching between windows users with high and normal DPI. Thank you!
Is this only supported on Windows 10? Has absolutely no effect on Windows 8.1
Hi Edward,
I haven’t tested it with Windows 8.1 so I can’t really tell. Unfortunately there’s no documentation (at least I couldn’t find any) about this flag. Since Windows 10 has a lot of changes and improvement around handling high DPI, there’s a good chance that this will only work on Windows 10.
Regards,
Stefan
Thank you! Thank you! Thank you! Thank you! Thank you! Thank you!
Thank you so very much! I was nearly going to throw my Surface Pro 4 through the window!
Thank you! Thank you! Thank you! Thank you! Thank you! Thank you! Thank you so very much! I was nearly going to throw my Macbook Pro through the window!
Thank you very much. I ignored my M3800 laptop for a year since Visual Studio messed up the GUI. I searched for different solution but doesn’t work. You trick helps.
Fantastic – thanks! Saved so much time. Worked for me on an app continuously developed since 2006 (VB2005) and now being developed in VS 2017 Community on a Workstation Specialists M Series laptop running Win 10 with a 3840×2160 monitor scaled at 150%
Worked for me also with a High DPI screen laptop (3840 X 2160) set to scalling factor of 200%. Now if I could just make my C++ (unmanaged) application to be High DPI aware.
You, Sir, are a genius! Thank you so very much!!!
cool !!! You saved me a lot of time. Thanks
Thanks, that works great.
Are there news about the topic especially with Framework 4.7.1?
The blured fonts are not so nice 😉
Thanks man. Great…!
Thank you so much, I thought I would have to sell my new Thinkpad X1, but now it’s fine.
Whaouuu that works very well !!
Many and many thanks
Thank you very much. (Çok Teşekkurler) From Turkey
These twists suck the life out of us developers. I cannot thank you enough for this extraordinary fix.
Awesome fix, thank you! It worked for VS2012 Ultimate running under Windows10 running on an HP laptop.
Sure glad this was still up and available. My system at home has dual GTX-1080’s in SLI on 3 – 4K 28″ Samsung monitors. My system at work is a docked HP portable Workstation (laptop) with 2 – 1080P monitors. This was driving me nuts, as I couldn’t bring things home to work on them unless I brought my laptop (and used it’s 15″ built-in). Thanks for the solution and research. I was about to give up! Microsoft should definitely allow users the ability to TOGGLE this in the IDE!
Many thanks. Saves my Surface Book 2 laptop investment.
Just found this. Very many thanks. previously on my Surface 4 I was setting scaling to 100%, restarting and then resetting the scaling to 200%. This worked but was a faf. Your registry editions make it so much easier (especially as I only use winforms).
Wow… Thats great. It literally saved my day.. Thank u so much sir.
I’ve been looking for this solution for two years… literally… Thank you so much!
Many thanks. I’ve been going crazy trying to figure out what was going wrong. This was the fix!
Just a heads up, this is NOT compatible with VS2019. In fact, the presence of this registry key prevents the actual 2019 registry key from working properly and it needs to be deleted for the proper key to take effect.
The proper key (for 2019) is noted in this doc.
https://docs.microsoft.com/en-us/visualstudio/designers/disable-dpi-awareness
Seems to work fine for me in VS2019. Give it a go. What’s the worst that could happen! Thanks very much.
Thank you! Works in Visual Studio Professional 2015 with 4K monitor with resolution set at 3840 x 2160 with 200% scaling.