Programming windows with mfc by Jeff Prosise first example help

Hi. Im about to start MFC programming with Visual C++. I choose book "Programming windows with MFC second edition by Jeff Prosise. But the problem is, on it's very first example it contains some code like this..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
Hello.h
class CMyApp : public CWinApp
{
public:
    virtual BOOL InitInstance ();
};

class CMainWindow : public CFrameWnd
{
public:
    CMainWindow ();

protected:
    afx_msg void OnPaint ();
    DECLARE_MESSAGE_MAP ()
};


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Hello.cpp
#include <afxwin.h>
#include "Hello.h"

CMyApp myApp;

/////////////////////////////////////////////////////////////////////////
// CMyApp member functions

BOOL CMyApp::InitInstance ()
{
    m_pMainWnd = new CMainWindow;
	

   m_pMainWnd->ShowWindow (m_nCmdShow);
    m_pMainWnd->UpdateWindow ();
    return TRUE;
}

/////////////////////////////////////////////////////////////////////////
// CMainWindow message map and member functions

BEGIN_MESSAGE_MAP (CMainWindow, CFrameWnd)
    ON_WM_PAINT ()
END_MESSAGE_MAP ()

CMainWindow::CMainWindow ()
{
    Create (NULL, _T ("The Hello Application"));
}

void CMainWindow::OnPaint ()
{
    CPaintDC dc (this);
    
    CRect rect;
    GetClientRect (&rect);

    dc.DrawText (_T ("Hello, MFC"), -1, &rect,
        DT_SINGLELINE ¦ DT_CENTER ¦ DT_VCENTER);
}


This is all. No ChildView.cpp s or MainFrm.cpp s.
And he doesn't explain how he started with those two files. Just codes. But when I create new MFC application with visual C++ (2013) it generates much more files than Hello.h and Hello.cpp.
And some of them contains some thing like
1
2
3
4
5
class CMyApp : public CWinApp
{
public:
    virtual BOOL InitInstance ();
};


But not as plain as the example from the book.

So I want to know if is there anyway to start MFC programming with empty MFC project ? Those extra things makes it tricky.

Thanks in advance.
Just choose "Empty project" in Visual Studio wizard and then add your files to the project. Or remove the auto-generated ones.
Registered users can post here. Sign in or register to post.