How to make a Digital clock in delphi7?

前端 未结 3 622
终归单人心
终归单人心 2021-02-14 23:56

I am pretty new to delphi , and would like to start with something easy . Could someone please show me an example how to make a Digital clock that will transfer the \"time\" ( h

3条回答
  •  囚心锁ツ
    2021-02-15 00:07

    Here are my clock's features:

    1. Time's accuracy 100%.
    2. Date is also added.
    3. It is easy to make and doesn't take less than 2 minutes; just create a timer and 2 labels, and write this under implementation:

    procedure TForm1.FormCreate(Sender: TObject);
    begin
      //Background,Clock's Settings
      form1.Caption:='Digital Clock';
      form1.Height:=260;
      form1.Width:=750;
      form1.BorderStyle:=bsToolWindow;
      form1.Color:=clbackground;
    
      //Label (Time,Date) Settings
      label1.Font.Size:=72;
      label1.Font.Color:=clred;
      label1.Caption:='Time';
      label1.Top:=0;
      label1.Left:=8;
    
      label2.Font.Size:=72;
      label2.Font.Color:=clblue;
      label2.Caption:='Date';
      label2.Top:=104;
      label2.Left:=8;
    end;
    
    //Create Clock,Calendar
    procedure TForm1.Timer1Timer(Sender: TObject);
    begin
      label1.Caption:='Time: '+timetostr(time);
      label2.Caption:='Date: '+datetostr(date);
    
      timer1.Interval:=1; //100% Accuracy
    end;
    

    enter image description here

提交回复
热议问题