nanoWeenie JUCE+=C++ question(s) if I may


Apologies for the general title of the thread, but I don’t want to pollute the forum with possible multiple questions so all my spam will go here if that’s okay. :slight_smile:

The issue I am having at the moment is attempting to maximise the main window from a button in a component.

The button and listener is in component HeaderPanel and I want to call isFullScreen() and setFullScreen() (class methods from the MainWindow:DocumentWindow class). Should the listener be in the MainWindow class and if so, how do I do that?

Thanks for any help,



Jules, I’m a big Tracktion fan - messing around with JUCE feels like getting to 2nd base with her/it/erm… you! :mrgreen:


If a component is going to need to call a method on the DocumentWindow that contains it, it can either find the DocumentWindow (e.g. with findParentComponentOfClass, or some dynamic_casts of its parent comps) or you can just give the class a pointer to the window when it gets created, or at some other appropriate time.


Thanks for the reply sensei, I’m afraid you overestimate my C++ chops though in terms of translating solid advice into actual syntax. :oops:

Re the pointer solution, it would be smashing if you or someone else not in the middle of a Jucequake could spare a couple of lines of code for a leper. In the class declaration I have MainWindow* mainWindowPointer; - is this right and if so what is the syntax for calling methods using this pointer?

Sorry for the n00bness.


So - instead of MainWindow* mainWindowPointer - try a pointer to a documentWindow, ie … documentWindow* mainWindowPointer; in your MainWindow class.

Then, when the document window is created, and the mainWindow is instantiated, you have something like this :
setContentOwned (MainWindow* myWindow = new MainWindow(), true);

Now - you will need to somehow set the documentWindow Pointer. There are several ways to do this:

directly (not recommended, because the mainWindowPointer should be private):
setContentOwned (MainWindow* myWindow = new MainWindow(), true);

myWindow->mainWindowPointer = this;

or … by including the pointer in the constrcutor:
setContentOwned (MainWindow* myWindow = new MainWindow(this), true);

… and then altering the constructor to set the mainWindowPointer;

MainWindow(DocumentWindow* _myDocWindow)

mainWindowPointer = _myDocWindow;

or, using dynamic_casting … something like this:

mainWindowPointer = dynamic_cast<DocumentWindow*>TopLevelWindow::getTopLevelWindow(0);
jassert(mainWindowPointer != 0); // check and make sure it actually worked ...

Which could be done anywhere in the code … though you need to be careful that it’s actually getting the RIGHT top level window (if you have more than one).


Thanks so much for the detailed reply - the help is appreciated! I am still struggling to get this working (I am using the Modern Dock System by maxprod with a button in the HeaderPanel trying to toggle maximise state if anyone fancies having a peek) but will persevere.

Thanks again.