This application was created as follows:
1. Start Microsoft Visual C++ or Visual Studio.
2. On the main menu, click either File -> New... or File -> New Project...
3. In the New dialog box, click Projects or, in the New Project dialog box, click Visual C++ Projects.
4. Click either Win32 Application or Win32 Project.
5. Type a name for the application in the Name edit box. An example would be MFCFundamentals1.
Click OK.
6. Specify that you want to create a Windows Application as an Empty Project and click Finish.
7. To use MFC in MSVC 6, click Project -> Settings... In MSVC 7, in the Solutions Explorer property page, right-click the project name (MFCFundamentals1) and click Properties.
8. In the Microsoft Foundation Classes combo box or in the Use of MFC combo box, select Use MFC In A Shared DLL.
Click OK.
To add a file to create the application, on the main menu of MSVC 6, click File -> New... or, for MSVC 7, on the main menu,
click Project -> Add New Item...
Click C++ (Source) File and, in the Name edit box, type a name for the file. An example would be Exercise.
Click OK or Open.
In the empty file, type the above code:
#include <AFXWIN.H>
class CExerciseApp : public CWinApp
{
public:
virtual BOOL InitInstance();
};
class CMainFrame : public CFrameWnd
{
public:
CMainFrame();
};
CMainFrame::CMainFrame()
{
Create(NULL, "MFC Fundamentals");
}
BOOL CExerciseApp::InitInstance()
{
m_pMainWnd = new CMainFrame;
m_pMainWnd->ShowWindow(SW_NORMAL);
return TRUE;
}
CExerciseApp theApp;Execute the application.
Close it and return to MSVC.