P
paulcross
Unregistered / Unconfirmed
GUEST, unregistred user!
我做画图程序的时候 画折线的时候 怎么在鼠标没按下的时候 线头跟着鼠标走 按下后才确定这点 我用moveto 到前一点后Lineto到鼠标现在的位置 是可以跟着走 可是怎么每下移动都画了一条线阿 出来一堆线 怎么办呢
这是代码部分
var
Form1: TForm1;
a,b:integer;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canvas.Pen.Color:=clred;
//canvas.Pen.Width:=3;
canvas.Brush.Color:=clblack;
canvas.FillRect(Rect(x-3,y+3,x+3,y-3));
a:=x;
b:=y;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canvas.lineto(x,y);
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
canvas.MoveTo(a,b);
canvas.LineTo(x,y);
end;
end.
这是代码部分
var
Form1: TForm1;
a,b:integer;
implementation
{$R *.dfm}
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canvas.Pen.Color:=clred;
//canvas.Pen.Width:=3;
canvas.Brush.Color:=clblack;
canvas.FillRect(Rect(x-3,y+3,x+3,y-3));
a:=x;
b:=y;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
canvas.lineto(x,y);
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
canvas.MoveTo(a,b);
canvas.LineTo(x,y);
end;
end.