class CDC : public CObject

The CDC class defines a class of device-context objects. The CDC object provides member functions for working with a device context, such as a display or printer, as well as members for working with a display context associated with the client area of a window.

Do all drawing through the member functions of a CDC object. The class provides member functions for device-context operations, working with drawing tools, type-safe GDI object selection, and working with colors and palettes. It also provides member functions for getting and setting drawing attributes, mapping, working with the viewport, working with the window extent, converting coordinates, working with regions, clipping, drawing lines, drawing simple shapes, ellipses, and polygons. Member functions are also provided for drawing text, working with fonts, using printer escapes, scrolling, and playing metafiles.

To use a CDC object, construct it, and then call its member functions, which parallel Windows functions that use device contexts or display contexts.

For specific uses, the Microsoft Foundation Class Library provides several classes derived from CDC—in particular class CPaintDC, which encapsulates calls to BeginPaint and EndPaint. Class CClientDC manages a display context associated with a window's client area. Class CWindowDC manages a display context associated with an entire window, including its frame and controls. Class CMetafileDC associates a device context associated with a metafile.

CDC supports the Attach/Detach idiom for Windows handles described in CWnd.

See Also

CPaintDC, CWindowDC, CClientDC, CMetafileDC