This is the hierarchy of widgets I've got:
Frame > wxBoxSizer > wxPanel > wxBoxSizer > wxFlexGridSizer (2 columns, 9 rows), with assorted form fields and buttons inside.
The first BoxSizer is to place the panel in, and the second is to make a border around the FlexGrid.
Everything looks nice, and the frame can expand properly if the window is enlarged, but it also can be resized to almost nothing, hiding all form elements.
How do I force the minimum size for the window to the one suggested by the FlexGridSizer by default (all form elements visible and having their minimal possible sizes)?
Probably much too late but the answers given here are needlessly complicated, you just need to call SetSizerAndFit(sizer)
to both associate the sizer with the frame, set its initial size and also set this size as minimal acceptable size.
Using the SetMinSize() method on your Frame to set a minimum size will set a limit on the smallest area of the frame (just tested it). Once set, wxWidgets will not allow the frame to be sized smaller than the value specified.
I'd set the value like this. In the constructor, set up all the elements of the frame. At the end, after you call the Layout()
method to setup all the sizers and such, call the GetSize(int *w, int *h)
method to get the x and y size of your frame at the default layout. Use those values to call the SetMinSize()
method to set that default size as the minimum for your Frame. This will take into account all the various padding and borders and such set up by the frame and the contained elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With