OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Printing Window Contents

A simple kind of printout to generate is a copy of a window, because windows do not have multiple pages and window objects already know how to draw themselves on a device context.

Window printout objects

To create a window printout object, construct a window printout object and pass it a title string and a pointer to the window you want printed, like this:

TWindowPrintout printout("Ruler Test", this);

A printout of the Window Itself

Often you want a window to create a printout of itself in response to a menu command. Here is the message response member function that responds to the print command in PRINTING.CPP:

void
TRulerWin::CmFilePrint() // Execute File|Print command
{
if (Printer) {
TWindowPrintout printout("Ruler Test", this);
printout.SetBanding(true);
Printer->Print(this, printout, true);
}
}

This member function calls the printer object's Print member function, which passes a pointer to the parent window and a pointer to the printout object, and specifies whether or not a printer dialog box should be displayed.

TWindowPrintout prints itself by calling your window object's Paint member function (within TWindowPrintout::PrintPage), but with a printer device context instead of a display context.

See Also