How do you use ClipRect ?

Posted by Philip Stacey on May 17, 2001

Use of ClipRect

According to Delphi 5 Help, you set ClipRect to the rectangle that defines where you want any lines to be drawn. The ClipRect property is Readonly - how do you do it ?

form1.Image1.Canvas.Rectangle (100, 100, 200, 200);
form1.Image1.Canvas.ClipRect := Rect (100, 100, 200, 200); { Won't compile }
form1.Image1.Canvas.moveto (90, 90);
form1.Image1.Canvas.lineto (210, 210);

Re: Jean Claude Servaye on May 17, 2001

Var
  R : THandle;
begin
  Image1.Canvas.Rectangle (0, 0, 200, 200);
  Image1.Canvas.Rectangle (10, 10, 190, 190);
  R := CreateRectRgn(10,10,190,190);
  R := CreateRectRgn(10+Image1.Left,10+Image1.Top,
    190+Image1.Left,190+Image1.Top);
  Image1.Canvas.moveto (0, 0);
  Image1.Canvas.lineto (200, 200);
end;