## Printer Device Driver

[prev][next][parent][TOC]

### Adding New Tests

The function AccessDevice(); provides a generic way of opening a printer DC . As soon as this printer DC is opened, drawing and querying to that printer is possible through Gpi and Dev API calls.

Currently, Font Test uses AccessDevice to print text files and to query forms, fonts, and capabilities by passing in "ACCESS_" flags and executing different sets of code.

For example, AccessDevice() can be called with the flag "ACTION_PRINT_FILE" . Within AccessDevice(), the flag "ACTION_PRINT_FILE" causes the function PrintTextFile() to be called. PrintTextFile() uses Gpi commands to draw to the printer DC.

Additional printing routines and queries within the AccessDevice() code can be added in a similar way. For example, you can add a test that allows the user to print a bit map. The following procedure provides an example of how to add this test.

1.Provide a method for the user to invoke this new function, such as a menu item.

2.Create a new ACTION_ flag, such as ACTION_PRINT_BITMAP, to pass into AccessDevice whenever the new bit-map function is invoked.

3.Write a new function, such as PrintBitmapFile();.

4.Add a check to AccessDevice for the ACTION_PRINT_BITMAP flag that calls the PrintBitmapFile(); function.

5.Within the new function PrintBitmapFile(), make use of GpiWCBitBlt() to draw a bit map to the printer DC.

After creating the new test, you can alter the PaintClientWindow() function to display the same bit map to the user on the screen.

Note: GpiWCBitBlt() is preferred over GpiBitBlt() because GPiWCBitBlt is always metafiled, but only one GpiBitBlt() can be metafiled per document.