Re:Printing -- good examples of BeginDoc, EndDoc/Abort, exceptions?
In article <kevink-0104991057480...@shs.pr.mcs.net>, Kevin C. Killion
wrote:
Quote
> Printing -- good examples of BeginDoc, EndDoc/Abort, exceptions?
> Hi --
> I would welcome some good examples of how to use these Printer methods,
> and the correct use of exceptions in a BeginDoc/EndDoc print routine.
> THANKS IN ADVANCE for any URLs or code snippets!
What are you trying to print and where are you having problems? At the
simplest level the following code should draw a big X on the paper:
with Printer do
begin
BeginDoc;
Canvas.MoveTo(0,0);
Canvas.LineTo(PageWidth,PageHeight);
Canvas.MoveTo(0,PageHeight);
Canvas.Lineto(PageWidth,0);
EndDoc;
end;
You're just drawing on the printer canvas instead of on the form so most
of the GDI commands (e.g. TextOut) will work. Note that Printer.PageWidth
and PageHeight give you the size of the printable area in pixels. Don't
use absolute numbers of pixels to determine print positions; either work
to proportions of the page or get the printer resolution and turn the
required physical position into the corresponding number of pixels.
I will agree that most books just skim over printing..
Tony Bryer SDA UK