Using the DRAWPATTERNRECT Escape in Windows

Last reviewed: November 2, 1995
Article ID: Q75380
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.1 and 3.0
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.5 and 3.51
        - Microsoft Windows 95 version 4.0
    

SUMMARY

The DRAWPATTERNRECT escape is implemented by the PCL/HP driver for Hewlett-Packard (HP) LaserJet printers and compatibles. The escape is used to draw a patterned rectangle without using the graphics banding bitmap. Using this escape can enhance the performance for many applications, particularly when a majority of users have LaserJet-compatible printers.

MORE INFORMATION

The HP LaserJet Plus and all later LaserJets implement a command called a rule. A rule is a rectangle filled with some pattern, such as a black rule, a quasi-halftone gray scale, or a hatch pattern.

The output does not go through the graphics banding bitmap (it is actually sent to the printer in the text band). The DRAWPATTERNRECT escape can be used to print line and block graphics in the text band without using graphics banding at all. Because many applications use only horizontal and vertical lines or blocks, this is a significant optimization.

An application should determine support for rules using the QUERYESCSUPPORT escape. In particular, the application should not check for the PCL/HP driver, since other page printer drivers may implement the escape as well.

There are some limitations to the escape. First, rules drawn with DRAWPATTERNRECT are not subject to clipping regions in the Device Context (DC). Second, rules cannot be opaqued; no white pixel in the graphics band will erase a pixel drawn by a rule (the same limitation occurs for PCL text). Once a rule is drawn, it cannot be erased.

If these limitations are acceptable, if all graphics on the page are likely to be horizontal and vertical lines, and if a significant number of users are expected to have LaserJet-type printers (which is the case for most Windows-based applications), the DRAWPATTERNRECT escape should be used.

If for any reason DRAWPATTERNRECT cannot be used, then the application should generally use the PatBlt function. If the device is a plotter, the Rectangle function should be used. In the case of the PatBlt function, if a black rectangle is to be printed, the BLACKNESS raster operator (ROP) should be used to avoid the overhead of selecting and later deselecting a black brush into the printer DC.


Additional reference words: 3.00 3.10 3.50 4.00 95 HPPCL HP-PCL
KBCategory: kbprint
KBSubcategory: GdiPrn


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.