我主要要实现这样一个功能,在mcontrol中设定一个值给test的label,然后起用timer让label中的值减少直到零。代码这样的
在mcontrol中给值
test.Label1.Caption :=listbox2.Items[listbox2.ItemIndex] ;
votetable.Locate('voteTitle',listbox2.Items[listbox2.ItemIndex],[loPartialKey]);
ti:= votetable.fieldbyname('votetimer').asinteger;
edit1.Text := inttostr(ti);
test.label2.Caption:=inttostr(ti) ;
showmessage(test.edit1.Text);
atmeeting.show;
self.hide;
test.show;然后在test中这样
var
test: Ttest;
mtime:integer;implementationuses macctrol;{$R *.dfm}procedure Ttest.Timer1Timer(Sender: TObject);
beginshowmessage(inttostr(mtime));
label2.Caption :=inttostr(mtime) ;
if mtime=0 then
timer1.Enabled :=false;
mtime:=mtime-1;
label2.Repaint ;
end;procedure Ttest.FormCreate(Sender: TObject);
begin
mtime:=strtoint(label2.Caption);
showmessage(label2.Caption );
if mtime>0 then
timer1.Enabled :=true;
end;错是说label2.caption无效
请问这个要怎么改?
在mcontrol中给值
test.Label1.Caption :=listbox2.Items[listbox2.ItemIndex] ;
votetable.Locate('voteTitle',listbox2.Items[listbox2.ItemIndex],[loPartialKey]);
ti:= votetable.fieldbyname('votetimer').asinteger;
edit1.Text := inttostr(ti);
test.label2.Caption:=inttostr(ti) ;
showmessage(test.edit1.Text);
atmeeting.show;
self.hide;
test.show;然后在test中这样
var
test: Ttest;
mtime:integer;implementationuses macctrol;{$R *.dfm}procedure Ttest.Timer1Timer(Sender: TObject);
beginshowmessage(inttostr(mtime));
label2.Caption :=inttostr(mtime) ;
if mtime=0 then
timer1.Enabled :=false;
mtime:=mtime-1;
label2.Repaint ;
end;procedure Ttest.FormCreate(Sender: TObject);
begin
mtime:=strtoint(label2.Caption);
showmessage(label2.Caption );
if mtime>0 then
timer1.Enabled :=true;
end;错是说label2.caption无效
请问这个要怎么改?
begin showmessage(inttostr(mtime));
label2.Caption :=inttostr(mtime) ;
if mtime=0 then//这里有问题
timer1.Enabled :=false;
mtime:=mtime-1;
label2.Repaint ;
end;procedure Ttest.Timer1Timer(Sender: TObject);
var
i : integer;
begin
i:=mtime;
showmessage(inttostr(mtime));
label2.Caption :=inttostr(mtime) ;
if i=0 then
begin
timer1.Enabled :=false;
i:=i-1;
label2.Repaint ;
end;
mtime:=i;
end;
try
temp:=ttest.Create(self) ;
temp.Label1.Caption := listbox3.Items[listbox3.ItemIndex];
temp.Label2.Caption:=inttostr(ti);
temp.mtime :=ti;
temp.ShowModal;
finally
FreeAndNil(temp);
end;但是现在还是传过去的为0奇怪?为什么?