blog

Home / DeveloperSection / Blogs / MFC (Microsoft Foundation class)

MFC (Microsoft Foundation class)

Amit Singh6137 08-May-2011

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 these classes they inherit many behaviors from their ancestors.

When we crate any MFC application (project name welcome) in vc++ it creates following files:

·         welcome.clw :                 This is the class wizard file

·         welcome.dsw:                  Main workspace file

·         welcome.h:                      Application header file

·         welcome.cpp:                   Application code file

·         StdAfx.h:                           Standard application framework 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 file

·         welcome.rc                        Resource file

·         welcome.ncb                     Layout and dependencies file

·         welcome.dsp                     Project file

·         res                                     Resource directory

·         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);
}

Updated 18-Sep-2014

Leave Comment

Comments

Liked By