RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.MoveTo Method

Changes the current drawing position to the point (X,Y).

Pascal
procedure MoveTo(X: Integer; Y: Integer);
C++
__fastcall MoveTo(int X, int Y);

Use MoveTo to set the value of PenPos before calling LineTo. Calling MoveTo is equivalent to setting the PenPos property.  

C++ Examples: 

 

/*
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.
*/
void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y)
{
  /* 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);
}

 

Delphi Examples: 

{
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.
} 
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;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!