HDC GetWindowDC(hwnd) | ||||
HWND hwnd; | /* handle of window, */ |
The GetWindowDC function retrieves a device context for the entire window,
including title bar, menus, and scroll bars. A window device context permits
painting anywhere in the window, because the origin of the context is the upper-left corner of the window instead of the client area.
GetWindowDC assigns default attributes to the device context each time it retrieves the context. Previous attributes are lost.
hwnd
Identifies the window whose device context is to be retrieved.
The return value is the handle of the device context for the given window, if the function is successful. Otherwise, it is NULL, indicating an error or an invalid hwnd parameter.
The GetWindowDC function is intended to be used 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.
After painting is complete, the ReleaseDC function must be called to release the device context. Failure to release a window device context will have serious effects on painting requested by applications.