The device context provides the essential drawing tools and the platform to draw. It helps to draw the text, shapes, lines etc. To create the device context, the MFC provides different classes like CDC and CClientDC.
The CDC is the most primary class to draw in MFC. It provides all of the fundamental drawing steps.
The CClientDC class is used for drawing in the client region of a window.
The Device context is a windows data structure which supports the device independent output.
The function of device context is best elaborated by the figure.
Figure: The Role of Device Context
The logical display is a virtual device and Actual display is the physical device. The programmers do not require worrying about the medium in which he is writing the output. The device context takes care of the output medium.