Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Visual C++ and MFC Fundamentals Chapter 2: Introduction to MFC


#include <afxwin.h>

class CSimpleFrame : public CFrameWnd
{
public:
CSimpleFrame()
{
// Create the window's frame
Create(NULL, "Windows Application");
}
};

struct CSimpleApp : public CWinApp
{
BOOL InitInstance()
{
// Use a pointer to the window's frame for the application
// to use the window
CSimpleFrame *Tester = new CSimpleFrame ();
m_pMainWnd = Tester;

// Show the window
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;
}
};

CSimpleApp theApp;


  1. Save the file.

  2. To implement the methods outside of their classes, change the file as follows:


#include <afxwin.h>

class CSimpleFrame : public CFrameWnd
{
public:
CSimpleFrame();
};

CSimpleFrame::CSimpleFrame()
{
// Create the window's frame
Create(NULL, "Windows Application");
}

struct CSimpleApp : public CWinApp
{
BOOL InitInstance();
};

BOOL CSimpleApp::InitInstance()
{
Free download pdf