GetDC

  HDC GetDC(hwnd)    
  HWND hwnd; /* handle of window */

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.

Parameters

hwnd

Identifies the window whose display context is to be retrieved.

Return Value

The return value identifies the display context for the given window's client area if the function is successful. Otherwise, it is NULL.

Comments

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. The number of display contexts is only limited by available memory.

See Also

ReleaseDC, GetWindowDC