1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| unit CompteTours;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, ComCtrls, StdCtrls,Math;//,Unit1;
type
TCompteTours = class(TGraphicControl)
private
{ Déclarations privées }
AngleDebut:Integer;
AngleFin:Integer;
ToursMaxi:Integer;
ToursActuel:Integer;
public
constructor Create();
procedure dessineCadran();
procedure dessineAiguille(tours:integer);
end;
implementation
uses Unit1;
var
Bmp, Bmp1: TBitmap;
P:TPaintBox;
const
R = 100; // R = rayon du cadran du compte tours
RR = R * 2;
constructor TCompteTours.Create();
begin
AngleDebut:=240;
AngleFin:=300;
P:=TPaintBox.Create(nil);
P.Parent := Unit1;
P.Top := 0;
P.Left := 0;
P.Width := RR;
P.Height := RR;
//création du bitmap
Bmp := TBitmap.Create;
Bmp.Width := RR;
Bmp.Height := RR;
Bmp.canvas.brush.Color := clBtnFace;
Bmp1 := TBitmap.Create;
Bmp1.Width := RR;
Bmp1.Height := RR;
Bmp1.canvas.brush.Color := clBtnFace;
With Bmp1 do begin
Canvas.Pen.Color := clBlack;
Canvas.brush.Color := clBtnFace;
//Canvas.FillRect(ClientRect);
Canvas.brush.Color := clYellow;
Canvas.Ellipse(0, 0, RR, RR);
end;
P.Canvas.Draw(0,0,Bmp1);
end; |
Partager