Control resizing itself

Joost imim at newhouse.nl
Tue Aug 1 03:32:15 PDT 2006


Hi,

I have a control that needs to dynamically resize itself based on its 
contents, so that it is large enough to show its data without scrollbars.

I've implemented DoGetBestSize() to return the optimum size. Initially 
this works fine, upon startup my control is made the right size.

But then something happens which require the control to enlarge itself. 
How should the control notify the sizer hierarchy that its best size has 
changed?

I tried GetContainingSizer()->Layout(), but this does nothing, probably 
because it does not propagate to the parent sizers. And I tried 
Frame->Layout(), but that did nothing either (don't understand shy). And 
the control really should not know anything about the window anyway. 
Only when I resize the window (using the mouse), the control size gets 
updated to the new size.

I figure there should be some event that a control could send to a 
sizer, which propagates upwards through the entire sizer hierarchy and 
causes all sizes to be recalculated. Does such a mechanism exist?

Thanks for any suggestions,
Joost





More information about the wx-users mailing list