Print Preview

Text Control's PrintPage method can not only be used with printers, but also with any control that has a hDC property. For instance. a Picture Box can be used as a print preview window. This is done by simply assigning its hDC property to Text Control's PrintDevice Property. When calling PrintPage, Text Control will print to the Picture Box instead of to the printer.

This code snippet will print page 1 to a picture box named Picture1. You can use the PrintZoom Property to scale down the printout if the Picture Box is smaller than a full printer page:

[Visual Basic 6]
TXTextControl1.PrintDevice = Picture1.hDC
TXTextControl1.PrintZoom = 25 ' scale down to 25%
TXTextControl1.PrintPage 1

The MDIDemo sample program contains a sophisticated print preview form that works like this. Its source code is contained in the Samples\vb6\MDI folder.