C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » General »

Outputting text and graphics in VC++


Posted Date: 06 Nov 2009    Resource Type: Articles    Category: General
Author: Abhisek PandaMember Level: Gold    
Rating: 1 out of 5Points: 10



Outputting text and graphics in VC++ using MFC


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)



Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Outputting text and graphics in VC++  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Creating Pen and Brush in VC++
Previous Resource: Shortcut methods for basic mathematics Operations
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use