F
foxweb
Unregistered / Unconfirmed
GUEST, unregistred user!
代码如下
procedure TForm_main.FormCreate(Sender: TObject);
var
i:integer;
button_width:integer;
button_height:integer;
label_width:integer;
label_height:integer;
left_temp:integer;
top_temp:integer;
left_default:integer;
//top_default:integer;
begin
button_width:=60;
button_height:=60;
label_width:=button_width;
label_height:=30;
left_temp:=15;
top_temp:=5;
left_default:=15;
for i:=0 to listname.Count -1 do
begin
button_temp:=tspeedbutton.Create(self);
label_temp:=tlabel.Create(self);
with button_temp do
begin
Parent:=form_main;
Top:=top_temp;
Left:=left_temp;
Width:=button_width;
Height:=button_height;
Flat:=false;
Layout:=blGlyphTop;
Tag:=i;
OnClick:=myClick;
end;
with label_temp do
begin
Parent:=form_main;
AutoSize:=false;
Alignment:=taCenter;
WordWrap:=true;
top:=button_temp.top + button_temp.Height + 2;
left:=button_temp.Left;
width:=label_width;
height:=label_height;
Font.Color:=$00CD5532;
Caption:='abc';
end;
end;
procedure TForm_main.FormClose(Sender: TObject; var Action: TCloseAction);
var i:integer;
begin
for i:=high(label_temp) downto low(label_temp) do
label_temp.free;
for i:=high(button_temp) downto low(button_temp) do
begin
button_temp.free;
end;
end;
//
button_temp和label_temp是在private中声明的
但在关闭的时候label_temp可以释放,但button_temp释放到button_temp[0]时就报错
程序无法退出,请各位dfw帮忙解决
procedure TForm_main.FormCreate(Sender: TObject);
var
i:integer;
button_width:integer;
button_height:integer;
label_width:integer;
label_height:integer;
left_temp:integer;
top_temp:integer;
left_default:integer;
//top_default:integer;
begin
button_width:=60;
button_height:=60;
label_width:=button_width;
label_height:=30;
left_temp:=15;
top_temp:=5;
left_default:=15;
for i:=0 to listname.Count -1 do
begin
button_temp:=tspeedbutton.Create(self);
label_temp:=tlabel.Create(self);
with button_temp do
begin
Parent:=form_main;
Top:=top_temp;
Left:=left_temp;
Width:=button_width;
Height:=button_height;
Flat:=false;
Layout:=blGlyphTop;
Tag:=i;
OnClick:=myClick;
end;
with label_temp do
begin
Parent:=form_main;
AutoSize:=false;
Alignment:=taCenter;
WordWrap:=true;
top:=button_temp.top + button_temp.Height + 2;
left:=button_temp.Left;
width:=label_width;
height:=label_height;
Font.Color:=$00CD5532;
Caption:='abc';
end;
end;
procedure TForm_main.FormClose(Sender: TObject; var Action: TCloseAction);
var i:integer;
begin
for i:=high(label_temp) downto low(label_temp) do
label_temp.free;
for i:=high(button_temp) downto low(button_temp) do
begin
button_temp.free;
end;
end;
//
button_temp和label_temp是在private中声明的
但在关闭的时候label_temp可以释放,但button_temp释放到button_temp[0]时就报错
程序无法退出,请各位dfw帮忙解决