Practical Learning: Creating a Map of Messages

Started by sukishan, Jul 12, 2009, 05:24 PM

Previous topic - Next topic

sukishan

Create a new and empty Win32 Project located in C:\Programs\MSVC Exercises and set its name to Messages1.
Specify that you want to use MFC in a Shared DLL.

Create a C++ file and name it Exercise.
To create a frame for the window, in the Exercise.cpp file, type the following:  Collapse Copy Code#include <AFXWIN.H>

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

protected:
   
    DECLARE_MESSAGE_MAP()
};

CMainFrame::CMainFrame()
{
    // Create the window's frame
Create(NULL,"WindowsApplication",WS_OVERLAPPEDWINDOW,
                       CRect(120, 100, 700, 480), NULL);
}

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

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)

END_MESSAGE_MAP()

BOOL CExerciseApp::InitInstance()
{
    m_pMainWnd = new CMainFrame ;
    m_pMainWnd->ShowWindow(SW_SHOW);
    m_pMainWnd->UpdateWindow();

    return TRUE;
}

CExerciseApp theApp;Test the application and return to MSVC.
A good beginning makes a good ending