2个回答
展开全部
将edit1的text初始值设为23:59:59 设为24:00:00会报错的,因为是24小时制
增加一个timer组件,将enabled初始属性设置为false,然后编写ontimer代码如下:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
edit1.Text:=timetostr(strtotime(edit1.Text)-strtotime('00:00:01'));
end;
编写按钮代码如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;
就OK了
增加一个timer组件,将enabled初始属性设置为false,然后编写ontimer代码如下:
procedure TForm1.Timer1Timer(Sender: TObject);
begin
edit1.Text:=timetostr(strtotime(edit1.Text)-strtotime('00:00:01'));
end;
编写按钮代码如下:
procedure TForm1.Button1Click(Sender: TObject);
begin
timer1.Enabled:=true;
end;
就OK了
展开全部
Var
atime: TDateTime;
Procedure TForm1.Timer1Timer(Sender: TObject);
Var
hh, mm, ss, zz: Word;
Begin
Edit1.Text := FormatDateTime('HH:mm:ss', (atime));
atime := (atime - 1 / (24 * 60 * 60) * timer1.Interval / 1000);
DecodeTime(atime, hh, mm, ss, zz);
If (hh = 0) And (mm = 0) And (ss = 0) Then
Begin
Close;
End;
End;
Procedure TForm1.BitBtn1Click(Sender: TObject);
Begin
atime := EncodeTime(23, 59, 59, 997);
Timer1.Enabled := True;
End;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
Timer1.Interval := 1000;
Timer1.Enabled := False;
End;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
//caption := FormatDateTime('c',(Now)); or
caption := FormatDateTime('yyyy-MM-dd HH:mm:ss',(Now));
end;
atime: TDateTime;
Procedure TForm1.Timer1Timer(Sender: TObject);
Var
hh, mm, ss, zz: Word;
Begin
Edit1.Text := FormatDateTime('HH:mm:ss', (atime));
atime := (atime - 1 / (24 * 60 * 60) * timer1.Interval / 1000);
DecodeTime(atime, hh, mm, ss, zz);
If (hh = 0) And (mm = 0) And (ss = 0) Then
Begin
Close;
End;
End;
Procedure TForm1.BitBtn1Click(Sender: TObject);
Begin
atime := EncodeTime(23, 59, 59, 997);
Timer1.Enabled := True;
End;
Procedure TForm1.FormCreate(Sender: TObject);
Begin
Timer1.Interval := 1000;
Timer1.Enabled := False;
End;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
//caption := FormatDateTime('c',(Now)); or
caption := FormatDateTime('yyyy-MM-dd HH:mm:ss',(Now));
end;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询