A display device context is a device context (DC), created by the system, that an application uses to paint and draw a window. The system prepares each display device context for output to a window, setting the drawing objects, colors, and modes for the window instead of for the display device. When the application supplies the display device context through calls to GDI functions, GDI uses the information in the context to generate output in the given window without intruding on other windows or other parts of the screen.
The system provides five kinds of display device contexts:
Type | Meaning |
---|---|
common | Permits drawing in the client area of a given window. |
class | Permits drawing in the client area of a given window. |
parent | Permits drawing anywhere in the window. Although the parent device context also permits drawing in the parent window, it is not intended to be used in this way. |
private | Permits drawing in the client area of a given window. |
window | Permits drawing anywhere in the window. |
The system supplies a common, class, parent, or private device context to a window based on the type of display device context specified in that window's class style. The system supplies a window device context only when the application explicitly requests one — for example, by calling the GetWindowDC or GetDCEx function. In all cases, an application can use the WindowFromDC function to determine which window a display DC currently represents.