马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
本帖最后由 shzbg1341810374 于 2015-12-24 09:16 编辑 unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;
type
TForm1 = class(TForm)
btn1: TButton;
btn2: TButton;
btn3: TButton;
btn4: TButton;
pnl1: TPanel;
lbl1: TLabel;
tmr1: TTimer;
tmr2: TTimer;
procedure btn4Click(Sender: TObject);
procedure btn1Click(Sender: TObject);
procedure btn2Click(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure tmr1Timer(Sender: TObject);
procedure tmr2Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.btn4Click(Sender: TObject);
begin
Close ;
end;
procedure TForm1.btn1Click(Sender: TObject);
var
pre : TDateTime ;
year, month, day : Word;
temp : string ;
begin
tmr1.Enabled := False ;
tmr2.Enabled := False ;
pre := Now;
DecodeDate(pre,year,month,day);
temp := IntToStr(year)+'.'+ IntToStr(month)+'.'+ IntToStr(day);
lbl1.Caption := temp;
end;
procedure TForm1.btn2Click(Sender: TObject);
var
pre: TDateTime ;
hour,min,sec,msec: Word;
temp: string ;
shour,smin,ssec: string ;
begin
tmr1.Enabled := True ;
tmr2.Enabled := False ;
pre := Now ;
DecodeTime(pre,hour,min,sec,msec);
if sec < 10 then
ssec := '0'+ IntToStr(sec)
else
ssec := IntToStr(sec);
if min < 10 then
smin := '0'+ IntToStr(min)
else
smin := IntToStr(min);
if hour < 10 then
shour := '0'+ IntToStr(hour)
else
shour := IntToStr(hour);
temp := shour+':'+ smin+':'+ ssec;
lbl1.Caption := temp;
end;
procedure TForm1.btn3Click(Sender: TObject);
var
temp1,temp2: string ;
pre : TDateTime ;
year,month,day,hour,min,sec,msec : Word;
shour,smin,ssec: string ;
begin
pre := Now;
DecodeDate(pre,year,month,day);
temp1 := IntToStr(year)+'.'+ IntToStr(month)+'.'+ IntToStr(day);
tmr1.Enabled := False ;
tmr2.Enabled := True ;
DecodeTime(pre,hour,min,sec,msec);
if sec < 10 then
ssec := '0'+ IntToStr(sec)
else
ssec := IntToStr(sec);
if min < 10 then
smin := '0'+ IntToStr(min)
else
smin := IntToStr(min);
if hour < 10 then
shour := '0'+ IntToStr(hour)
else
shour := IntToStr(hour);
temp2 := shour+':'+ smin+':'+ ssec;
lbl1.Caption := temp1 +' '+ temp2;
end;
procedure TForm1.tmr1Timer(Sender: TObject);
begin
btn2Click(Sender );
end;
procedure TForm1.tmr2Timer(Sender: TObject);
begin
btn3Click(Sender );
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
tmr1.Enabled := False ;
tmr2.Enabled := False ;
end;
end.
|