我没有那本书,但是我觉得是不是描述的代码有问题?下面是帮助的一部分。
When drawing lines, track the point where the line starts with the Origin field.
Origin must be set to the point where the mouse-down event occurs, so the
mouse-up event handler can use Origin to place the beginning of the line, as in
this code:
procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Drawing := True;
Canvas.MoveTo(X, Y);
Origin := Point(X, Y); { record where the line starts }
end;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
Canvas.MoveTo(Origin.X, Origin.Y); { move pen to starting point }
Canvas.LineTo(X, Y);
Drawing := False;
end;