这是我以前写的,点1分钟就会倒计时1分钟,10分钟就倒计时10分钟。
附上源码,自己参考修改一下吧。
=============================start==================================
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
STime : TTime;
implementation
{$R *.dfm}
procedure TForm1.Timer1Timer(Sender: TObject);
begin
if STime>=1/86400then
begin
STime:= STime - 1/86400;
Edit1.Text := FormatDateTime('hh:nn:ss',STime);
end else
begin
Edit1.Text:='time up';
Timer1.Enabled:=False;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Timer1.Enabled:=True;
STime := (600*1+1)/86400;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
STime := (60*1+1)/86400;
Timer1.Enabled:=True;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
SetWindowPos(Handle,HWND_TOPMOST,Left,Top,Width,Height,0);
end;
end.
===========================end=================================
2024-09-19 广告
可以注册 www.csdn.net