DevCloseDC: Difference between revisions
Appearance
mNo edit summary |
|||
Line 13: | Line 13: | ||
==Errors== | ==Errors== | ||
Possible returns from [[WinGetLastError]]: | Possible returns from [[WinGetLastError]]: | ||
;PMERR_NOT_CREATED_BY_DEVOPENDC (0x20DC):An attempt has been made to destroy a device context using DevCloseDC that was not created using DevOpenDC. | ;PMERR_NOT_CREATED_BY_DEVOPENDC (0x20DC):An attempt has been made to destroy a device context using DevCloseDC that was not created using [[DevOpenDC]]. | ||
;PMERR_DC_IS_ASSOCIATED (0x2017):An attempt was made to associate a presentation space with a device context that was already associated or to destroy a device context that was associated. | ;PMERR_DC_IS_ASSOCIATED (0x2017):An attempt was made to associate a presentation space with a device context that was already associated or to destroy a device context that was associated. | ||
;PMERR_INV_HDC (0x207C):An invalid device-context handle or (micro presentation space) presentation-space handle was specified. | ;PMERR_INV_HDC (0x207C):An invalid device-context handle or (micro presentation space) presentation-space handle was specified. | ||
==Remarks== | ==Remarks== | ||
If the device context is currently associated with a presentation space, or if it is created with the WinOpenWindowDC call (that is, it is a screen device context), an error is raised, and the device context is not closed. | If the device context is currently associated with a presentation space, or if it is created with the [[WinOpenWindowDC]] call (that is, it is a screen device context), an error is raised, and the device context is not closed. | ||
If the device context being closed is a memory device context that has a bit map currently selected into it (see [[GpiSetBitmap]] in the ''Presentation Manager Programming Reference'') the bit map is automatically deselected before the device context is closed. | If the device context being closed is a memory device context that has a bit map currently selected into it (see [[GpiSetBitmap]] in the ''Presentation Manager Programming Reference'') the bit map is automatically deselected before the device context is closed. | ||
Line 39: | Line 39: | ||
==Prerequisite Functions== | ==Prerequisite Functions== | ||
*[[DevOpenDC]] | *[[DevOpenDC]] | ||
[[Category:Dev]] | [[Category:Dev]] |
Revision as of 15:23, 3 April 2025
This function closes a device context.
Syntax
DevCloseDC (hdc)
Parameters
- hdc (HDC) - input
- Device-context handle.
- hmf (HMF) - returns
- Error indicator metafile handle (for a metafile device context)
- DEV_ERROR - Error occurred
- DEV_OK - Device closed, but not a metafile device context.
- Other Device closed, a metafile device context whose metafile handle is returned.
Errors
Possible returns from WinGetLastError:
- PMERR_NOT_CREATED_BY_DEVOPENDC (0x20DC)
- An attempt has been made to destroy a device context using DevCloseDC that was not created using DevOpenDC.
- PMERR_DC_IS_ASSOCIATED (0x2017)
- An attempt was made to associate a presentation space with a device context that was already associated or to destroy a device context that was associated.
- PMERR_INV_HDC (0x207C)
- An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
Remarks
If the device context is currently associated with a presentation space, or if it is created with the WinOpenWindowDC call (that is, it is a screen device context), an error is raised, and the device context is not closed.
If the device context being closed is a memory device context that has a bit map currently selected into it (see GpiSetBitmap in the Presentation Manager Programming Reference) the bit map is automatically deselected before the device context is closed.
Any clip region currently in use for this device context is deleted.
Example Code
This example calls DevCloseDC to close a device context based on the handle returned from DevOpenDC.
#define INCL_DEV /* Device Function definitions */
#include <os2.h>
HDC hdc; /* Device-context handle */
HMF hmf; /* error code (or metafile handle if metafile device context) */
/* close the device context associated with handle hdc */
hmf = DevCloseDC(hdc);