DevCloseDC

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.

Related Functions

 * DevOpenDC
 * WinOpenWindowDC