var
Form1: TForm1;
a:Integer;
po:TPoint;
//定义全局变量
implementation
{$R *.dfm}
procedure TForm1.img1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
a:=1;
po.X:=x;
po.y:=y;
end;
procedure TForm1.img1MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if a=1 then
begin
img1.Canvas.Pen.Color:=clRed;
img1.Canvas.MoveTo(po.X,po.y);
img1.Canvas.LineTo(x,y);
po.X:=x ;
po.y:=y;
end;
end;
procedure TForm1.img1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
a:=0;
end;