Page 1 of 1
problem with show/hide in nested dialogs
Posted: Thu Feb 18, 2010 4:18 pm
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!
Posted: Thu Feb 18, 2010 5:08 pm
It is complex to understand where and when you call "Show" and what happens without the code.
just in case, may be you need wxWizard? It seems suitable for such purposes.
Posted: Thu Feb 18, 2010 5:30 pm
wxWizard is an option, but i only have one more window to show, so it does not seem the best choice.
Posted: Thu Feb 18, 2010 7:01 pm
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.
Code: Select all
Dialog1Sizer->Add(... all the controls for the first dialog);
Dialog2Sizer->Add(... all the controls for the second dialog);
// hides all of dialog 2 controls...
// show only the first dialog...
When you want to show the second dialog:
Code: Select all
// Hide dialog 1, and show dialog 2
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,
Posted: Mon Feb 22, 2010 2:15 pm
works like a charm, thanx!!!
Posted: Mon Feb 22, 2010 5:12 pm
If the topic is solved, please click on "accept" at the top of the post that helped you most to mark the topic as solved and give credits to people who helped you.