Disable DPI Awareness for specific elements (Win)

Any ideas if is it possible to exclude specific GUI elements from being automatically resized/stretched, when running DPI aware JUCE standalone app? Or do i have to disable JUCE DPI awareness and do everything by myself?

For example, I would like to display different version of bitmap, depending on screen scaling. What would be the proper approach to achieve that.

Thx!

No, Windows DPI awareness is an application-wide setting. It is possible to temporarily disable DPI awareness for the calling thread before opening a new top-level HWND by using the ScopedDPIAwarenessDisabler helper which is what we do in the AudioPluginHost when the DPI-aware setting is disabled:

However this probably isn’t the behaviour that you want as Windows will bitmap stretch non DPI-aware HWNDs to the correct size.

The ComponentPeer::getPlatformScaleFactor() method will return the native backing scale factor for the window which may be what you need.

1 Like

So the only way is to to disable JUCE DPI awareness (JUCE_WIN_PER_MONITOR_DPI_AWARE set to 0) and take complete care of scaling by myself?

If i understand correctly … If i don’t disable it, JUCE will stretch everything automatically and with DPIAwarenessDisabler, Windows will stretch it automatically (instead of JUCE).

Btw. how should i set my app to be DPI aware … with manifest?

With JUCE_WIN_PER_MONITOR_DPI_AWARE=0 JUCE applications will be “system” DPI-aware which means that they will be bitmap stretched when displayed on auxiliary monitors.

You can read more about the different types of Windows DPI awareness here:

This happens in JUCE here:

1 Like

Thanks!