GreLockDevice: Difference between revisions
Appearance
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..." |
mNo edit summary |
||
Line 1: | Line 1: | ||
GreLockDevice locks a device for use by a single thread. | 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). | 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. | ;Simulation support: None. This function is mandatory for all drivers. | ||
==Syntax== | ==Syntax== | ||
GreLockDevice(hdc, pInstance, lFunction) | GreLockDevice(hdc, pInstance, lFunction) | ||
==Parameters== | ==Parameters== | ||
;hdc (HDC) - input | ;hdc (HDC) - input:Device context handle. | ||
:Device context handle. | ;pInstance (PVOID) - input:Pointer to instance data. | ||
;lFunction (ULONG) - input:High-order WORD=flags; low-order WORD=NGreLockDevice. | |||
;pInstance (PVOID) - input | |||
:Pointer to instance data. | |||
;lFunction (ULONG) - input | |||
:High-order WORD=flags; low-order WORD=NGreLockDevice. | |||
==Return Code== | ==Return Code== | ||
;rc (BOOL) - returns | ;rc (BOOL) - returns:Return Code. | ||
:Return Code. | :On completion, the handling routine must return a BOOLEAN value to indicate success or an error. | ||
:*TRUE Successful | |||
:On completion, the handling routine must return a BOOLEAN value to indicate success or an error. | :*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: | |||
:*TRUE Successful | :*PMERR_DEV_FUNC_NOT_INSTALLED | ||
:*FALSE Error | :*PMERR_INV_HDC | ||
:Refer to the "Error Explanations" section in the ''Presentation Manager Programming Reference'' for further explanation. | |||
: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== | ==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. | 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== | ==Sample Code== | ||
<PRE> | <PRE> | ||
#define INCL_GRE_DEVMISC3 | #define INCL_GRE_DEVMISC3 | ||
#include <os2.h> | #include <os2.h> |
Latest revision as of 22:37, 24 March 2020
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);