鱼C论坛

 找回密码
 立即注册
查看: 1823|回复: 0

[技术交流] 程序有点长

[复制链接]
发表于 2015-12-24 09:14:09 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

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.
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-11-22 11:11

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表