Escape

  int Escape(hdc, nEscape, cbInput, lpvInData, lpvOutData)    
  HDC hdc; /* handle of device context */
  int nEscape; /* specifies escape function */
  int cbInput; /* size of structure for input */
  LPCSTR lpvInData; /* address of structure for input */
  LPVOID lpvOutData; /* address of structure for output */

The Escape function allows applications to access capabilities of a particular device that are not directly available through the graphics device interface (GDI). Escape calls made by an application are translated and sent to the driver.

Parameters

hdc

Identifies the device context.

nEscape

Specifies the escape function to be performed. In Win32, this parameter must be one of the predefined escape values. Use the ExtEscape function if your application defines a private escape value.

cbInput

Specifies the number of bytes of data pointed to by the lpvInData parameter.

lpvInData

Points to the input structure required for the specified escape.

lpvOutData

Points to the structure that receives output from this escape. This parameter should be NULL if no data is returned.

Return Value

The return value specifies the outcome of the function. It is greater than zero if the function is successful, except for the QUERYESCSUPPORT printer escape, which checks for implementation only. The return value is zero if the escape is not implemented. A return value less than zero indicates an error.

Errors

If the function fails, the return value is one of the following:

Value Meaning

SP_ERROR General error.
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 User terminated the job through Print Manager.

Comments

Windows version 3.1 introduced 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 ResetDC function is also new for Windows version 3.1. ResetDC updates a device context, allowing such new functionality as changing the paper orientation or paper bin within a single print job. This ability was not supported by an escape in previous versions of Windows.

Following is a complete list of the printer escapes under Windows version 3.0 and how support has changed for Win32:

Escape Description

ABORTDOC Superseded by the AbortDoc function in Win32.
BANDINFO Obsolete in Win32. Because all printer drivers for Windows version 3.1 and later set the text flag in every band, this escape is useful only for older printer drivers.
BEGIN_PATH No changes for Win32. This escape is specific to PostScript printers.
CLIP_TO_PATH No changes for Win32. This escape is specific to PostScript printers.
DEVICEDATA Superseded in Win32. Applications should use the PASSTHROUGH escape to achieve the same functionality.
DRAFTMODE Superseded in Win32. Applications can achieve the same functionality by setting the dmPrintQuality member of the DEVMODE structure to DMRES_DRAFT and passing this structure to the CreateDC function.
DRAWPATTERNRECT No changes for Win32.
ENABLEDUPLEX Superseded in Win32. Applications can achieve the same functionality by setting the dmDuplex member of the DEVMODE structure and passing this structure to the CreateDC function.
ENABLEPAIRKERNING No changes for Win32.
ENABLERELATIVEWIDTHS No changes for Win32.
ENDDOC Superseded by the EndDoc function in Win32.
END_PATH No changes for Win32. This escape is specific to PostScript printers.
ENUMPAPERBINS Superseded in Win32. Applications can use the DeviceCapabilities function to achieve the same functionality.
ENUMPAPERMETRICS Superseded in Win32. Applications can use the DeviceCapabilities function to achieve the same functionality.
EPSPRINTING No changes for Win32. This escape is specific to PostScript printers.
EXT_DEVICE_CAPS Superseded in Win32. Applications can use the GetDeviceCaps function to achieve the same functionality. This escape is specific to PostScript printers.
EXTTEXTOUT Superseded in Win32. Applications can use the ExtTextOut function to achieve the same functionality. This escape is not supported by the version 3.1 PCL driver.
FLUSHOUTPUT Removed for Win32.
GETCOLORTABLE Removed for Win32.
GETEXTENDEDTEXTMETRICS No changes for Win32. Support for this escape may change in future versions of Windows.
GETEXTENTTABLE Superseded in Win32. Applications can use the GetCharWidth function to achieve the same functionality. This escape is not supported by the version 3.1 PCL or PSCRIPT drivers.
GETFACENAME No changes for Win32. This escape is specific to PostScript printers.
GETPAIRKERNTABLE No changes for Win32.
GETPHYSPAGESIZE No changes for Win32. Support for this escape may change in future versions of Windows.
GETPRINTINGOFFSET No changes for Win32. Support for this escape may change in future versions of Windows.
GETSCALINGFACTOR No changes for Win32. Support for this escape may change in future versions of Windows.
GETSETPAPERBINS Superseded in Win32. Applications can achieve the same functionality by calling the DeviceCapabilities function to find the number of paper bins, calling the ExtDeviceMode function to find the current bin, and then setting the dmDefaultSource member of the DEVMODE structure and passing this structure to the CreateDC function.
  GETSETPAPERBINS changes the paper bin only for the current device context. A new device context will use the system-default paper bin until the bin is explicitly changed for that device context.
