Escape  42GH8Y4 

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

   );

 

 

Parameters

hdc

Identifies the device context.

nEscape

Specifies the escape function to be performed. This parameter must be one of the predefined escape values. Use the ExtEscape11KPPE_ 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 Values

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. To get extended error information, call GetLastError11C2VS7.

Errors

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
ERROR_DISK_FULL
ERROR_NOT_ENOUGH_MEMORY
ERROR_PRINT_CANCELLED

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 Windows Print Manager.

 

Remarks

The Win32 API provides six new functions that supersede some printer escapes:

Function

Description

AbortDoc2JKZTWM

Terminates a print job. Supersedes the ABORTDOC escape.

EndDoc1PHX_3Y

Ends a print job. Supersedes the ENDDOC escape.

EndPage6ZJXO8

Ends a page. Supersedes the NEWFRAME escape. Unlike NEWFRAME, this function is always called after printing a page.

SetAbortProcHCN8B4

Sets the abort function for a print job. Supersedes the SETABORTPROC escape.

StartDoc231V06S

Starts a print job. Supersedes the STARTDOC escape.

StartPage1JZ9NP

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 application:

Escape

Description

QUERYYESCSUPPORT

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.

 

See Also

AbortDoc, EndDoc, EndPage, ExtEscape, SetAbortProc, StartDoc, StartPage, ResetDC