Delphi: How to programmatically adjust visual ordering of components with align = alTop

You can easily move a top-aligned panel to the top by setting its Top property to 0. Do this in reverse requested order (bottom panel first) and you are done.


Move them the same way you'd move them at design time with the mouse: Set the current panel's Top property to one less than the Top property of the panel you want to be below the current panel. The VCL will take care of the rest.

If you have to move several panels, start with BeginDeferWindowPos. Adjust all the panels to whatever coordinates you want with DeferWindowPos, and then make them all move at once with EndDeferWindowPos.