CWnd::GetDC

Syntax

CDC* GetDC();

Remarks

Retrieves a pointer to a display context for the client area. The display context can be used in subsequent GDI functions to draw in the client area.

Retrieves a common, class, or private display context depending on the class style specified for the CWnd. For common display contexts, GetDC assigns default attributes to the context each time it is retrieved. For class and private contexts, GetDC leaves the previously assigned attributes unchanged.

Unless the display context belongs to a window class, the ReleaseDC member function must be called to release the context after painting. Since only five common display contexts are available at any given time, failure to release a display context can prevent other applications from accessing a display context.

A display context belonging to the CWnd class is returned by the GetDC member function if CS_CLASSDC, CS_OWNDC, or CS_PARENTDC were specified as a style in the WNDCLASS structure when the class was registered.

Return Value

Identifies the display context for the CWnd client area if the function is successful. The return value is NULL if the function is unsuccessful. The pointer may be temporary, and should not be stored for later use.

See Also

CWnd::ReleaseDC, ::GetDC, CClientDC