The Escape function allows applications to access capabilities of a particular device not directly available through GDI. Escape calls made by an application are translated and sent to the driver.
int Escape(
HDC hdc, // handle to device context
int nEscape, // escape function
int cbInput, // number of bytes in input structure
LPCSTR lpvInData, // pointer to input structure
LPVOID lpvOutData // pointer to output structure
);
If the function succeeds, the return value is greater than zero, except with the QUERYESCSUPPORT printer escape, which checks for implementation only. If the escape is not implemented, the return value is zero.
If the function fails, the return value is an error.
Windows NT: To get extended error information, call GetLastError.
If the function fails, the return value is one of the following values.
Value | Meaning |
---|---|
SP_ERROR | General error. If SP_ERROR is returned, Escape may set the last error code to:
ERROR_INVALID_PARAMETER |
SP_OUTOFDISK | Not enough disk space is currently available for spooling, and no more space will become available. |
SP_OUTOFMEMORY | Not enough memory is available for spooling. |
SP_USERABORT | The user terminated the job through Print Manager. |
The Win32 API provides six new functions that supersede some printer escapes:
Function | Description |
---|---|
AbortDoc | Terminates a print job. Supersedes the ABORTDOC escape. |
EndDoc | Ends a print job. Supersedes the ENDDOC escape. |
EndPage | Ends a page. Supersedes the NEWFRAME escape. Unlike NEWFRAME, this function is always called after printing a page. |
SetAbortProc | Sets the abort function for a print job. Supersedes the SETABORTPROC escape. |
StartDoc | Starts a print job. Supersedes the STARTDOC escape. |
StartPage | Prepares printer driver to receive data. |
The Win32 API provides six new indexes for the GetDeviceCaps function that supersede some printer escapes:
Index | Description |
---|---|
PHYSICALWIDTH | For printing devices: the width of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical width value of 5100 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller. |
PHYSICALHEIGHT | For printing devices: the height of the physical page, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper has a physical height value of 6600 device units. Note that the physical page is almost always greater than the printable area of the page, and never smaller. |
PHYSICALOFFSETX | For printing devices: the distance from the left edge of the physical page to the left edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the leftmost 0.25" of paper, has a horizontal physical offset of 150 device units. |
PHYSICALOFFSETY | For printing devices: the distance from the top edge of the physical page to the top edge of the printable area, in device units. For example, a printer set to print at 600 dpi on 8.5"x11" paper, that cannot print on the topmost 0.5" of paper, has a vertical physical offset of 300 device units. |
Of the original printer escapes, only the following can be used by Win32-based applications:
Escape | Description |
---|---|
QUERYESCSUPPORT | Determines whether a particular escape is implemented by the device driver. |
Following is a list of the obsolete printer escapes that are supported only for compatibility with 16-bit versions of Windows:
Escape | Description |
---|---|
ABORTDOC | Stops the current print job and erases everything the application has written to the device since the last ENDDOC escape. |
ENDDOC | Ends a print job started by the STARTDOC escape. |
GETPHYSPAGESIZE | Retrieves the physical page size and copies it to the specified location. |
GETPRINTINGOFFSET | Retrieves the offset from the upper-left corner of the physical page where the actual printing or drawing begins. |
GETSCALINGFACTOR | Retrieves the scaling factors for the x-axis and the y-axis of a printer. |
NEWFRAME | Informs the printer that the application has finished writing to a page. |
NEXTBAND | Informs the printer that the application has finished writing to a band. |
PASSTHROUGH | Allows the application to send data directly to a printer. |
SETABORTPROC | Sets the Abort function for a print job. |
STARTDOC | Informs a printer driver that a new print job is starting. |
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in wingdi.h.
Import Library: Use gdi32.lib.
Printing and Print Spooler Overview, Printing and Print Spooler Functions, AbortDoc, EndDoc, EndPage, ExtEscape, SetAbortProc, StartDoc, StartPage, ResetDC