【发布时间】:2011-12-17 19:56:12
【问题描述】:
我有一个小问题。我试图在运行时在 Delphi7 中创建一个组件列表,并使用表单的 .OnResize 事件调整它们的大小,但没有用......我不知道该怎么做。
这是我的代码:
procedure TForm1.Button1Click(Sender: TObject);
var
//ExtCtrls
panel: TPanel;
memo: TMemo;
splitter: TSplitter;
list: TListBox;
begin
panel := TPanel.Create(Self);
list := TListBox.Create(Self);
splitter := TSplitter.Create(Self);
memo := TMemo.Create(Self);
with panel do
begin
Parent := Form1;
BevelOuter := bvNone;
Top := 12;
Left := 12;
Height := Form1.Clientheight - 24;
Width := Form1.Clientwidth - 24;
end;
with list do
begin
Parent := panel;
Align := alClient;
Top := 0;
Height := panel.Height;
end;
with splitter do
begin
Parent := panel;
Top := 0;
Width := 12;
Align := alLeft;
end;
with memo do
begin
Parent := panel;
Top := 0;
Left := 0;
Width := round(panel.Width / 4) * 3;
Height := panel.Height;
Align := alLeft;
end;
end;
我是否必须以某种方式注册他们的名字才能在表单的活动中使用它们?或者,创建一个类并包含它们?
非常感谢任何形式的帮助!提前谢谢你。
【问题讨论】: