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

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
EftelElf
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Nov 16, 2015 7:56 pm

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

Post by EftelElf » Mon Nov 16, 2015 8:01 pm

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

New Pagodi
Super wx Problem Solver
Super wx Problem Solver
Posts: 325
Joined: Tue Jun 20, 2006 6:47 pm
Contact:

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

Post by New Pagodi » Mon Nov 16, 2015 10:56 pm

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.

EftelElf
In need of some credit
In need of some credit
Posts: 2
Joined: Mon Nov 16, 2015 7:56 pm

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

Post by EftelElf » Tue Nov 17, 2015 11:27 am

Yes, I'm absolutely sure

User avatar
tierra
Site Admin
Site Admin
Posts: 1342
Joined: Sun Aug 29, 2004 7:14 pm
Location: Salt Lake City, Utah, USA
Contact:

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

Post by tierra » Tue Nov 17, 2015 2:12 pm

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.

Post Reply