给你一个程序玩一下
var
BP, EP: TPoint;
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
BP.X := X;
BP.Y := Y;
EP.X := X;
EP.Y := Y;
Drawing := True;
end;
procedure TForm1.FormMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
with Canvas do
if Drawing then
begin
Pen.Width := 2;
Pen.Color := clRed;
Pen.Mode := pmNOTXOR;
MoveTo(BP.X, BP.Y);
LineTo(EP.X, EP.Y);
MoveTo(BP.X, BP.Y);
LineTo(X, Y);
EP.X := X;
EP.Y := Y;
end;
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Drawing := False;
end;