Export (0) Print
Expand All
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.


Windows Mobile 6.5
A version of this page is also available for

This function retrieves the device context (DC) for the entire window, including title bar, menus, and scroll bars.

HDC GetWindowDC( 
  HWND hWnd


Handle to the window with a device context that is to be retrieved.

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

The handle of a device context for the specified window indicates success.

NULL indicates an error or an invalid hWnd parameter.

To get extended error information, call GetLastError.

GetWindowDC is intended for special painting effects within a window's nonclient area. Painting in nonclient areas of any window is not recommended.

The GetSystemMetrics function can be used to retrieve the dimensions of various parts of the nonclient area, such as the title bar, menu, and scroll bars.

The GetDC function can be used to retrieve a device context for the entire screen.

After painting is complete, the ReleaseDC function must be called to release the device context. Not releasing the window device context has serious effects on painting requested by applications.

Librarycoredll.lib, Winmgr.lib
Windows Embedded CEWindows CE 1.0 and later
Windows MobileWindows Mobile Version 5.0 and later

Community Additions

© 2014 Microsoft