HDC GetDC(hWnd)
This function retrieves a handle to a display context for the client area of the given window. The display context can be used in subsequent GDI functions to draw in the client area.
The GetDC function retrieves a common, class, or private display context depending on the class style specified for the given window. 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.
Parameter | Type/Description |
hWnd | HWND Identifies the window whose display context is to be retrieved. |
The return value identifies the display context for the given window's client area if the function is successful. Otherwise, it is NULL.
After painting with a common display context, the ReleaseDC function must be called to release the context. Class and private display contexts do not have to be released. 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.