PaintBox
来源:互联网 发布:java.util.jar下载 编辑:程序博客网 时间:2024/05/18 01:38
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls;type TForm1 = class(TForm) PaintBox1: TPaintBox; Panel1: TPanel; Button1: TButton; procedure Button1Click(Sender: TObject); procedure PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1; oldX:integer; oldY:integer; count:integer;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);begin with PaintBox1.Canvas do begin brush.Color:=clWhite; FillRect(rect(0,0,PaintBox1.Width,PaintBox1.Height)); end;end;procedure TForm1.PaintBox1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);var OldBrushColor: TColor; OldpenColor: TColor;begin with PaintBox1.Canvas do begin //if obj.showed then //begin OldBrushColor:=brush.color; OldpenColor:=pen.color; if {obj.Selected} Not (count>0) then begin Pen.Color:=rgb(255,0,0); end; Brush.Color:=$00FF31FF; Ellipse(X-10,Y-10,X+10,Y+10); Pen.Color:=$00FF31FF; if {obj.TypeNo>0}count>0 then begin //moveTo(obj.CenterX,obj.CenterY); //lineTo(GetObj(obj.FNode).CenterX,GetObj(obj.FNode).CenterY); moveTo(oldX,oldY); lineTo(X,Y); end; oldX:=X; oldY:=Y; Inc(count); pen.color:=OldpenColor; brush.color:=OldBrushColor; //end; end;end;procedure TForm1.FormCreate(Sender: TObject);begincount:=0;end;end.