wxWizard closing entire app on finish Topic is solved
wxWizard closing entire app on finish
I am using a wxWizard and when it reaches the end, on finish it closes the entire app instead of just the wxwizard and I don't know why.
Re: wxWizard closing entire app on finish
Show your code for reproducing the behaviour and check the wizard sample.
Also there is wxWizard tutorial
Also there is wxWizard tutorial
Re: wxWizard closing entire app on finish
Is the wizard the only window the app has, if so perhaps, the wxApp considers the wizard its top-level window and exits when it is closed?
Whatever it is, it should be easy to see what is going on with a debugger.
Whatever it is, it should be easy to see what is going on with a debugger.
Re: wxWizard closing entire app on finish
Turns out it was not the wxWizard that was the problem. I was using a Main Menu to create a wxDialog box to determine which wizard to use. When the Dialog was done it was closing everything instead of just the Dialog frame. Using this->Close(); instead of Destroy() seems to solve the problem but then the entire app won't close when using the main menu's EXIT Button.
The Dialog, Wizard and main menu all have their own individual parent frames and should not be linked to each other by parent frames.
Dialog creation from main menu
Character creation wizard created from Dialog
I have tried instead to use
instead but that causes the mentioned problem.
The Dialog, Wizard and main menu all have their own individual parent frames and should not be linked to each other by parent frames.
Dialog creation from main menu
Code: Select all
void MainFrame::OnNewChar(wxCommandEvent&event)
{
wxFrame *CharCreatorSelection =new wxFrame(NULL,-1,"",wxPoint(0,0),g_mainmenusize,wxFULLSCREEN_NOMENUBAR);
CustomDialog *RPGselect = new CustomDialog(CharCreatorSelection,wxT("RPG Selection"),wxSize(g_sizex/2,g_sizey/2));
RPGselect->Show(true);
}
Code: Select all
void CustomDialog::OnDone(wxCommandEvent&event)
{
int RPGdone = RPGradio->GetSelection();
int Chardone = Charradio->GetSelection();
int numdone=numradio->GetSelection();
Destroy();[b][u]//problem[/u][/b]
wxFrame *CharCreator =new wxFrame(NULL,-1,"",wxPoint(0,0),g_mainmenusize,wxFULLSCREEN_NOMENUBAR);
if (RPGdone==0&&Chardone==0){
PWitcher *PWitcherCreator=new PWitcher(CharCreator);
PWitcherCreator->RunWizard(PWitcherCreator->GetFirstPage());
}
}
I have tried instead to use
Code: Select all
Close(TRUE);
this->Close(True);
Last edited by doublemax on Fri Oct 15, 2021 10:19 pm, edited 2 times in total.
Reason: Added code tags
Reason: Added code tags
Re: wxWizard closing entire app on finish
Code: Select all
void MainFrame::OnNewChar(wxCommandEvent&event)
{
wxFrame *CharCreatorSelection =new wxFrame(NULL,-1,"",wxPoint(0,0),g_mainmenusize,wxFULLSCREEN_NOMENUBAR);
CustomDialog *RPGselect = new CustomDialog(CharCreatorSelection,wxT("RPG Selection"),wxSize(g_sizex/2,g_sizey/2));
RPGselect->Show(true);
}
And if CustomDialog derives from wxDialog, it should be created on the stack and shown with ShowModal().
Use the source, Luke!
Re: wxWizard closing entire app on finish
Because the same problem occurred when I originally used the Main menu as the parent window using
this->GetParentForModialDialog()
and attempted to see if using a different window would do anything different.
this->GetParentForModialDialog()
and attempted to see if using a different window would do anything different.
Re: wxWizard closing entire app on finish
First of all, get rid of the dummy-frame creations everywhere.
A modal dialog should be shown with ShowModal(). Inside the dialog, use EndModal() to end it.
I think the general structure should look something like this:
A modal dialog should be shown with ShowModal(). Inside the dialog, use EndModal() to end it.
I think the general structure should look something like this:
Code: Select all
void MainFrame::OnNewChar(wxCommandEvent&event)
{
CustomDialog RPGselect(this, wxT("RPG Selection"),wxSize(g_sizex/2,g_sizey/2));
if(RPGselect.ShowModal() == wxID_OK)
{
PWitcher PWitcherCreator(this);
PWitcherCreator.RunWizard(PWitcherCreator.GetFirstPage());
}
}
Code: Select all
void CustomDialog::OnDone(wxCommandEvent&event)
{
int RPGdone = RPGradio->GetSelection();
int Chardone = Charradio->GetSelection();
int numdone = numradio->GetSelection();
if (RPGdone == 0 && Chardone == 0) {
EndModal(wxID_OK);
} else {
EndModal(wxID_CANCEL);
}
}
Use the source, Luke!
Re: wxWizard closing entire app on finish
Thank you for helping a newbie who somehow missed that EndModal() was a thing.
Finished code based on help
void CustomDialog::OnDone(wxCommandEvent&event)
{
int RPGdone = RPGradio->GetSelection();
int Chardone = Charradio->GetSelection();
int numdone=numradio->GetSelection();
if (RPGdone==0&&Chardone==0){
PWitcher PWitcherCreator(this);
PWitcherCreator.RunWizard(PWitcherCreator.GetFirstPage());
}
EndModal(wxID_OK);
}
void MainFrame::OnNewChar(wxCommandEvent&event)
{
CustomDialog RPGselection(this, wxT("RPG Selection"),wxSize(g_sizex/2,g_sizey/2));
}
Finished code based on help
void CustomDialog::OnDone(wxCommandEvent&event)
{
int RPGdone = RPGradio->GetSelection();
int Chardone = Charradio->GetSelection();
int numdone=numradio->GetSelection();
if (RPGdone==0&&Chardone==0){
PWitcher PWitcherCreator(this);
PWitcherCreator.RunWizard(PWitcherCreator.GetFirstPage());
}
EndModal(wxID_OK);
}
void MainFrame::OnNewChar(wxCommandEvent&event)
{
CustomDialog RPGselection(this, wxT("RPG Selection"),wxSize(g_sizex/2,g_sizey/2));
}