Hi Skute! It's not that complecated, you're on the right track and will be done in just a minute :))
Problem is that dialogs normally have their own event loop. This is necessary when using dialogs modal (so the dialog is on top of all the action going on in a frame you created it from). That means that if the frame is closed, the parent of the dialog dies and so the dialog will be destroyed. Since there is no parent when using only a dialog instead of a frame, the dialog is closed and then there's a return to the normal wxApp event loop. So, what you'll have to do is implement an event handler to Destroy the dialog correctly and terminate the wxApp. Do it like this:
In your dialog class derived from wxDialog add a method like OnQuit() and implement it.
bool MainApp::OnInit() { MyDialog *win = new MyDialog("Bla", wxDefaultPosition,wxDefaultSize);
win->Centre(); win->Show(TRUE); SetTopWindow( win );
return true;
}
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
EVT_CLOSE( MyDialog::OnQuit)
END_EVENT_TABLE()
...
...
void MainDialog::OnQuit(wxCommandEvent & WXUNUSED(event))
{
Destroy(); }
...
...
Now if you're closing the dialog, it should destroy the whole app.
upcaseupCASE ----------------------------------- If it was hard to write, it should be hard to read!- Do. Or do not. There is no try! |