OWLNext 7.0
Borland's Object Windows Library for the modern age
|
Creating a printout object is similar to writing a Paint member function for a window object: you use Windows' graphics functions to generate the image you want on a device context.
Just as the window object's display context takes care of interactions with the screen device, the printout object's device context insulates you from the printer device.
The printout object has fields that hold the size of the page and a device context that is already initialized to render to the printer. The printer object sets those values by calling the printout object's SetPrintParams member function. You should use the printout object's device context in any calls to Windows graphics functions.
Here is the class TWindowPrintout, derived from TPrintout in the sample program PRINTING.CPP:
GetDialogInfo retrieves page-range information from a dialog box if page selection is possible. Since there is only one page, GetDialogInfo for TWindowPrintout looks like this:
PrintPage must be overridden to print the contents of each page, band (if banding is enabled), or window. PrintPage for TWindowPrintout looks like this:
SetBanding is called with banding enabled, as follows:
HasPage is called after every page is printed and by default returns false, which means that only one page will be printed. This function must be overridden to return true while pages remain in multipage documents.