新手求助,delphi里Timer 从60开始倒计时,想点击按钮之后重新从60开始倒计时该怎么做。
1个回答
展开全部
var
FTim: Integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
FTim := 60;
Timer1.Interval := 1000;
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Dec(FTim);
Caption := IntToStr(FTim);
if FTim <= 0 then Timer1.Enabled := False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FTim := 60;
Timer1.Enabled := True;
end;
FTim: Integer;
procedure TForm1.FormCreate(Sender: TObject);
begin
FTim := 60;
Timer1.Interval := 1000;
Timer1.Enabled := True;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Dec(FTim);
Caption := IntToStr(FTim);
if FTim <= 0 then Timer1.Enabled := False;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FTim := 60;
Timer1.Enabled := True;
end;
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询