Export (0) Print
Expand All
Expand Minimize
This topic has not yet been rated - Rate this topic

GetDCEx (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function retrieves a handle to a display device context (DC) for the client area of a specified window or for the entire screen. You can use the returned handle in subsequent graphics display interface (GDI) functions to draw in the device context.

GetDCEx is an extension to the GetDC function, which gives an application more control over how and whether clipping occurs in the client area.

  HWND hWnd, 
  HRGN hrgnClip, 
  DWORD flags


Handle to the window whose device context is to be retrieved.

If this value is NULL, GetDCEx retrieves the device context for the entire screen.

Specifies a clipping region that may be combined with the visible region of the device context.
Specifies how the device context is created.

This parameter can be a combination of the following values.

DCX_WINDOWReturns a device context corresponding to the window rectangle rather than the client rectangle.
DCX_CACHEReturns a device context from the cache, rather than the OWNDC or CLASSDC window. Essentially overrides CS_OWNDC and CS_CLASSDC.
DCX_PARENTCLIPUses the visible region of the parent window.

The parent's WS_CLIPCHILDREN and CS_PARENTDC style bits are ignored.

The device context origin is set to the upper-left corner of the window identified by hWnd.

DCX_CLIPSIBLINGSExcludes the visible regions of all sibling windows above the window identified by hWnd.
DCX_CLIPCHILDRENExcludes the visible regions of all child windows below the window identified by hWnd.
DCX_NORESETATTRSDoes not reset the attributes of this device context to the default attributes when this device context is released.
DCX_EXCLUDERGNThe clipping region identified by hrgnClip is excluded from the visible region of the returned device context.
DCX_EXCLUDEUPDATEReturns a region that excludes the window's update region.
DCX_INTERSECTRGNThe clipping region identified by hrgnClip is intersected with the visible region of the returned device context.
DCX_INTERSECTUPDATEReturns a region that includes the window's update region.
DCX_VALIDATEWhen specified with DCX_INTERSECTUPDATE, causes the device context to be completely validated.

Using this function with both DCX_INTERSECTUPDATE and DCX_VALIDATE is identical to using the BeginPaint function.

Return Values

The handle of the device context for the specified window indicates success. NULL indicates failure. An invalid value for the hWnd parameter causes the function to fail.

To get extended error information, call GetLastError.



Unlike a DC returned by GetDC, a DC returned by this function is not kept in sync with its associated window.

If the window moves or is resized, unexpected drawing results can occur. The chance of error is reduced if an application gets a DC, draws, and then releases that DC.

Unless the display device context belongs to a window class, the ReleaseDC function must be called to release the device context after painting.

Because only five common device contexts are available at a time, failure to release a device context can prevent other applications from accessing a device context.

The function returns a device context belonging to the window's class if CS_CLASSDC, CS_OWNDC or CS_PARENTDC was specified as a style in the WNDCLASS structure when the class was registered.


OS Versions: Windows CE 2.10 and later.
Header: Winuser.h.
Link Library: Coredll.lib, Winmgr.lib.

See Also

BeginPaint | GetDC | ReleaseDC | WNDCLASS

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.