Obtaining a Printer Device Context and Starting a Print Job (Windows CE 5.0)

Windows CE 5.0
Send Feedback

Microsoft® Windows® CE does not send printing commands directly to output devices. Rather, it passes all output information to device drivers, which in turn send the information to display devices and printers. Windows CE has a small footprint in part because it does not need to maintain hard-coded routines for interfacing with multiple output devices.

All device-side rendering is done by the display driver, with the rasterized bands handed to the printer driver for output to the printer device. In effect, the graphics device interface (GDI) stores up all the GDI commands issued after a StartPage call. When the application calls EndPage, GDI works with the display driver to render the commands. To minimize memory usage, application developers should minimize using bitmaps in printed output. When bitmaps are necessary, applications should use StretchBlt to defer bitmap rendering until GDI is rendering the printer band.

Most applications strive for "what you see is what you get" (WYSIWYG) output. Ideally, WYSIWYG means that text drawn with a specified font and size on the screen has a similar appearance when printed. However, it is almost impossible to obtain true WYSIWYG output, partly because of differences between video and printer technologies.

To obtain a WYSIWYG effect when drawing text, call the CreateFontIndirect function and specify the typeface name and logical size of the font you want to draw with and then call the SelectObject function to select the font into a printer device context. Windows CE will select a physical font that is the closest possible match to the specified logical font.

To obtain a printer device context

  1. Call PageSetupDlg (function) to enable the user to select a printer and the output destination and to specify the characteristics of the print job.
  2. Call CreateDC, passing in the name of the printer driver dynamic-link library (DLL) file, the output destination, and a DEVMODE containing the device-specific initialization data.

    DEVMODE is returned by PageSetupDlg.

To start a print job

  1. Call the SetAbortProc function to establish an abort procedure.

    The abort procedure should include a modeless dialog box that enables a user to cancel a print job.

  2. Initialize the necessary variables registered in your AbortProc function.
  3. Display a modeless Cancel dialog box.
  4. Call the StartDoc function to start the print job.

Once you start the print job, you can define individual pages in the document by calling the StartPage and EndPage functions and embedding the appropriate calls to GDI drawing functions within this bracket. After you define the last page, you can close the document and end the print job with the EndDoc function.

Windows CE does not have a print manager. It will not spool or print more than a single copy of a document.

Note   Printing is supported on devices that support TrueType fonts. Printing is not supported on devices using raster fonts.

See Also

Using Virtual-Key Codes | GWES Application Development

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.