How to start the print process

The information stored in CPrintSetup is associated with a document and may even be stored as part of the persistent form of the document. A TPrintParameters object, on the other hand, contains information associated with a particular print request, and is transient, so is set separately.

To start a print request:

  1. Create and set a TPrintParameters object.

  2. Some UI variants may supply a print progress dialog that allows users to start and cancel print jobs and informs them of their progress. Alternatively, use CPrintSetup::StartPrintL().

TPrintParameters params;
// pages 1 to 3
params.iFirstPage = 1;
params.iLastPage = 3;
// one copy
params.iNumCopies = 1;

// Start print
setup->StartPrintL(params, iBodyPrinter, NULL, NULL);

Notes

  • The call to StartPrintL() assumes that iBodyPrinter refers to an implementation of MPageRegionPrinter, which draws to the printer graphics context.

  • Additional parameters can be set for StartPrintL() to set a printer port and an observer.