Introducing DotNetFunda.com on mobile http://m.dotnetfunda.com ! Be with DotNetFunda.com on the go !
Go to DotNetFunda.com
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 2239 |  Welcome, Guest!   Register  Login
Home > Articles > Others > Outputting Text and Graphics in VC++

Outputting Text and Graphics in VC++

Article posted by Abhisek on 11/26/2009 | Views: 1737 | Category: Others | Level: Beginner 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,

CPaintDC
CClientDC
CWindowDC
CMetaFileDC


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

int OnPaint()
{
CPaintDc dc(this);
dc.TextOut(20,20,"Welcome",7);
return (0);
}

CClientDC:-


        This device context class works with the outputting of text and graphics within the client area. It can work with the events like,
ON_WM_LBUTTONDOWN()
ON_WM_LBUTTONUP()
,etc.

These events occurs when the left mouse button is pressed and released respectively. Similarly there are several button events.

int OnLButtonDown()
{
CClientDC dc(this);
dc.TextOut(20,20,"Welcome",7);
return (0);
}

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.
int OnRButtonDown()
{
CWindowDC dc(this);
dc.TextOut(20,20,"Welcome",7);
return (0);
}


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)

If you like this article, subscribe to our RSS Feed. You can also subscribe via email to our Interview Questions, Codes and Forums section.

Page copy protected against web site content infringement by Copyscape
Found interesting? Add this to:



Please Sign In to vote for this post.

Experience:0 year(s)
Home page:
Member since:Sunday, October 11, 2009
Level:Bronze
Status: [Member]
Biography:Thanks and Regards
Abhisek Panda
Go Green And Save Your Future
>> Write Response - Respond to this post and get points
Related Posts

This is next article to earlier article on "HTML 5 primer" and goes a step ahead to distill it little further.

The standard for HTML5 is drafted in May-2011. It would be finalized soon. It would be interesting to see what it offers and what one need to know about it.

Since last two months we were running "Article Writing Competition - 2011" on the occasion of 4th year of excellent track record of serving .NET Community.

Filters give a great variety of visual effects in web pages dynamically.

On 19-Apr-2011, DotNetFunda.Com has completed its 4th year of excellent track record of serving the .NET community. We had started from 1 article and now we have grown many folds with thousands of articles, interview questions, career advices and other useful content. We are one of the fastest growing website related with .NET Technologies.

More ...
About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you found plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/21/2012 7:21:59 AM