Microsoft Foundation Classes
The Microsoft Foundation Class (MFC) library is a library of classes for you to use when writing Windows programs.
The classes defined in the library can be divided into three parts:
- MFC Application Framwork (Afx): These are the classes that organize your application.
They include the application class (CWinApp), the frame window class (CFrameWnd),
and the document (CDocument) and view (CView) classes.
Your application will be an instance of a class dreived from CWinApp.
You may write your own classes derived from these classes but it is easier just to let the AppWizard do it for you.
- MFC Wrapper Classes: These classes are used to provide an object oriented wrapper for the Window API.
Examples of these classes are the CDialog class for controlling dialogs;
CEdit, CListBox and CButton classes for wrapping dialog controls;
CBitmap, CBrush and CFont for interacting with the Graphic Device Interface (GDI);
and others.
- MFC General Classes: In this category are the classes made to improve programming in general.
Some of these include CSTring for strings, for working with time and dates,
and collection classes such as CArrya, CList and CMap template classes.
Most MFC classes are derived from the CObject base class.
Windows treats all windows as objects so the MFC base class for a window, CWnd, is itself derived (indirectly) from CObject.
Classes derived for CWnd include CFrameWnd, CView, CDialog and CPropertySheet.
Also, Windows sees everything as a window, even dialog controls (basically, anything Windows sends and receives messages from is a window).
Thus the wrapper classes CButton, CEdit, CListBox, CComboBox, etc. are also derived from CWnd.
Some MFC classes not derived from CObject include the simple value types like CString, CTime and CPoint.
As I mentioned earlier, anything Windows sends and receives messages from is a window.
All the MFC classes which process messages are derived from the CCmdTarget class.
This includes CWnd and all its child classes as well as CWinApp and CDocument, which are not derived from CWnd.