On Thu, 28 Jan 2021 13:49:34 +0000 Les Newell wrote:
LN> What is the correct way to force a window and all of it's children to
LN> layout as if the window has just been created?
Call wxWindow::Layout() on the top-most window whose layout you want to
change (usually just the top level window, i.e. the parent frame, but it
could be also some panel inside it if you want to limit the re-layout to
this panel only).
LN> I have a window that changes the number and size of controls depending
LN> on user input. I want to force a complete sizer layout to take into
LN> account the new layout. Simply calling GetSizer()->Layout() does not
LN> work.
It's a bit confusing, but wxSizer::Layout() is not quite the same as
wxWindow::Layout(), the latter also updates the size available to the sizer
which is very important if the size of the window has actually changed. If
it didn't change, however, calling Layout() on the window itself and
GetSizer()->Layout() should be equivalent.
LN> I resorted to recursing through all windows and sizers, calling
LN> Layout() on each sizer and InvalidateBestSize() on each window. This
LN> mostly works but in some cases I still end up with the wrong window size.
You definitely don't need to manually recurse through anything, Layout()
already does it (either one). It looks like there could be some other
problem, e.g. maybe you don't delete the old controls before updating the
layout or something like this?
In any case, calling wxWindow::Layout() should always work and if you find
a reproducible case in which it doesn't, please report it as a bug.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/