⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 u1.pas

📁 简单的动态时钟界面
💻 PAS
字号:
unit U1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Shape1: TShape;
    Shape2: TShape;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    procedure FormPaint(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure FormKeyPress(Sender: TObject; var Key: Char);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  const pi=3.14159;

implementation

{$R *.dfm}

procedure TForm1.FormPaint(Sender: TObject);
var
  x1,y1:integer;
  a:real;
  datetime,hour,minute,second:Tdatetime;
begin
  datetime:=time;
  form1.Caption:=timetostr(datetime);
  hour:=datetime;
  if hour>=0.5 then
    hour:=hour-0.5;
  a:=hour*pi*4;
  x1:=round(sin(a)*60+268);
  y1:=round(148-cos(a)*60);
  canvas.pen.color:=clblack;
  canvas.Pen.Width:=2;
  with canvas do
  begin
    moveto(268,148);
    lineto(x1,y1);
  end;
  minute:=frac(datetime*24);
  a:=minute*2*pi;
  x1:=round(sin(a)*65+268);
  y1:=round(148-cos(a)*65);
  canvas.Pen.Color:=clblack;
  canvas.Pen.Width:=1;
  with canvas do
  begin
    moveto(268,148);
    lineto(x1,y1);
  end;
  second:=frac(datetime*24*60);
  a:=second*2*pi;
  x1:=round(sin(a)*80+268);
  y1:=round(148-cos(a)*80);
  canvas.Pen.Color:=clblack;
  canvas.Pen.Width:=1;
  with canvas do
  begin
    moveto(268,148);
    lineto(x1,y1);
  end;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
var
  x1,y1:integer;
  a:real;
  datetime,hour,minute,second:TDatetime;
begin
  refresh;
  datetime:=time;
  form1.Caption:=timetostr(datetime);
  hour:=datetime;
  if hour>=0.5 then
    hour:=hour-0.5;
  a:=hour*pi*4;
  x1:=round(sin(a)*60+268);
  y1:=round(148-cos(a)*60);
  canvas.pen.color:=clblack;
  canvas.Pen.Width:=2;
  with canvas do
  begin
    moveto(268,148);
    lineto(x1,y1);
  end;
  minute:=frac(datetime*24);
  a:=minute*2*pi;
  x1:=round(sin(a)*65+268);
  y1:=round(148-cos(a)*65);
  canvas.Pen.Color:=clblack;
  canvas.Pen.Width:=1;
  with canvas do
  begin
    moveto(268,148);
    lineto(x1,y1);
  end;
  second:=frac(datetime*24*60);
  a:=second*2*pi;
  x1:=round(sin(a)*80+268);
  y1:=round(148-cos(a)*80);
  canvas.Pen.Color:=clblack;
  canvas.Pen.Width:=1;
  with canvas do
  begin
    moveto(268,148);
    lineto(x1,y1);
  end;
end;

procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
begin
  form1.Close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -