I know the long way to change a panel's z-order to what I want. Enumerate over all controls, calling SendToBack or BringToFront in just the right order. But that's messy, and today I'm chasing elegant (Sunday best and all that) :-)
Is there a simple way of setting the Z-Order of a TPanel so it's directly above another TPanel without mucking around with every other related visible control? (Both Panels have the same parent - oh - it's another Panel, let call it PanelParent :-) )
I've got this far on my own, and yeah, it's working. But my problem is I don't know how to retrieve the current Z-Order of Panel1...
Type
THackPanel = Class(TPanel)
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
THackPanel(PanelParent).SetChildZPosition(Panel2, 0);
//THackPanel(PanelParent).SetChildZPosition(Panel2, Panel1.ZOrder+1); // <-- What I want...
end;
Alternatively, is there just a better way of doing this?