unit Clock;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls,jpeg, StdCtrls, Buttons, XPMan, Menus;
type
TempTime=record
TempHour,TempMint,TempSecd:Word;
end;
TForm1 = class(TForm)
Image1: TImage;
Timer1: TTimer;
ImageHand: TImage;
PopupMenu1: TPopupMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
procedure FormCreate(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
LastTime:TempTime;
implementation
uses Manager;
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
var
Circle:TShape;
NumOfHour:integer;
begin
LastTime.TempHour:=100;
LastTime.TempMint:=100;
LastTime.TempSecd:=100;
ImageHand.Top:=0;
ImageHand.Left:=0;
ImageHand.Height:=200;
ImageHand.Width:=200;
Image1.Top:=0;
Image1.Left:=0;
Image1.Height:=200;
Image1.Width:=200;
Image1.Picture.LoadFromFile('F:/delphi/时钟/Back.jpg');
For NumOfHour:=0 To 59do
begin
Circle:=TShape.Create(nil);
Circle.Left:=Round(97+Sin(NumOfHour*6*PI/180)*90);
Circle.Top:=Round(99-Cos(NumOfHour*6*PI/180)*90);
Circle.Width:=((NumOfHour+4) mod 5) +2;
Circle.Height:=((NumOfHour+4) mod 5) +2;
Circle.Shape:=stCircle;
Circle.Parent:=Form1;
ImageHand.Canvas.FillRect(Rect(0,0,200,200));
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
NowHour:word;
NowMinu:word;
NowSecd:word;
NowMill:word;
begin
DecodeTime(Now,NowHour,NowMinu,NowSecd,NowMill);
ImageHand.Canvas.Pen.Color:=$ffffff;
if ((LastTime.TempHour<>100) and (LastTime.TempMint<>100) and (LastTime.TempSecd<>100)) then
begin
ImageHand.Canvas.MoveTo(99,97);
ImageHand.Canvas.LineTo(Round(99+Sin( LastTime.TempHour*30*PI/180)*60),Round(97-Cos(LastTime.TempHour*30*PI/180)*60));
ImageHand.Canvas.MoveTo(99,97);
ImageHand.Canvas.LineTo(Round(99+Sin( LastTime.TempMint*6*PI/180)*70),Round(97-Cos( LastTime.TempMint*6*PI/180)*70));
ImageHand.Canvas.MoveTo(99,97);
ImageHand.Canvas.LineTo(Round(99+Sin( LastTime.TempSecd*6*PI/180)*80),Round(97-Cos( LastTime.TempSecd*6*PI/180)*80));
end;
ImageHand.Canvas.Pen.Color:=clBlack;
ImageHand.Canvas.MoveTo(99,97);
ImageHand.Canvas.LineTo(Round(99+Sin( NowHour*30*PI/180)*60),Round(97-Cos( NowHour*30*PI/180)*60));
ImageHand.Canvas.MoveTo(99,97);
ImageHand.Canvas.LineTo(Round(99+Sin( NowMinu*6*PI/180)*70),Round(97-Cos( NowMinu*6*PI/180)*70));
ImageHand.Canvas.MoveTo(99,97);
ImageHand.Canvas.LineTo(Round(99+Sin( NowSecd*6*PI/180)*80),Round(97-Cos( NowSecd*6*PI/180)*80));
LastTime.TempHour:=NowHour;
LastTime.TempMint:=NowMinu;
LastTime.TempSecd:=NowSecd;
end;
end.
以上是源代码……