Page 1 of 1

show/hide controls in wxScrolledWindow

Posted: Fri Jul 12, 2019 12:14 pm
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?

Re: show/hide controls in wxScrolledWindow

Posted: Fri Jul 12, 2019 1:09 pm
by doublemax
No idea. Does the layout fix itself when you resize the window manually?

Re: show/hide controls in wxScrolledWindow

Posted: Fri Jul 12, 2019 1:47 pm
by mael15
Yes it does! Can I trigger this somehow?

Re: show/hide controls in wxScrolledWindow

Posted: Fri Jul 12, 2019 1:54 pm
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.