Jump to content

DevCloseDC: Difference between revisions

From EDM2
Ak120 (talk | contribs)
m Ak120 moved page OS2 API:PMI:DevCloseDC to DevCloseDC
Ak120 (talk | contribs)
mNo edit summary
Line 2: Line 2:


==Syntax==
==Syntax==
  #define INCL_DEV /* Or use INCL_PM, Also in COMMON section */
  DevCloseDC (hdc)
#include <os2.h>
HDC    hdc;  /*  Device-context handle. */
HMF    hmf;  /*  Error indicator metafile handle (for a metafile device context) */
hmf = DevCloseDC(hdc);


==Parameters==
==Parameters==
;'''hdc''' (HDC) - input:Device-context handle.  
;hdc (HDC) - input:Device-context handle.  
;'''hmf''' (HMF) - returns:Error indicator metafile handle (for a metafile device context)
;hmf (HMF) - returns:Error indicator metafile handle (for a metafile device context)
:DEV_ERROR
:DEV_ERROR - Error occurred
::Error occurred. DEV_OK
:DEV_OK - Device closed, but not a metafile device context.
::Device closed, but not a metafile device context.
:Other Device closed, a metafile device context whose metafile handle is returned.
::Other Device closed, a metafile device context whose metafile handle is returned.


==Errors==
==Errors==
Line 36: Line 29:


==Example Code==
==Example Code==
This example calls DevCloseDC to close a device context based on the handle returned from DevOpenDC.
This example calls DevCloseDC to close a device context based on the handle returned from [[DevOpenDC]].
 
<code>
  #define INCL_DEV                /* Device Function definitions  */
  #define INCL_DEV                /* Device Function definitions  */
  #include <os2.h>
  #include <os2.h>
   
   
  HDC hdc;               /* Device-context handle                */
  HDC hdc;   /* Device-context handle                */
  HMF hmf;               /* error code (or metafile handle if
  HMF hmf;   /* error code (or metafile handle if metafile device context) */
                            metafile device context)             */
   
   
  /* close the device context associated with handle hdc */
  /* close the device context associated with handle hdc */
  hmf = DevCloseDC(hdc);
  hmf = DevCloseDC(hdc);
</code>


==Related Functions==
==Related Functions==

Revision as of 22:53, 25 February 2017

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

Related Functions