L
lliu
Unregistered / Unconfirmed
GUEST, unregistred user!
我定义了几个数组:
var
imagearray:array[1..20] of Timage;
labelarray:array[1..20] of Tlabel;
formarray:array[1..20] of Tform;
timerarray:array[1..20] of Ttimer;
然后在一个buttonclick事件中动态创建form,form中放置
动态创建的imagearray,labelarray,timerarray;
程序段如下:
procedure TForm1.buttonClick(Sender: TObject);
var
string1:string;
begin
str(indeximage,string1);
formarray[indeximage]:=Tform.create(self);
formarray[indeximage].parent:=self;
formarray[indeximage].caption:=string1;
formarray[indeximage].show;
imagearray[indeximage]:=Timage.create(self);
imagearray[indeximage].parent:=formarray[indeximage];
imagearray[indeximage].picture.loadfromfile('d:/picture/comm.bmp');
imagearray[indeximage].left:=imagearray[indeximage].left+indeximage*20;
labelarray[indeximage]:=Tlabel.create(self);
labelarray[indeximage].parent:=formarray[indeximage];
labelarray[indeximage].caption:=string1;
labelarray[indeximage].left:=imagearray[indeximage].left;
labelarray[indeximage].top:=imagearray[indeximage].top+30;
timerarray[indeximage]:=Ttimer.create(self);
timerarray[indeximage].interval:=1000;
timerarray[indeximage].ontimer:=mytime;
timerarray[indeximage].enabled:=true;
indeximage:=indeximage+1;
end;
其中mytime为自定义的一个过程:
procedure Tform1.mytime(sender:Tobject);
begin
imagearray[indeximage].picture.loadfromfile('c:/my documents/cellv0.bmp');
end;
上述程序在到imagearray[indeximage].picture.loadfromfile('c:/my documents/cellv0.bmp');
时出现错误,错误提示:无法访问imagearray[indeximage].picture.loadfromfile();
(注:indeximage是一个全局变量;)
我想请教以下,我如何才能访问动态创建的控件的属性?
谢谢!
var
imagearray:array[1..20] of Timage;
labelarray:array[1..20] of Tlabel;
formarray:array[1..20] of Tform;
timerarray:array[1..20] of Ttimer;
然后在一个buttonclick事件中动态创建form,form中放置
动态创建的imagearray,labelarray,timerarray;
程序段如下:
procedure TForm1.buttonClick(Sender: TObject);
var
string1:string;
begin
str(indeximage,string1);
formarray[indeximage]:=Tform.create(self);
formarray[indeximage].parent:=self;
formarray[indeximage].caption:=string1;
formarray[indeximage].show;
imagearray[indeximage]:=Timage.create(self);
imagearray[indeximage].parent:=formarray[indeximage];
imagearray[indeximage].picture.loadfromfile('d:/picture/comm.bmp');
imagearray[indeximage].left:=imagearray[indeximage].left+indeximage*20;
labelarray[indeximage]:=Tlabel.create(self);
labelarray[indeximage].parent:=formarray[indeximage];
labelarray[indeximage].caption:=string1;
labelarray[indeximage].left:=imagearray[indeximage].left;
labelarray[indeximage].top:=imagearray[indeximage].top+30;
timerarray[indeximage]:=Ttimer.create(self);
timerarray[indeximage].interval:=1000;
timerarray[indeximage].ontimer:=mytime;
timerarray[indeximage].enabled:=true;
indeximage:=indeximage+1;
end;
其中mytime为自定义的一个过程:
procedure Tform1.mytime(sender:Tobject);
begin
imagearray[indeximage].picture.loadfromfile('c:/my documents/cellv0.bmp');
end;
上述程序在到imagearray[indeximage].picture.loadfromfile('c:/my documents/cellv0.bmp');
时出现错误,错误提示:无法访问imagearray[indeximage].picture.loadfromfile();
(注:indeximage是一个全局变量;)
我想请教以下,我如何才能访问动态创建的控件的属性?
谢谢!