unit Unit2;
interface
uses
Vcl.Controls;
procedure ReAlignChildControls( AParentControl: TWinControl );
implementation
uses
System.Types;
procedure ReAlignChildControls( AParentControl: TWinControl );
var
lIdx : Integer;
lBounds : TRect;
lControl: TControl;
begin
lBounds := AParentControl.ClientRect;
for lIdx := 0
to AParentControl.ControlCount - 1
do
begin
lControl := AParentControl.Controls[ lIdx ];
if not lControl.Visible
then
Continue;
case lControl.Align
of
alTop:
begin
lControl.Top := lBounds.Top;
lBounds.Inflate( 0, -lControl.Height, 0, 0 );
end;
alBottom:
begin
lControl.Top := lBounds.Bottom - lControl.Height;
lBounds.Inflate( 0, 0, 0, -lControl.Height );
end;
alLeft:
begin
lControl.Left := lBounds.Left;
lBounds.Inflate( -lControl.Width, 0, 0, 0 );
end;
alRight:
begin
lControl.Left := lBounds.Right - lControl.Width;
lBounds.Inflate( 0, 0, -lControl.Width, 0 );
end;
end;
end;
end;
end.