DRAWPATTERNRECT Printer Escape function

The DRAWPATTERNRECT printer escape creates a white, gray scale, or solid black rectangle by using the pattern and rule capabilities of Page Control Language (PCL) on Hewlett-Packard LaserJet or LaserJet-compatible printers. A gray scale is a gray pattern that contains a specific mixture of black and white pixels.

To perform this operation, call the ExtEscape function with the following parameters.


int ExtEscape(
  _In_  HDC    hdc,
  _In_  int    nEscape,
  _In_  int    cbInput,
  _In_  LPCSTR lpszInData,
  _In_  int    cbOutput,
  _Out_ LPSTR  lpszOutData


  • hdc [in]
    A handle to the printer device context.

  • nEscape [in]
    The escape function to be performed.

    Value Meaning

    Draws a white, gray-scale, or black rectangle.


  • cbInput [in]
    The number of bytes of data to which the lpszInData parameter points.

    Set this parameter to sizeof ( DRAWPATRECT ).

  • lpszInData [in]
    A pointer to a DRAWPATTERNRECT structure that describes the rectangle.

  • cbOutput [in]
    The number of bytes of data to which the lpszOutData parameter points.

    For this printer escape function, the value of this parameter is 0.

  • lpszOutData [out]
    A pointer to the structure that will receive output from this escape.

    For this printer escape function, the value of the parameter is NULL.

Return value

The return value is greater than zero if the function is successful and less than zero if not. A return value of zero indicates that the function is not supported.


An application should use the QUERYESCSUPPORT escape to determine whether the printer is capable of drawing patterns and rules before using the DRAWPATTERNRECT escape.

Applications that use the DRAWPATTERNRECT escape must observe the following two limitations:

  • Rules drawn with DRAWPATTERNRECT are not subject to clipping regions in the device context.
  • Applications should not try to erase patterns and rules created with DRAWPATTERNRECT by placing opaque objects over them.

If the printer supports white rules, these can be used to erase patterns created by DRAWPATTERNRECT. If the printer does not support white rules, there is no method for erasing these patterns.

If an application cannot use the DRAWPATTERNRECT escape and the device is a printer, it should generally use the PatBlt function instead. Note that if PatBlt is used to print a black rectangle, the application should use the BLACKNESS raster operator. If the device is a plotter, however, the application should use the Rectangle function.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Wingdi.h (include Windows.h)

See also


GDI Printer Escape Functions