hi,
in my app i have a settings dialog. in that dialog, there is a button opening a second dialog. while the second dialog is displayed, the first should be hidden, so i use first->Hide().
the problem is, when i call first->Show() after/while destroying the second dialog, the first is also destroyed.
how can this be?
unfortunately, the wxWidgets dialog sample does not work, so i cannot look for an answer there.
thanx for your thoughts!
problem with show/hide in nested dialogs Topic is solved
-
- wxWorld Domination!
- Posts: 1059
- Joined: Sun Dec 30, 2007 6:40 pm
- Location: Canada
Hi,
If only 1 dialog is visible at a time, consider using only a single dialog window.
Put each set of controls in its own sizer. So you end up with a top sizer for each set of controls, then put each of these into the main sizer for the dialog.
Then use show/hide on the sizers themselves.
e.g. :
When you want to show the second dialog:
Then flip it around when you want to go back to dialog 1.
One advantage is that the controls retain their values if the user switches back to 'dialog' 2 a subsequent time.
Hope that helps,
Jim
If only 1 dialog is visible at a time, consider using only a single dialog window.
Put each set of controls in its own sizer. So you end up with a top sizer for each set of controls, then put each of these into the main sizer for the dialog.
Then use show/hide on the sizers themselves.
e.g. :
Code: Select all
Dialog1Sizer->Add(... all the controls for the first dialog);
Dialog2Sizer->Add(... all the controls for the second dialog);
TopSizer->Add(Dialog1Sizer);
TopSizer->Add(Dialog2Sizer);
// hides all of dialog 2 controls...
TopSizer->Hide(Dialog2Sizer);
this->SetSizer(TopSizer);
// show only the first dialog...
TopSizer->Layout();
Code: Select all
// Hide dialog 1, and show dialog 2
TopSizer->Hide(Dialog1Sizer);
TopSizer->Show(Dialog2Sizer);
TopSizer->Layout();
One advantage is that the controls retain their values if the user switches back to 'dialog' 2 a subsequent time.
Hope that helps,
Jim
OS: Vista SP1, wxWidgets 2.8.7.