Rob,

In the old days of WinAPI programming, I used to draw into a metafile and
draw the metafile on both the printer and screen.  Perhaps this might work
better for you.  In any case, personally, I will not use CopyRect because
the screen and printer resolutions are different and even if it worked you
are likely either to get a postage stamp size copy of your screen, or very
jaggy print out.

The other technique is to make your drawing routines accept a canvas as a
parameter, and you can either pass in a screen canvas or printer canvas -
just need to get your pixels per inch correct.

Regards,
Dennis.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 4 July 2001 12:01
To: Multiple recipients of list delphi
Subject: Re: [DUG]: Printing


Does any one have any suggestions, we are stumped?

Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]
----- Original Message -----
From: Robert Martin
To: Multiple recipients of list delphi
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.

Rob
Software engineer
Wild Software Ltd
[EMAIL PROTECTED]

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to