Dialog window titlebar problems

Hi, found a couple of problems with DialogWindow:



The dialog window header file shows:


/** If true, the dialog will use a native title bar. See TopLevelWindow::setUsingNativeTitleBar() */

        bool useNativeTitleBar;


However, useNativeTitleBar is hardcoded to be 'false' in showModalDialog, so it's impossible to change.



Non native title bar heights are not applied to dialog windows, only other styling is. 





showModalDialog is only a convenience function, and is mainly there just for legacy code. If you use a LaunchOptions object yourself then you can set whatever flags you like.

Not sure what you mean about the title height - where are you trying to set it?

Thanks Jules - I see launching using LaunchOptions does allow a choice between non-native and native titlebar correctly. 

I'm setting the title bar height and implementing other formatting for my non native titlebar in MyLookAndFeel::drawDocumentWindowTitleBar. All of the formatting (colour, my custom buttons etc) is being correctly applied to the DialogWindow title bar except the height. Strange!

It could be that the look+feel just ignores the title height..

Nope it's definitely not that as the same look and feel is applied to other document windows with the correct title height. 

Interestingly, if I apply a new title height using DialogWindow::SetTitleHeight, and then open the window using DialogWindow::RunModalLoop, then the height is applied to the dialog window correctly - but run modal loop isn't right for this situation though. 

Perhaps we should be able to access the LaunchOptions structure from a DialogWindow object, then the problem could potentially be circumvented.

I think this problem would be fixed by allowing LookAndFeel to be specified in the LaunchOptions.



If your content component needs to find the dialog window that it is

            contained in, a quick trick is to do this:


            Dialogwindow* dw = contentComponent->findParentComponentOfClass<DialogWindow>();



I assume that this is so you can access the correct DialogWindow object to change the LookAndFeel, but it doesn't seem to work. (Also a typo in their by the way; "Dialog(W)indow dw")

I assume that this is so you can access the correct DialogWindow object to change the LookAndFeel, but it doesn't seem to work

Yes, that's the idea - what is it that doesn't work? Looking at the code, calling setLookAndFeel on it should update all the relevant things.


When I try to change the look and feel of the DialogWindow, I hit  'Juce Message Thread (1): EXC_BAD_ACCESS' in Component::setLookAndFeel(LookAndFeel* const newLookAndFeel). I am using the DocumentWindow in showAudioSettingsDialog() by the way.

I've attached the section of code which the error stems from. Thanks for the help:

DialogWindow* dw = getContentComponent()->findParentComponentOfClass<DialogWindow>();

    if (dw != nullptr)

        dw->exitModalState (1234);


    MyLookAndFeel look2;



    DialogWindow::LaunchOptions launchOps;


    launchOps.content->setSize(500, 194);

    launchOps.useNativeTitleBar = false;

    launchOps.resizable = false;

    launchOps.dialogBackgroundColour = Colours::black;


Your pointer nullness checks are pretty dodgy, but the main problem is that you're giving the window a pointer to a LookAndFeel object that will be deleted as soon as your function finishes.

Ok that makes sense. So what I've tried is creating the LookAndFeel object (which is given to the DialogWindow) as a private member variable of the class in which the previous code snippet is from, so that it isn't deleted when the function finishes. This leads to the same error. Sorry if I'm missing something obvious here Jules : /

It looks like I need to use the static version 'setDefaultLookAndFeel'?