Jump to content

DevCloseDC: Difference between revisions

From EDM2
Ak120 (talk | contribs)
Line 38: Line 38:
Possible returns from WinGetLastError
Possible returns from WinGetLastError


    PMERR_NOT_CREATED_BY_DEVOPENDC (0x20DC)
;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 has been made to destroy a device context using DevCloseDC that was not created using DevOpenDC.
        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)
;PMERR_DC_IS_ASSOCIATED (0x2017)
        An invalid device-context handle or (micro presentation space) presentation-space handle was specified.
: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==
==Remarks==

Revision as of 14:08, 29 September 2016

Syntax

This function closes a device context.

#define INCL_DEV /* Or use INCL_PM, Also in COMMON section */
#include <os2.h>

HDC    hdc;  /*  Device-context handle. */
HMF    hmf;  /*  Error indicator metafile handle (for a metafile device context) */

hmf = 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.

Returns

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);

Related Functions

Prerequisite Functions


Related Functions