Delphi Tutorial


 

Transparent Analog clock

 

      

Download this example

         The Update procedure which draws the needles similar to the one we describe in first Analog Clock example.

Here is the procedure to draw the nubers for the circle on a circular path.

procedure TForm1.ClockFrame(Sender: TObject);
Var
     A, R, Xo, Yo, X, Y : Integer;
Begin
     { Set center point }
     Xo:=Width Div 2;
     Yo:=Height Div 2;
     R:=Yo-30;

     { Set font properties }
     Canvas.Font.Style:=[fsBold];
     Canvas.Font.Name:='TimesNewRoman';

     { Set font background color to transparent . . . }
     Canvas.Brush.Style:=bsClear;

     { Display numbers in a circle from 1 to 12 }
     Canvas.Font.Size:=40;
     Canvas.Font.Color:=clBlack;
     For A:=1 to 12 Do
     Begin
          X:=Xo+Round(R*Sin(30*A*Pi/180));
          Y:=Yo-Round(R*Cos(30*A*Pi/180))-20;
          Canvas.TextOut(X,Y,IntToStr(A));
     End;

     Canvas.Font.Size:=35;
     Canvas.Font.Color:=clYellow;
     For A:=1 to 12 Do
     Begin
          X:=Xo+Round(R*Sin(30*A*Pi/180));
          Y:=Yo-Round(R*Cos(30*A*Pi/180))-20;
          Canvas.TextOut(X,Y,IntToStr(A));
     End;
End;

This one make the transparent form at startup.

procedure TForm1.FormCreate(Sender: TObject);
begin
     FirstDraw:=True;

     { Set Form background to transparent }
     Brush.Style:=bsClear;
end;

These procedures use to close the program if any key or mouse button press.

procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
     { Close the program if any key is pressed . . . }
     Close;
end;

procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
     { Close the program if mouse click . . . }
     Close;
end;

DOWNLOAD this example

 

Click here to download this complete example for Delphi 6. (File size 6KB)

Click here to download the compiled program of this example. (File size 193KB)

 

Go top

 


Previous Page First Page Next Page
 
Copyright © 2002 digitalcoding.com. All rights reserved.