Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 3: Windows Resources Visual C++ and MFC Fundamentals


Figure 46: Simple Menu................................................................................................................



  1. To use the new menu, open the Exercise.cpp file and change the
    CFrameWnd::Create() method as follows:


#include <afxwin.h>
#include "resource.h"

class CResApp: public CWinApp
{
public:
BOOL InitInstance();
};

class CResFrame : public CFrameWnd
{
public:
CResFrame()
{
Create(NULL, "Resources Fundamentals",
WS_OVERLAPPEDWINDOW, CRect(200, 120, 640, 400),
NULL,
MAKEINTRESOURCE(IDR_MENU_RES));
}
};

BOOL CResApp::InitInstance()
{
m_pMainWnd = new CResFrame;
m_pMainWnd->ShowWindow(SW_SHOW);
m_pMainWnd->UpdateWindow();

return TRUE;
}

CResApp theApp;


  1. Test the application

Free download pdf