----- Original Message -----
Sent: Tuesday, July 03, 2001 3:02
PM
Subject: [DUG]: Printing
I have a program where I want to draw a number of
Rectangles on a TCanvas, I then want to use CopyRect to copy page sized blocks
of the source canvas to the Printers canvas. This will, I hope, give me
a simple way of outputting multiple pages from my layout
application.
The problem is I get no output at all, the
printer whirrs and stops. I was getting good output by drawing directly
to the printers canvas, and suspect the problem lies with copyrect. I
have setup the following test code and determined that if I load my source
canvas with an image (loadFromFile) the copyrect works fine, If instead I draw
to the canvas of the image copyRect fails. Is their a step I am
missing?
MaxPos := 0;
with Printer do
begin
BeginDoc;
try
Title := 'Image Layout';
//build
Canvas
Image := TImage.Create(Application);
try
//Draw on canvas
SourceRect
:= Rect(0, 0, 10000,
10000);
DestRect
:= Rect(0, 0, 10000, 10000);
Image.Canvas.Rectangle(1,
1, 200 , 200);
Canvas.CopyMode
:=
cmSrcCopy;
Canvas.CopyRect
(DestRect, Image.Canvas, SourceRect);
finally
Image.Free;
end;
finally
EndDoc;
end;
end;
Please excuse the alignement etc of the above
code. Note that if I replace 'Image.Canvas.Rectangle(1, 1, 200 , 200);' with a
loadfromfile an output is acheived. I have viewed the image on screen
and can confirm a rectangle is displayed.
Any help would be greatly
appreciated.