I have created a Dialog project with the help of wizard and without modifying it, the default code in
wxDialogDefaultApp.cpp is
bool wxDialogDefaultApp::OnInit()
{
//(*AppInitialize
bool wxsOK = true;
wxInitAllImageHandlers();
if ( wxsOK )
{
wxDialogDefaultDialog Dlg(0);
SetTopWindow(&Dlg);
Dlg.ShowModal();
wxsOK = false;
}
//*)
return wxsOK;
}
This kind of code compiles fine, but when you press the close button on the program, it returns
status -1. I asked help from Freenode's wxWidgets' channel and the guys helped me immediately (thanks
DavidGH and
BrianHV). I checked my code with Call Stack and for some reason the program seems that it just closes and it's not getting destroyed.
All I did was to replace my previous original code with this in
wxDialogDefaultApp.cppbool wxDialogDefaultApp::OnInit()
{
bool wxsOK = true;
wxInitAllImageHandlers();
if (wxsOK)
{
wxDialogDefaultDialog * Dlg = new wxDialogDefaultDialog(NULL);
SetTopWindow(Dlg);
Dlg->Show(true);
}
return wxsOK;
}
and in
wxDialogDefaultMain.cpp I changed the
Close() to
Destroy().
void wxDialogDefaultDialog::OnQuit(wxCommandEvent& event)
{
Destroy();
}
Successfully compiled, and tested; it closes with status 0.
Can someone test the original code on other systems and provide feedback? Even though I have mentioned that is under wxMSW, it would not harm anyone by testing it on other environments as well.
My specs are:
Windows XP Professional SP3 (x86)
TDM's GCC 4.5.0
Code::Blocks svn-6386
P.S.: Can we add the syntax highlighter mod so we can make our sample code(s) here more attractive for the eye?