LineTo (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code draws a line from the upper left corner of a form to the mouse position when the mouse is moved, creating a "rubber band" effect.

Code

procedure TForm1.FormMouseMove(
  Sender: TObject; Shift: TShiftState; X, Y: Integer);
begin
  { First call FillRect to paint the surface of the form.
    This removes any previously drawn lines (and anything else). }
  Canvas.FillRect(ClientRect);
  Canvas.MoveTo(0, 0);
  Canvas.LineTo(X, Y);
end;

Uses

Personal tools
Assistance