Outputting Text and Graphics in VC++

Posted by in Others category on for Beginner level | Views : 6605 red flag

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,



     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().

int OnPaint()
CPaintDc dc(this);
return (0);


        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.

int OnLButtonDown()
CClientDC dc(this);
return (0);


        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.
int OnRButtonDown()
CWindowDC dc(this);
return (0);


        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)

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Abhisek Panda
Member Level: Bronze
Member Status: Member
Member Since: 10/11/2009 6:25:59 AM
Country: India
Abhisek Panda

Thanks and Regards Abhisek Panda Go Green And Save Your Future

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)