GETSETPAPERMETRICS Obsolete in Win32. Applications can use the DeviceCapabilities and ExtDeviceMode functions to achieve the same functionality.
GETSETPAPERORIENT Obsolete in Win32. Applications can achieve the same functionality by setting the dmOrientation member of the DEVMODE structure and passing this structure to the CreateDC function. This escape is not supported by the Windows 3.1 PCL driver.
GETSETSCREENPARAMS No changes for Win32.
GETTECHNOLOGY No changes for Win32. Support for this escape may change in future versions of Windows. This escape is not supported by the Windows 3.1 PCL driver.
GETTRACKKERNTABLE No changes for Win32.
GETVECTORBRUSHSIZE No changes for Win32. Support for this escape may change in future versions of Windows.
GETVECTORPENSIZE No changes for Win32. Support for this escape may change in future versions of Windows.
MFCOMMENT No changes for Win32.
NEWFRAME No changes for Win32. Applications should use the StartPage and EndPage functions instead of this escape. Support for this escape may change in future versions of Windows.
NEXTBAND No changes for Win32. Support for this escape may change in future versions of Windows.
PASSTHROUGH No changes for Win32.
QUERYESCAPESUPPORT No changes for Win32.
RESTORE_CTM No changes for Win32. This escape is specific to PostScript printers.
SAVE_CTM No changes for Win32. This escape is specific to PostScript printers.
SELECTPAPERSOURCE Obsolete in Win32. Applications can achieve the same functionality by using the DeviceCapabilities function.
SETABORTPROC Superseded in Win32 by the SetAbortProc function.
SETALLJUSTVALUES No changes for Win32. Support for this escape may change in future versions of Windows. This escape is not supported by the Windows 3.1 PCL driver.
SET_ARC_DIRECTION No changes for Win32. This escape is specific to PostScript printers.
SET_BACKGROUND_COLOR No changes for Win32. Applications should use the SetBkColor function instead of this escape. Support for this escape may change in future versions of Windows.
SET_BOUNDS No changes for Win32. This escape is specific to PostScript printers.
SETCOLORTABLE No changes for Win32. Support for this escape may change in future versions of Windows.
SETCOPYCOUNT Superseded in Win32. An application should call the DeviceCapabilities function, specifying DC_COPIES for the nIndex parameter, to find the maximum number of copies the device can make. Then the application can set the number of copies by passing to the CreateDC function a pointer to the DEVMODE structure.
SETKERNTRACK No changes for Win32.
SETLINECAP No changes for Win32. This escape is specific to PostScript printers.
SETLINEJOIN No changes for Win32. This escape is specific to PostScript printers.
SETMITERLIMIT No changes for Win32. This escape is specific to PostScript printers.
SET_POLY_MODE No changes for Win32. This escape is specific to PostScript printers.
SET_SCREEN_ANGLE No changes for Win32.
SET_SPREAD No changes for Win32.
STARTDOC Superseded in Win32. An application should call the StartDoc function instead of this escape.
TRANSFORM_CTM No changes for Win32. This escape is specific to PostScript printers.