Constraining expanded wxPanel 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
mmead
In need of some credit
In need of some credit
Posts: 4
Joined: Tue Jun 08, 2021 7:30 pm

Constraining expanded wxPanel in wxScrolledWindow

Post by mmead »

Hello,

I am looking for recommendations on how to constrain an expanded wxPanel in a wxScrolledWindow. My setup is that I have a parent class derived from a wxScrolledWindow, and it has a wxPanel child that was added with the wxEXPAND flag. When the parent window expands, the child expands with it as expected. However, when I start to shrink the parent window, the child does not resize (it keeps its original size) and the horizontal and vertical scrollbars appear. I understand this is the default behavior.

However, the behavior I would would like is for the child to shrink back to the original width, but for the user to be able to scroll vertically. Are there any recommendations on how to do this?

In the OnSize event handler of my child class, I have printed out the current size and noticed that it remains the full size (after I expand the parent window fully, and the child expands with it).
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Constraining expanded wxPanel in wxScrolledWindow

Post by doublemax »

This is an unusual scenario and i can't think of any easy/elegant solution. I think you need to catch the size event handler of the scrolled window and calculate and set a fitting minimum width for the panel to make it shrink back.
Use the source, Luke!
Post Reply