Skip to main content

CObject, the Ancestor of All/Most MFC Classes

To implement its functionality, the MFC is organized as a hierarchical tree of classes, the ancestor of which is CObject:
CObject
Although you can create C++ classes for your applications, most of the classes you will use throughout our lessons descend directly or indirectly from CObject.
The CObject class lays a valuable foundation that other classes can build on. Using the rules of inheritance, the functionality of CObject can be transparently applied to other classes as we will learn little by little. Some of the features that CObject provides are:
  • Performing value streaming for saving or opening the contents of files
  • Controlling dynamic creation and destruction of its inherited classes
  • Checking the validity of variables of classes, etc
You will hardly use CObject directly in your program. Instead, you may create your own classes that are based on CObject. Here is an example:
class CCar : public CObject
{
public:
    CCar();
    char *Make;
    char *Model;
    int Year;
    long Mileage;
    int Doors;
    double Price;
};


  1. To make sure that this application uses MFC, on the main menu, click Project -> Properties...
  2. In the left list, click Configuration Properties
  3. In the right list, click User of MFC, click the arrow of its combo box and select Use MFC In A Shared DLL
    Property Pages
  4. Click OK

Comments

Popular posts from this blog

Links

Official resources MSDN Visual C++ Home microsoft.public.vc.language The Top CodeGuru CodeProject DeveloperFusion.com C/C++ Users Journal RSDN (RU) First Steps (RU) Sources.ru (RU) Tricks, Tips, FAQs Bjarne Stroustrup's C++ Style and Technique FAQ CodeGuru FAQ C++ FAQ Lite by Marshall Cline CodeProject Forum FAQ Boob Moore's page (Win32, NT, MFC) Edelmiro Fuentes's page http://www.sources.ru/cpp/cpp_vcpp_faq.shtml (RU) Akzhan Site (RU) Forums, newsgroups CodeGuru Forum microsoft.public.vc.language comp.lang.c++ RSDN Forum (RU) Libraries, Components, Add-ons, Add-ins Boost Libraries #1 for C++! TinyXML - light yet powerful XML library. Forget about MSXML! :) Whole Tomato Software: Code syntax highlighting Compuware corporation: BoundsChecker, SoftICE etc. Xtreme ToolkitPro - Industry leading Visual C++ MFC UI controls. STL Error Decryptor UCanCode: XD++ MFC Class Library for Diagrams Regular Expression Library Disk File Sy...

Introduction to Microsoft Visual C++/MFC

Microsoft Visual C++ is a programming environment used to create applications for the Microsoft Windows family of operating systems. To use these lessons, you must have installed either Microsoft Visual Studio 2010. Although Microsoft Visual Studio 2010 Professional provides many programming environments for the price of one, in our lessons, we will use it but we will cover only the Microsoft Foundation Class (MFC) library side. After installing it, to use the programming environment, you must first open it. To do that, you would click Start -> (All) Programs -> Microsoft Visual Studio 2010 -> Microsoft Visual Studio 2010. In our lessons, unless used in code, the -> arrow means an action that should follow another. Based on this: Edit -> Copy means click Edit, then click Copy View -> Toolbars -> Custom means click View position the mouse on Toolbars, and then click Custom To start Microsoft Visual C++ or Visual Studio, on the Taskbar, click Start (All) Prog...