Intermec 6200 Reference Guide

Page of 410
SECTION 3
Supporting Windows Applications
PEN*KEY
R
 6200/6300 Hand-Held Computer Programmer’s Reference Guide    3-31
Basic Windows Printing
Once Windows has loaded, printing is accomplished through the standard
printing API.  No special processing by the application is needed. The following
sequence demonstrates the correct method for printing under Windows:
1. Create a device context for the printer.  
GetPrinterDC()
 creates the device
context.
2. Set up the device context with the desired fonts, etc.  Keep in mind that
some fonts cause Windows to print completely in graphics mode, which may
provide less performance than desired.  
SelectObject(...)
 sets the
desired font.
3. Set an abort procedure to handle errors during printing and allow the user
to cancel the print job.  
SetABortProc(...)
 sets an abort procedure.
4. Begin the printing operation by calling
 
StartDoc(...)
 to inform GDI that
every output is to be one job.
5. Begin each page of output by calling 
StartPage(...)
 to allow GDI to begin
sending data to the printer on a pageĆbyĆpage basis.
6. Create the page using standard GDI API like 
TextOut(...)
.  The output
operations, that convert text and other objects into a binary data stream,
contain printerĆspecific escape codes.  This data is spooled" until the entire
page is composed.
7. Use 
EndPage(...)
 to finish off a page.  The entire page is then sent to the
printer.  A form feed is generated to move the paper to the top of the next
page.
8. Use 
EndDoc()
 to complete the printing operation.  
AbortDoc()
 can cancel a
job.  GDI cleans things up.
9. Free the instance of your abort procedure using 
FreeProcInstance(...)
.
See the Windows SDK manual for more information about the API used in the
operations previously described.
Default Error-Handling Mode
Once the drivers are loaded as defined previously, no special processing by the
application is needed.  This makes it possible for offĆtheĆshelf packages to take
advantage of the NPCP protocol.  In this mode, all printerĆrelated errors are
handled by the NPCP driver.  A message is displayed and the user can Cancel or
Retry.  If the user selects Retry, the driver attempts to continue printing.  If the
user selects Cancel, the driver attempts to clean up as best it can.  The standard
Windows API returns a standard error, indicating that a problem occurred.  This
is the application's signal to abort the print job.
Application-Defined Error-Handling Mode
This is probably the most common mode of operation.  In this mode, the
application can link to the NPCP driver in the same manner that it would link to
any Windows DLL.  Once linked, the application can use the driver's API to
perform various operations.  The application registers a callback with the driver.
The application needs to perform the following actions to define a new error
handler:
1. Link to driver and obtain PrtService entry point.
2. Call PrtService to enable the driver using PRT_ENABLE (0x0001).
3. Windows
Applications