Board index » delphi » printing canvas of TPaintBox

printing canvas of TPaintBox

Can anyone help me with trying to print the canvas of a TPaintbox?  I
tried the following, but it won't compile:

with Printer do
begin
  BeginDoc;
  Canvas.draw(0,0,PaintBox1.Canvas);
  EndDoc;
end;

Please email any suggestions.  Thanks.

 

Re:printing canvas of TPaintBox


Wade,

A quick check of the Delphi help file on TCanvas.Draw shows:

procedure Draw(X, Y: Integer; Graphic: TGraphic);
                              ^^^^^^^^^^^^^^^^^

That's your problem... The solution is to use another drawing
method, like CopyRect():

with Printer do
begin
   BeginDoc;
   Canvas.CopyRect( Rect(0, 0, PaintBox1.Width, PaintBox1.Height),
        PaintBox1.Canvas, Rect(0, 0, PaintBox1.Width,
        PaintBox1.Height));
   EndDoc;
end;

HTH

Ken
--
Ken White
kwh...@westelcom.com

Clipper Functions for Delphi
http://members.aol.com/clipfunc/

Quote
Wade Gillingham wrote:

> Can anyone help me with trying to print the canvas of a TPaintbox?  I
> tried the following, but it won't compile:

> with Printer do
> begin
>   BeginDoc;
>   Canvas.draw(0,0,PaintBox1.Canvas);
>   EndDoc;
> end;

> Please email any suggestions.  Thanks.

Other Threads