Display Devices

Before painting, the system must prepare the display device for drawing operations. A display device context defines a set of graphic objects and their associated attributes, and the graphic modes that affect output. The system prepares each display device context for output to a window, setting the drawing objects, colors, and modes for the window instead of 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 specified 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 specified window.
class Permits drawing in the client area of a specified 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 specified 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.

This section provides information on the following topics.