Jump to content

GreRestoreDC

From EDM2

GreRestoreDC restores the contents of a previously saved device context.

This function is supported by the graphics engine.

Syntax

GreRestoreDC(hdc, idDC, pInstance, lFunction);

Parameters

hdc (HDC) - input
Device context handle.
idDC (LONG) - input
DC state identifier.
Identifies the DC state to be restored. The values with which this parameter may be passed are as follows:
  • A negative value indicates the number of device contexts that must be popped OFF the stack to access the required DC. A -1 indicates that the most recently saved DC must be restored.
  • When this parameter is passed as a positive value (>0) and a corresponding DC does not exist, an error is returned. The current DC is not modified.
  • When passed as a negative value and there are insufficient entries on the stack, an error is raised. The current DC is not modified.
  • When the value passed corresponds to a saved DC, all entries on the stack up to the one indicated are discarded. Any clip regions selected into the discarded DCs are destroyed.
  • A value of 1 resets the DC stack. All entries are removed from the stack.
  • A value of 0 raises an error and the DC is not modified.
pInstance (PVOID) - input
Pointer to instance data.
lFunction (ULONG) - input
High-order WORD=flags; low-order WORD=NGreRestoreDC.

Return Code

fSuccess (BOOL) - returns
Return codes.
On completion, the handling routine must return BOOLEAN (fSuccess).
  • TRUE Successful
  • FALSE Error
Possible Errors Detected: When an error is detected, the graphics engine calls WinSetErrorInfo to post the condition. Reasons for failure of this function include:
  • PMERR_BASE_ERROR
  • PMERR_DEV_FUNC_NOT_INSTALLED
  • PMERR_EXCEEDS_MAX_SEG_LENGTH
  • PMERR_HDC_BUSY
  • PMERR_INSUFFICIENT_MEMORY
  • PMERR_INV_CODEPAGE
  • PMERR_INV_COORDINATE
  • PMERR_INV_DC_TYPE
  • PMERR_INV_HDC
  • PMERR_INV_HRGN
  • PMERR_INV_ID
  • PMERR_INV_IN_AREA
  • PMERR_INV_IN_PATH
  • PMERR_INV_RECT
  • PMERR_INV_REGION_CONTROL
Refer to the "Error Explanations" section of the Presentation Manager Programming Reference for further explanation.

Sample Code

#define INCL_GRE_DCS
#include <os2.h>

HDC      hdc;        /*  Device context handle. */
LONG     idDC;       /*  DC state identifier. */
PVOID    pInstance;  /*  Pointer to instance data. */
ULONG    lFunction;  /*  High-order WORD=flags; low-order WORD=NGreRestoreDC. */
BOOL     fSuccess;   /*  Return codes. */

fSuccess = GreRestoreDC(hdc, idDC, pInstance,
             lFunction);