The article will describe you about the use of different classes in VC++ to output text and graphics with examples.
MFC carries out the outputting of text and graphics by using device context. It defines a top-level device context class with the name "CDC".
This class defines a group of subclasses relating to a particular device. The subclasses defines a set of functions relating to GDI(Graphics Device Interface) to output text and graphics. The various subclasses defined by CDC are as follows,
CPaintDC:- This device context class can output text and graphics within the client area of the window. It works on the event of ON_WM_PAINT().
This event occures when we interact with a window,i.e, when we open the window, close the window, move the window, resize the window, etc. The ON_WMPAINT() is associated with an event handler,i.e, OnPaint().
CClientDC:- This device context class works with the outputting of text and graphics within the client area. It can work with the events like,
These events occurs when the left mouse button is pressed and released respectively. Similarly there are several button events.
CWindowDC:- This device context class relates to outputting text and graphics in client area as well as non-client area of a window. It works with the events relating to button and mouse, etc.
CMetaFileDC:- This device context class works with the input, output relating to files. It is also the medium via which data persistence is carried out. In other words CMetaFileDC works with the serialization and deserialization of objects.
(Writing the state of object to a persisted device is called serialization and loading of that object is called as deserialization)