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
Super wx Problem Solver
Super wx Problem Solver
Posts: 359
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

show/hide controls in wxScrolledWindow

Post by mael15 » Fri Jul 12, 2019 12:14 pm

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: 13715
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: show/hide controls in wxScrolledWindow

Post by doublemax » Fri Jul 12, 2019 1:09 pm

No idea. Does the layout fix itself when you resize the window manually?
Use the source, Luke!

mael15
Super wx Problem Solver
Super wx Problem Solver
Posts: 359
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: show/hide controls in wxScrolledWindow

Post by mael15 » Fri Jul 12, 2019 1:47 pm

Yes it does! Can I trigger this somehow?

User avatar
doublemax
Moderator
Moderator
Posts: 13715
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: show/hide controls in wxScrolledWindow

Post by doublemax » Fri Jul 12, 2019 1:54 pm

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