DevEscape: Difference between revisions
No edit summary |
|||
Line 152: | Line 152: | ||
*PMERR_ESC_CODE_NOT_SUPPORTED (0x202B) - The code specified with DevEscape is not supported by the target device driver. | *PMERR_ESC_CODE_NOT_SUPPORTED (0x202B) - The code specified with DevEscape is not supported by the target device driver. | ||
*PMERR_INV_ESCAPE_DATA (0x206E) - An invalid data parameter was specified with DevEscape. | *PMERR_INV_ESCAPE_DATA (0x206E) - An invalid data parameter was specified with DevEscape. | ||
==Graphic Elements and Orders== | ==Graphic Elements and Orders== | ||
Line 181: | Line 175: | ||
lResult = DevEscape(hdc, DEVESC_NEWFRAME, 0L, NULL, &plOutCount,pbOutData); | lResult = DevEscape(hdc, DEVESC_NEWFRAME, 0L, NULL, &plOutCount,pbOutData); | ||
</PRE> | </PRE> | ||
==Related Functions== | |||
*Prerequisite Functions: [[DevOpenDC]] | |||
*[[GpiAssociate]] (for DEVESC_STARTDOC) | |||
*[[GpiErase]] (for DEVESC_NEWFRAME) | |||
[[Category:Dev]] | [[Category:Dev]] |
Revision as of 03:14, 25 April 2025
This function allows applications to access facilities of a device not otherwise available through the API. Escapes are, in general, sent to the presentation driver and must be understood by it.
Syntax
DevEscape (hdc, lCode, lInCount, pbInData, plOutCount, pbOutData)
Parameter
- hdc (HDC) - input
- Device-context handle.
- lCode (LONG) - input
- Escape code.
- If the device context is of type OD_QUEUED with a PM_Q_STD spool file, some escapes are sent to the presentation driver and others are recorded in the spool file (depending on the escape code). If the device context is of type OD_METAFILE, all escapes are metafiled. If the device context is of any type other than OD_QUEUED (with a PM_Q_STD spool file) or OD_METAFILE, all escapes are sent to the presentation driver.
- The description for each standard escape specifies which of these categories the escape falls into.
- Devices can define additional escape functions using user lCode values, that have the following ranges:
- 32 768 through 40 959 Not metafiled and not recorded (sent to presentation driver for PM_Q_STD)
- 40 960 through 49 151 Metafiled only (sent to presentation driver for PM_Q_STD)
- 49 152 through 57 343 Metafiled and recorded (not sent to presentation driver) for PM_Q_STD
- 57 344 through 65 535 Recorded only (not sent to presentation driver for PM_Q_STD).
- The following escapes are defined:
- DEVESC_QUERYESCSUPPORT
- DEVESC_GETSCALINGFACTOR
- DEVESC_STARTDOC
- DEVESC_ENDDOC
- DEVESC_ABORTDOC
- DEVESC_NEWFRAME
- DEVESC_RAWDATA
- DEVESC_QUERYVIOCELLSIZES
- DEVESC_SETMODE
- lInCount (LONG) - input
- Input data count.
- Number of bytes of data in the pbInData buffer.
- pbInData (PBYTE) - input
- The input data required for this escape.
- plOutCount (PLONG) - in/out
- Output data count.
- plOutCount is the number of bytes of data in the pbOutData buffer.
- If data is returned in pbOutData, plOutCount is updated to the number of bytes of data returned.
- pbOutData (PBYTE) - output
- Output data.
- pbOutData is a buffer that receives the output from this escape. If plOutCount is null, no data is returned.
Returns
- lResult (LONG) - returns
- Implementation error indicator:
- DEVESC_ERROR Error
- DEVESC_NOTIMPLEMENTED Escape not implemented for specified code
- DEV_OK OK.
Remarks
The data fields for standard escapes are:
DEVESC_QUERYESCSUPPORT | Queries whether a particular escape is implemented by the presentation driver. The return value gives the result.
This escape is not metafiled or recorded. |
|
---|---|---|
DEVESC_GETSCALINGFACTOR | Returns the scaling factors for the x and y axes of a printing device. For each scaling factor, an exponent of two is put in pbOutData. Thus, the value 3 is used if the scaling factor is 8.
Scaling factors are used by devices that cannot support graphics at the same resolution as the device resolution. This escape is not metafiled or recorded. |
|
DEVESC_STARTDOC | Indicates that a new print job is starting. All subsequent output to the device context is spooled under the same job identifier until a DEVESC_ENDDOC occurs.
GpiAssociate must be issued to associate the presentation space with the device context before issuing this escape. This escape is metafiled but not recorded. |
|
DEVESC_ENDDOC | Ends a print job started by DEVESC_STARTDOC.
This escape is metafiled but not recorded. |
|
DEVESC_ABORTDOC | Aborts the current job, erasing everything the application has written to the device since the last DEVESC_STARTDOC, including the DEVESC_STARTDOC.
This escape is metafiled but not recorded. |
|
DEVESC_NEWFRAME | Signals when an application has finished writing to a page and wants to start a new page. It is similar to GpiErase processing for a screen device context, and causes a reset of the attributes. This escape is used with a printer device to advance to a new page.
This escape is metafiled and recorded. |
|
DEVESC_RAWDATA | Allows an application to send data directly to a presentation driver. For example, in the case of a printer driver, this could be a printer data stream.
If DEVESC_RAWDATA is mixed with other data (such as GPI data) being sent to the same page of a device context, the results are unpredictable and depend upon the action taken by the presentation driver. For example, a presentation driver might ignore GPI data if DEVESC_RAWDATA is mixed with it on the same page. In general, DEVESC_RAWDATA should be sent either to a separate page (using the DEVESC_NEWFRAME escape to obtain a new page) or to a separate document (using the DEVESC_STARTDOC and DEVESC_ENDDOC escapes to create a new document). This escape is metafiled and recorded. |
|
DEVESC_QUERYVIOCELLSIZES | Returns the VIO cell sizes supported by the presentation driver.
This escape is not metafiled or recorded. |
and nothing is returned in the buffer pointed to by pbOutData.
VIO cell sizes that can be returned by this escape. The buffer pointed to by pbOutData is updated so that maxcount is the number of VIO cell sizes that can be returned.
sizes that are supported. The buffer pointed to by pbOutData is updated so that:
|
DEVESC_SETMODE | Sets the printer into a particular mode. It is optional for printer drivers to support this escape, but those that do support it need to be aware of the code page of any built-in fonts. For example, if only code page 437 is built in, it is used if 437 is requested by
DEVESC_SETMODE; however, if code page 865 is requested, a suitable code page/font could be downloaded. This escape is metafiled and recorded. |
|
Errors
Possible returns from WinGetLastError
- PMERR_INV_ESC_CODE (0x206D) - An invalid escape code was used in a call to DevEscape.
- PMERR_INV_HDC (0x207C) - An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
- PMERR_INV_LENGTH_OR_COUNT (0x2092) - An invalid length or count parameter was specified.
- PMERR_ESC_CODE_NOT_SUPPORTED (0x202B) - The code specified with DevEscape is not supported by the target device driver.
- PMERR_INV_ESCAPE_DATA (0x206E) - An invalid data parameter was specified with DevEscape.
Graphic Elements and Orders
DevEscape functions generate orders only when metafiling. Order: GEESCP
Example Code
This example uses DevEscape to access facilities of a device that would otherwise be unavailable through the normal Device API set. Here, a new page in a print job is started.
#define INCL_DEV /* Device Function definitions */ #include <os2.h> LONG lResult; /* Error code or not implemented warning code */ HDC hdc; /* Device-context handle */ LONG plOutCount; /* length of output buffer(input), number of bytes returned(output) */ PBYTE pbOutData; /* output buffer */ /* for the NEWFRAME, input and output buffers are not used, so set the buffer lengths to zero(0) and set the buffers to NULL */ plOutCount = 0; pbOutData = NULL; lResult = DevEscape(hdc, DEVESC_NEWFRAME, 0L, NULL, &plOutCount,pbOutData);
Related Functions
- Prerequisite Functions: DevOpenDC
- GpiAssociate (for DEVESC_STARTDOC)
- GpiErase (for DEVESC_NEWFRAME)