Delphi XE6 TForm.AutoSize

I have code in Delphi XE2 that works fine. But in Delphi XE6 it does not work. I am creating a Tform with the AutoSize property set to true. I use TPanel align alTop with a button to create some other panels.

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

The form does not have an automatic size. If I want to see all my panels, I need to move the form (or try resizing, ....).

Do you have any ideas?

+2
source share
2 answers

This is truly a change in behavior. I can reproduce what you are reporting. Namely, that your code causes the form to resize in XE2, but not in XE6.

To get 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;
+3

, :

t.Anchors:=[TAnchorKind.akTop];

XE5 ( XE6)

0

All Articles