High DPI support for non-plugins on Windows

Hi, I’m back with my DPI issue fix for Windows :slight_smile: See my previous post which holds a potential fix for Juce 5.3.2. We’ve now upgraded our code base to use Juce 6.0.5 instead, and so I needed to re-apply a similar fix again.

The issue is that (on Windows) standalone Juce applications have proper DPI scaling, and I imagine VST plugins have proper support too (I read something about the host passing on the scaling to use to the plugins?), but plugins for unrelated applications are left at the mercy of their host application’s DPI handling setting. In case we’re not a standalone app, Juce defaults to a 100% DPI scaling, so when the host informs Windows it’s perfectly DPI aware, this results in tiny controls on high DPI monitors in standalone Juce dialogs.

The fix I applied is that when we’re not a standalone app, I query for the DPI support the host has set once, and then (where needed) toggle the DPI support to “per-monitor aware” using SetThreadDPIAwarenessContext for the current thread (and revert it back when not needed anymore). This way no matter which DPI support the host has, the Juce dialogs get sized correctly and look nice and crispy.
Where this is not supported (pre-Windows 10.1703), the code could fall back to use SetThreadDPIAwareness instead (for everything from Windows 8.1 upward); this has to be added to the code though.

There are probably quite a few issues with the code though… For one, I added all of this behind the preprocessor define JUCE_WIN_PER_MONITOR_DPI_AWARE, so for code bases not using this define the fix won’t work (don’t know if that would even make sense though). But I tested it on Windows 7, Windows 8.1 and Windows 10 for one particular host (Adobe Premiere), and on all those combinations the result is good. Then again the changes might very well wreck havoc for VST plugins under their hosts; there’s no way for me to test for that.

I report a simular problem in this thread. I want use unify good on my 4k monitor. developer of unify report this Use font and size from DAW in juce popup menus? - #23 by getdunne

there can see in the changelog of 6.1.2 that some small enhancements are done for better DPI support. really strange wy juce this not support since such long time with a small example code in plugins. all users with 4 k monitor or larger scale on windows need this. I have a dell inspiron witch a 13,3 4k display. this have windows desktop scale size of 300%. on my desktop PC i set it to 175%. small fonts is not good for health. also when have small fonts move head instinctly more near to monitor which cause unhealty sitting position

Hi Calvin,

I don’t know what haryvincent176 meant by re-posting only the top part of a post of mine, but please see my original post where I also link to a possible solution too. It also links to my solution for Juce 5.