Search code examples
c++wxwidgets

WxWidgets Show form after first is closed


i'm currently working on a project that involves OGRE for the 3D part and WXWidgets for the user interface. I have followed the hello world tutorial and i'm able to create an application, a window and the message map. The goal is to display at startup a window where you can choose some specific settings like fullscreen, texture quality and some other application specific settings. After you have chosen the settings, the window needs to close and then start the OGRE part with the settings from window.

I have tried to put the code to start the new Window for ogre in the init function:

bool MyApp::OnInit() {
MyFrame *frame = new MyFrame( "Settings", wxPoint(50, 50), wxSize(640, 480) );
frame->Show( true );
start_ogre();
return true;
}

The problem is that both forms are showed at the same time. The Application, Frame and window are in my code split in seperate classes. i also tried to put the code in the main.cpp after the wxwidget code:

wxIMPLEMENT_APP(MyApp);
start_ogre();

This gives the same problem. I tried also in the close event, but that does nothing.

Is there an easy way to make the OGRE form show only when the settings form is closed without shutting down my application or starting both at the same time?


Solution

  • You could use a dialog instead of a frame and show it using ShowModal(). This will block until the user dismisses or closes the dialog. You need to derive your dialog from wxDialog and you need to add some buttons with the appropriate IDs to close or dismiss the dialog. For this you can use the CreateStdDialogButtonSizer(long) method which your dialog inherits from wxDialog.