Jump to content

GreLockDevice

From EDM2
Revision as of 15:56, 31 December 2019 by Martini (talk | contribs) (Created page with "GreLockDevice locks a device for use by a single thread. This function must be supported by all presentation drivers. GreLockDevice prevents two separate processes from acce...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

GreLockDevice locks a device for use by a single thread.

This function must be supported by all presentation drivers. GreLockDevice prevents two separate processes from accessing the resource (device context) at the same time. Hardcopy drivers need do nothing except return TRUE (Successful).

Simulation support
None. This function is mandatory for all drivers.

Syntax

GreLockDevice(hdc, pInstance, lFunction);

Parameters

hdc (HDC) - input
Device context handle.
pInstance (PVOID) - input
Pointer to instance data.
lFunction (ULONG) - input
High-order WORD=flags; low-order WORD=NGreLockDevice.

Return Code

rc (BOOL) - returns
Return Code.
On completion, the handling routine must return a BOOLEAN value to indicate success or an error.
  • TRUE Successful
  • FALSE Error
Possible Errors Detected: When an error is detected, the handling routine must call WinSetErrorInfo to post the condition. Error codes for conditions that the handling routine is expected to check include:
  • PMERR_DEV_FUNC_NOT_INSTALLED
  • PMERR_INV_HDC
Refer to the "Error Explanations" section in the Presentation Manager Programming Reference for further explanation.

Remarks

This function synchronizes the use and update of the visible region by allowing all current and pending drawings to finish and then blocking any requests to draw from other threads until GreUnlockDevice is called. On exit, the only thread allowed to continue with screen operations is the one that acquires the lock. To prevent deadlock, GreDeath cannot be called while the visible region is locked.

Sample Code


#define INCL_GRE_DEVMISC3
#include <os2.h>

HDC      hdc;        /*  Device context handle. */
PVOID    pInstance;  /*  Pointer to instance data. */
ULONG    lFunction;  /*  High-order WORD=flags; low-order WORD=NGreLockDevice. */
BOOL     rc;         /*  Return Code. */

rc = GreLockDevice(hdc, pInstance, lFunction);