2
votes

I've code in Delphi XE2 who work perfectly. But in Delphi XE6 it doesn't work. I create a Tform with the property AutoSize to true. I use a TPanel align alTop with a button for create some another panels.

procedure TForm2.Button1Click(Sender: TObject);
var
   t :TPanel;
begin
   t := TPanel.Create(self);
   t.Parent := self;
   t.Align := alTop;
end;

The form doesn't auto size. If I want to see all my panels I have to move the form (or try to resize, ....).

Have you any idea's ?

2
Seems to work ok in XE5. Installing XE6 om my laptop, may take a while ...LU RD
AutoSize -> Adjust form size automatically. alTop -> Adjust panel size automatically. No good using both, one of them should have precedence, which would purely depend on implementation detail.Sertac Akyuz
@SertacAkyuz I'm not so sure – alTop does more than adjust size, it positions controls too.David Heffernan
@David - What it does more does not change the fact that it is resized automatically to fit in its parent.Sertac Akyuz
@SertacAkyuz It seems to me that AutoSize and Align are expected to work together. When you put aligned controls in an auto-sized container, the controls are no longer resized. The controls are positioned, and the container is resized to match the size of the controls. Not that I can find any documentation to that effect.David Heffernan

2 Answers

3
votes

This is indeed a change in behaviour. I can reproduce what you report. Namely that your code results in the form size changing in XE2, but not in XE6.

To work around this you can manually call AdjustSize:

procedure TForm1.Button1Click(Sender: TObject);
var
  Panel: TPanel;
begin
  Panel := TPanel.Create(self);
  Panel.Parent := Self;
  Panel.Top := ClientHeight;
  Panel.Align := alTop;
  AdjustSize;
end;
0
votes

Not align, use anchors:

t.Anchors:=[TAnchorKind.akTop];

This is from my XE5 (have no XE6)