continue create dialog wizard cause unkonwn exception Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
sunose
Earned a small fee
Earned a small fee
Posts: 16
Joined: Tue Jul 07, 2009 2:01 am

continue create dialog wizard cause unkonwn exception

Post by sunose »

Just a dialog wizard follow,one by one ,let user select some option.
but final cause unknown exception.
what cause exception?

thanks.

I am use window xp IDE codeblocks 8.02 and wxwidgets 2.8.10 msw

the code piece as follow:

Code: Select all

void  test()
{
    wxDialog dlg;
    dlg.Create(NULL, wxNewId(), _T("Step 1"),
                 wxDefaultPosition, wxSize(500,300));
   wxPanel* bgpanel=new wxPanel(&dlg, wxID_ANY, wxDefaultPosition, wxSize(dlg.GetSize().GetWidth(),dlg.GetSize().GetHeight()), wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("Step 1"));
    wxButton* ok = new wxButton(bgpanel,wxID_OK,_("ok"),wxPoint(bgpanel->GetSize().GetWidth()/2-50,bgpanel->GetSize().GetHeight()-60));

 dlg.ShowModal();
  dlg.Destroy();

    wxDialog dlg2;
    dlg2.Create(NULL, wxNewId(), _T("Step 2"),
                 wxDefaultPosition, wxSize(500,300));
   wxPanel* bgpane2=new wxPanel(&dlg2, wxID_ANY, wxDefaultPosition, wxSize(dlg2.GetSize().GetWidth(),dlg2.GetSize().GetHeight()), wxTAB_TRAVERSAL|wxWANTS_CHARS, _T("step 1"));
    wxButton* ok2 = new wxButton(bgpane2,wxID_OK,_("ok"),wxPoint(bgpane2->GetSize().GetWidth()/2-50,bgpane2->GetSize().GetHeight()-60));

 dlg2.ShowModal();
dlg2.Destroy();
}
illnatured
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 234
Joined: Mon May 08, 2006 12:31 pm
Location: Krakow, Poland

Post by illnatured »

You shouldn't call Destroy on a dialog that has been created statically, because the destructor is called twice then. Either create your dialogs by 'new' or just don't call Destroy.
VC++ 2005 / Windows XP / wxWidgets 2.8.9
sunose
Earned a small fee
Earned a small fee
Posts: 16
Joined: Tue Jul 07, 2009 2:01 am

Post by sunose »

illnatured wrote:You shouldn't call Destroy on a dialog that has been created statically, because the destructor is called twice then. Either create your dialogs by 'new' or just don't call Destroy.
this work!

thank you illnatured
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

sunose wrote:
illnatured wrote:You shouldn't call Destroy on a dialog that has been created statically, because the destructor is called twice then. Either create your dialogs by 'new' or just don't call Destroy.
this work!

thank you illnatured
Hi,

next time, please accept the post that helped you, and not your own, in order to give credits to the person who helped you

Thanks
"Keyboard not detected. Press F1 to continue"
-- Windows
Post Reply