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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
|
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls ;
type
TForm1 = class(TForm)
PaintBox1: TPaintBox;
Panel1: TPanel;
Memo1: TMemo;
procedure PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
procedure PaintBox1Paint(Sender: TObject);
procedure PaintBox1MouseLeave(Sender: TObject);
procedure PaintBox1MouseEnter(Sender: TObject);
private
procedure Clear;
procedure CrossCursor(X, Y: Integer);
procedure Log(S: String);
procedure Dessin;
public
Lx,Ly:integer;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure TForm1.Clear;
Begin
with PaintBox1.canvas do begin
Pen.mode:=pmCopy;
brush.color:=clWhite;
pen.color:=clwhite;
rectangle(0,0,paintbox1.width,paintbox1.height);
end;
End;
Procedure TForm1.CrossCursor(X,Y:Integer);
Begin
with paintbox1.Canvas do begin
pen.Mode:=pmnotxor;
pen.Color:= clblack;
moveto(0,LY);LineTo(paintbox1.width,Ly);
moveto(Lx,0);LineTo(Lx,paintbox1.Height);
moveto(0,Y);LineTo(paintbox1.width,y);
moveto(X,0);LineTo(x,paintbox1.Height);
end;
Lx:=x;
Ly:=Y;
End;
Procedure TForm1.Dessin; //Dessin bidon pour fin de test
Begin
with paintbox1.Canvas do begin
pen.Mode:=pmCopy;
pen.Color:= clblue;
moveto(0,0);LineTo(paintbox1.width,paintbox1.Height);
moveto(paintbox1.width,0);LineTo(0,paintbox1.Height);
end;
End;
Procedure TForm1.Log(S:String);
Begin
Memo1.lines.add(FormatDateTime('HH:NN:SS:ZZZ',now) + ',' + s);
End;
procedure TForm1.PaintBox1MouseEnter(Sender: TObject);
begin
Log('MouseEnter');
CrossCursor(-10,-10);
end;
procedure TForm1.PaintBox1MouseLeave(Sender: TObject);
begin
Log('MouseLeave');
CrossCursor(-10,-10);
end;
procedure TForm1.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X,Y: Integer);
begin
Log('MouseMove');
caption := inttostr(x)+','+inttostr(y);
CrossCursor(x,y);
end;
procedure TForm1.PaintBox1Paint(Sender: TObject);
begin
Log('Paint');
Clear; //Efface l'espace de travial
Dessin; //<-dessin bidon pour fin de test
lx:=-10;ly:=-10;
end;
end. |
Partager