---
title: "MFC (Microsoft Foundation class)"  
description: "MFC built on concept of class hierarchy. Most of the MFC classes are driven from another class which is eventually driven from CObject.  When we use t"  
author: "Amit Singh"  
published: 2011-05-08  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/159/mfc-microsoft-foundation-class  
category: "visual c++"  
tags: ["visual c++"]  
reading_time: 1 minute  

---

# MFC (Microsoft Foundation class)

MFC built on concept of [class hierarchy](https://www.mindstick.com/interview/2459/what-is-the-difference-between-the-reader-writer-class-hierarchy-and-the-inputstream-outputstream-class-hierarchy). Most of the MFC classes are driven from another class which is eventually driven from CObject.\

When we use these classes they inherit many behaviors from their ancestors.

When we crate any [MFC application](https://www.mindstick.com/forum/6/multi-form-mfc-application) (project name welcome) in vc++ it creates following files:

· welcome.clw : This is the class wizard file

· welcome.dsw: Main [workspace](https://www.mindstick.com/blog/304118/transform-your-workspace-tips-for-enhancing-focus-and-productivity) file

· welcome.h: Application [header file](https://answers.mindstick.com/qa/104712/how-to-include-a-header-file)

· welcome.cpp: Application code file

· StdAfx.h: [Standard](https://www.mindstick.com/articles/23223/naming-convention-or-coding-standard) application [framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) header

· StdAfx.cpp: Standard application framework code

· MainFrm.h: Main window header

· Mainfrm.cpp Main window code

· welcomeDoc.h : Document header

· welcomeDoc.cpp: Document code

· welcomeView.h: View header

· welcomeView.cpp View code

· Resource.h Resource [constants](https://www.mindstick.com/articles/1813/objective-c-constants) file

· welcome.rc [Resource file](https://www.mindstick.com/articles/327263/what-is-the-use-of-resource-file-how-to-use-it-on-your-project)

· welcome.ncb Layout and dependencies file

· welcome.dsp Project file

· res Resource [directory](https://www.mindstick.com/forum/226/how-to-get-application-directory-using-c-sharp-csharp)

· readme.txt It contain the file information

##### For Example:

##### \

##### Displaying any message

##### \

We write the code in OnDraw() method in welcomeView.cpp file

```
void CWelcomeView::OnDraw(CDC* pDC){      CString mesg="This is the first mfc application";      CAmitMFC1Doc* pDoc = GetDocument();      ASSERT_VALID(pDoc);      pDC->TextOut(0,0,mesg);}
```

---

Original Source: https://www.mindstick.com/blog/159/mfc-microsoft-foundation-class

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
