CWnd::GetWindowDC

Syntax

CDC* GetWindowDC();

Remarks

Retrieves the display context for the entire window, including caption bar, menus, and scroll bars. A window display context permits painting anywhere in CWnd, since the origin of the context is the upper-left corner of CWnd instead of the client area.

Assigns default attributes to the display context each time it retrieves the context. Previous attributes are lost.

Intended to be used for special painting effects within the CWnd nonclient area. Painting in nonclient areas of any window is not recommended.

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

After painting is complete, the ReleaseDC member function must be called to release the display context. Failure to release the display context will seriously affect painting requested by applications due to limitations on the number of device contexts that can be open at the same time.

Return Value

Identifies the display context for the given window if the function is successful; otherwise, the value is NULL.

The returned pointer may be temporary, and should not be stored for later use.

See Also

::GetSystemMetrics, CWnd::ReleaseDC, ::GetWindowDC, CWnd::GetDC, CWindowDC