Showing modeless dialog from modal dialog

Hi all,

I built a free-standing Windows desktop application with Juce, and it uses a hierarchy of modal dialogs starting at the main application window. This is all working fine. However, I now want to add a modeless dialog to that hierarchy. The main window opens a modal “Item” window when pressing it’s edit button. The item window in turn needs to show a modeless “Preview” window after pressing it’s preview button.

My main app window is derived from DocumentWindow. In it’s constructor I call setVisible(true). One of these is created in a JUCEApplication derived class’s initialize method. All my modal dialogs are ran using LaunchOptions.runModal().

My first guess was to just use LaunchOptions again to start the modeless dialog, but not call runModal() on it but create() and setVisible(true) instead. This however results in the ‘modeless’ dialog to be shown but being blocked for input, while the ‘parent’ modal dialog continues business as usual. It’s also not possible to have the modeless dialog’s z-order equal to the parent modal dialog; once the focus is on the parent dialog again the modeless dialog gets pushed behind it and can’t be put on top again. Apparently Juce doesn’t allow for true window parenting? And I don’t want to use setAlwaysOnTop(), since that’s just an ugly hack here, plus that I also want the user to properly switch between the windows (they’re both quite big so I cannot have one of them permanently overlap the other).

Thinking the modal dialog’s message loop might interfere with the modeless dialog’s one, my second guess was to make the modeless dialog another top-level window in paralel to the main window (so also created and managed by the JUCEApplication). It is hidden from the start but once it needs to be shown I use setVisible(true) on it. This however results in exactly the same outcome…

Thirdly I tried also calling addToDesktop() to the modeless window when constructing it from the main JUCEApplication, hoping that that would make it listen to the main message loop (if Juce even works like that?), but that doesn’t do anything either. Besides: all my child dialogs get a Windows taskbar button anyway, despite not calling addToDesktop() on them, so adding-to-desktop seems to be the defaul here anyway?

So what is the proper way to show a modeless dialog next to a modal dialog?

A side suggestion here: these subdialogs get their own taskbar button, which makes them visible in the Windows alt-tab list. Which in turn means if my hierarchy shows 4 nested modal dialogs the user needs to alt-tab 4x to really get to the next Windows application. Just pressing alt-tab once is the norm on Windows to go to the next app; running on instinct with my app just switches the focus to one of the parent dialogs, which is blocked ofc, so that just shifts the focus back to the dialog the user was at to begin with. All in all not so user friendly.