Delphi XE6 TForm.AutoSize [英] Delphi XE6 TForm.AutoSize

查看:128
本文介绍了Delphi XE6 TForm.AutoSize的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Delphi XE2中编写了代码,可以很好地工作。但是在Delphi XE6中它不起作用。
我创建一个Tform,其AutoSize属性为true。我使用TPanel将alTop与一个按钮对齐以创建其他面板。

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, ....).

您有任何想法吗?

推荐答案

这确实是行为的改变。我可以复制您的举报。也就是说,您的代码会导致XE2中的表单大小发生更改,而XE6中的表单大小却没有变化。

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.

要解决此问题,您可以手动调用 AdjustSize

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;

这篇关于Delphi XE6 TForm.AutoSize的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