Registriert seit: 7. Dez 2008
70 Beiträge
|
Uhr besser zentrieren!
23. Jan 2009, 18:15
hallo!!
Wie passt sich meine Uhr besser an die Größe meines Fensters an?
Delphi-Quellcode:
//digtaluhr und mitte bestimmen-------------------------
procedure TForm2.Timer1Timer(Sender: TObject);
var winkel : real;
x, y, r, i : Integer;
hour, min, sec, msec : Word;
begin
decodetime(mytime,hour,min,sec,msec);
r:=((mx+my)div 4);
mx := Width div 2;
my := Height div 2;
refresh;
sekunde;
//Stundenstriche ------------------------------------------
with canvas do begin
pen.Width:=3;
pen.Color:=clblack;
moveto(mx,my-width div 4);
lineto(mx,my-width div 5);
pen.Width:=3;
pen.Color:=clblack;
moveto(mx-width div 4,my);
lineto(mx-width div 5,my);
pen.Width:=3;
pen.Color:=clblack;
moveto(mx+width div 4,my);
lineto(mx+width div 5,my);
pen.Width:=3;
pen.Color:=clblack;
moveto(mx,my+width div 4);
lineto(mx,my+width div 5);
// Sekundenzeiger------------------------------------------
winkel:=sec* ((2*pi) / 60) - pi/2;
x:=Trunc(cos(winkel)*r);
y:=Trunc(sin(winkel)*r);
x:=x+(mx);
y:=y+(my);
Canvas.Pen.Color:=clblack;
Canvas.Pen.Width:=1;
Canvas.MoveTo(mx,my);
Canvas.LineTo(x,y);
end;
end;
end.
Meine Version:
Borland® Delphi® für Microsoft® Windows™ Version 10.0.2288.42451 Update 2 Copyright © 2005 Borland® Software Corporation.
|
|
Zitat
|