Strange popup-menu issues (HiDPI, 2 displays, using ScopedDPIAwarenessDisabler)

I have here JUCE5 »Hello, world« application with tray icon. Click on tray icon also shows simple popup menu. IMPORTANT: app is creating instance of ScopedDPIAwarenessDisabler class before showing main window. I need it, because my application scaling must be managed by OS and not by JUCE.

Now, there are some strange issues happening, when using this app with 2 monitors. Monitor settings: left (1st) monitor is not scaled and 2nd HiDPI monitor (on the right) is scaled to 150%.

The actual problem is that in some situations, popup menu is not displayed correctly.

How to replicate the issue (image 1 attached):

App’s main window must be located on right (2nd) monitor - click on the tray icon (1st monitor) shows only menu shadow, and not its items

How to fix it (image 2 attached):

  • main window should be moved to the 1st (left) monitor


  • ScopedDPIAwarenessDisabler instance should be removed fromcode

Obviously the main culprit is ScopedDPIAwarenessDisabler . I tried this both with JUCE5 and JUCE6. With JUCE5, there are even some optimization settings in VS project, which partially remedy the issue, but that’s not really a solution.

I can provide the code / VS project, it’s very simple.


Well the PopupMenu is a separate desktop window, so you need to also add a ScopedDPIAwarenessDisabler object when creating it if you want it to ignore DPI scaling. Alternatively you can give the PopupMenu a parent component and it won’t be a desktop window so will use the DPI scaling of the main window.

I need it, because my application scaling must be managed by OS and not by JUCE.

Can I ask why? Using ScopedDPIAwarenessDisabler means that your application window will be bitmap stretched by the OS instead of scaling correctly, so will look horribly blurry on any modern screens which use a scale factor > 100%.

Thx for the answer!

Pop-up menu in my case is displayed on main display, which is not scaled, why should i use ScopedDPIAwarenessDisabler for it? It looks like JUCE is not showing menu properly, when main app window is located on other, scaled display. If main window is on the same display as menu, everything is fine.

Btw. i am not sure how do you set parent window for popup?

My app is hosting VST plugins in very special way, pretty complicated.
GUI of these plugins can not be scaled, at least i didn’t succed to do it. If i use JUCE scaling, only app is scaled propery, not plugins. They are only properly scaled, if i allow OS to do it.

Any hints why plugins are not scaled? Can JUCE somehow automatically stretch VSTGUI editor bitmap on HiDPI display (like OS does) ?

Using ScopedDPIAwarenessDisabler will ensure that the screen bounds calculations are not scaled, which is probably the cause of your issues. With DPI awareness enabled any calls into the Win32 geometry methods will use and return unscaled physical pixel values but if you use the DPI disabler these calls will be virtualised to return logical pixels which is what your main app window is using.

My app is hosting VST plugins in very special way, pretty complicated.

Take a look at the JUCE AudioPluginHost - we use the ScopedDPIAwarenessDisabler for some plug-in windows for compatibility but the rest of the app is DPI-aware.

For each hosted plugin i use TopLevelWindow. But plugins in my app are not floating windows like in AudioPluginHost, they are children, stacked inside DocumentWindow in a rack style, at fixed positions. So they must be linked to parent DocumentWindow.

To keep top level windows linked to single DocumentWindow, i set this document window to be a parent of each top level window (addToDesktop 2nd parameter).

As i understand, this prevents a possibility to have document window scaled by JUCE and plugin windows scaled by OS (using DPI disabler).

Check this page to get an idea of visual appearance.

OK, it looks it’s working … i removed DPI disabler before menu is created/displayed and create it again afterwards.

IMPORTANT: new thing which really confuses me … some VS 2019 C/C++ optimization settings can break menu behaviour (with all JUCE versions and both applications).

VS 2019 community edition JUCE5:

  • full optimization - menu works
  • speed or size optimization - menu doesn’t work?!?

With JUCE6, things are slightly different, but still, some optimization settings can break menu behaviour.

Any idea how optimization modes can be related to the issue. Funny is that other than that, pretty complex program work flawlessly, regardless of VS optimization settings.