Visual C++ 6 Unleashed

Visual C++ 6 Unleashed

By MICKEY WILLIAMS and David Bennett

The CWinApp Class

Every true MFC application has a class derived from CWinApp. You can see how MFC AppWizard has done this for you by looking at the following sample from HiMom.h:

class CHiMomApp : public CWinApp
{
public:
    CHiMomApp();
// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CHiMomApp)
    public:
    virtual BOOL InitInstance();
    //}}AFX_VIRTUAL
// Implementation
    //{{AFX_MSG(CHiMomApp)
    afx_msg void OnAppAbout();
        // NOTE: ClassWizard will add and remove member functions here.
        // DO NOT EDIT what you see in these blocks of generated code !
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
};

The first line shown here is what gives your application the real power of the MFC application framework. This is where the CHiMomApp class is derived from CWinApp. Apart from that, you will notice an awful lot of strange comments. These comments give the ClassWizard landmarks to find the pieces of the code that it manipulates.

Just as your Application class derives from CWinApp, CWinApp itself is derived from a chain of other classes in the application architecture hierarchy, including CWinThread, CCmdTarget, and CObject.

Share ThisShare This

Informit Network