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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| unit UnitGraph;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, Buttons,
StdCtrls, ExtCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Image1: TImage;
PaintBox1: TPaintBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
public
{ public declarations }
Procedure Affich(Sender: TObject); // affichage des graphes
private
{ private declarations }
FGph : TBitmap;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
//******************************************************************************
//************************** Affichage des graphes *************************
//******************************************************************************
procedure TForm1.Affich(Sender: TObject);
Const
ClrFond = Clgreen;
begin
Image1.Visible:=false;
Paintbox1.Align:=AlClient;
FGph.Height:=Paintbox1.Height;
FGph.Width:=Paintbox1.Width;
FGph.Canvas.brush.Color:=ClrFond ;
FGph.Canvas.pen.Color:=ClrFond ; // si la couleur n'est pas celle du fond, un cadre apparaît de la couleur du stylo
FGph.Canvas.rectangle(0, 0, FGph.Width, FGph.Height); // -----> efface la fenêtre
FGph.Canvas.pen.Color:=ClBlack; // si la couleur n'est pas celle du fond, un cadre apparaît de la couleur du stylo
FGph.canvas.moveto(100, 100); // construction des axes des abscisses
FGph.canvas.lineto(150, 150);
Paintbox1.Canvas.Draw(0, 0, FGph); // transfère le dessin dans la Paintbox
Paintbox1.Visible:=true;
end;
//******************************************************************************
//********************* Fin de l'affichage des graphes *********************
//******************************************************************************
procedure TForm1.Button1Click(Sender: TObject);
begin
Affich(Sender);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Paintbox1.Visible:=false;
Image1.Visible:=true;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FGph:=TBitmap.Create;
end;
end. |
Partager