TStatusBar with bottom aligned panel

I have a form c TStatusBarand bottom aligned TPanel, bottom aligned TSplitterand aligned by the client TPanel, as shown in the following screenshot:

Screen Shot 1 - Before - Good

(The separator is colored red to make it more obvious)

Button1 simply increases the height of Panel1 by 20:

Panel1.Height := Panel1.Height + 20;

But when you click on the order of changes in the controls, when Panel1 blows the status bar, and the splitter now resizes the status bar.

Screen Shot 2 - After - Bad

This only happens when the height of Panel1 increases by more than the height of StatusBar1 (19).

I assume that this is due to the presence of two lower aligned controls, but I do not agree with the exact cause of the problem and how to get around it.

I am currently using XE2, but I have the same problem with D2010.

Panel1 , , ?

+5
3

, Top .

StatusBar1.Top := Panel1.Top + Panel1.Height;
+5

( ):

procedure TForm1.Button1Click(Sender: TObject);
begin
  Panel1.SetBounds(Panel1.Left, Panel1.Top - 20,
                   Panel1.Width, Panel1.Height + 20);
end;
+3

Alternatively, if you do not want to track where you change the position / size of the controls,

type
  TForm1 = class(TForm)
    ..
  private
  protected
    procedure AlignControls(AControl: TControl; var Rect: TRect); override;

..

procedure TForm1.AlignControls(AControl: TControl; var Rect: TRect);
begin
  inherited;
  if AControl = Panel1 then
    StatusBar1.Top := Panel1.Top + Panel1.Height;
end;
+2
source

All Articles