show/hide controls in wxScrolledWindow

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
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

show/hide controls in wxScrolledWindow

Post by mael15 »

Very weird problem, hard to describe...
the sizer of a wxScrolledWindow contains a LOT of controls that are grouped in their own subsizers. I Hide() and Show() these subsizers according to what controls should be shown.
Now, the bigger of two sizers is only painted as big as the smaller one is. What makes it super weird is that this is only the case every second show/hide iteration, not every time. The scrollbar makes the wxScrolledWindow scroll enough to show all the controls of the bigger subsizer, they just only get painted as big as the smaller subsizer is.

Is there maybe a function to call before Layout that does something like recalculate the size used for painting? maybe the virtual size of the wxScrolledWindow???

EDIT: I am guessing: the controls get painted before the scrollbar size gets updated, so the painting of the controls in the bigger sizer stops when the size of the previously shown smaller sizer is reached?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: show/hide controls in wxScrolledWindow

Post by doublemax »

No idea. Does the layout fix itself when you resize the window manually?
Use the source, Luke!
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: show/hide controls in wxScrolledWindow

Post by mael15 »

Yes it does! Can I trigger this somehow?
User avatar
doublemax
Moderator
Moderator
Posts: 19116
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: show/hide controls in wxScrolledWindow

Post by doublemax »

First check if it's just a redraw issue by moving a window from another application across yours. If that restores the correct layout, try adding an additional Refresh().

If not, try calling wxWindow::SendSizeEvent() or PostSizeEvent() as a last resort.
Use the source, Luke!
Post Reply