Page 1 of 1

Show/Hide from parent element doens't completely hide children

Posted: Mon Nov 16, 2015 8:01 pm
by EftelElf
I dunno what I'm doing wrong here

I have a wxWindow as parent of two wxPanel. I switch between those two panels by calling hide and show respectively. When this hide/show thing is called by a mouse event, everything works great. But when I try to do this at runtime, called within another function, the new panel is shown, but the old one doesn't hide. Instead, widgets are strangely mixed , some hide, some not... calling layout or refresh doesn't help... anyone knows how to figure this out? I'd like to switch panels at runtime without the need of a mouse event

Re: Show/Hide from parent element doens't completely hide children

Posted: Mon Nov 16, 2015 10:56 pm
by New Pagodi
Are you sure all the controls in the panels have the panels as their parent? If the main wxWindow is set as the parent for a control, hiding the panel won't hide it.

Incidentally, if you're using 3.0, there's a new control called wxSimplebook which may or may not be helpful here.

Re: Show/Hide from parent element doens't completely hide children

Posted: Tue Nov 17, 2015 11:27 am
by EftelElf
Yes, I'm absolutely sure

Re: Show/Hide from parent element doens't completely hide children

Posted: Tue Nov 17, 2015 2:12 pm
by tierra
If you don't have both panels in a sizer, you should only have *one* panel as a child of any top level window, regardless of whether one is hidden or not. wxWidgets does some magic sizing for a single child window that isn't in a sizer, and you're likely confusing it. I would second the recommendation for wxSimplebook, or simply add your your panels to an appropriate sizer, and maybe even another parent panel that is always shown, and always the only child of your top level window.