I created a Win32 console application to write a simples MFC project.
The source code is as follow:
#include <afxwin.h>
class MyApp : public CWinApp
{
public:
BOOL InitInstance();
MyApp()
{
}
};
class MainWindow : public CFrameWnd
{
protected:
int OnCreate(LPCREATESTRUCT lpCreateStruct);
void OnClose();
LRESULT OnTimer(WPARAM wParam, LPARAM lParam);
// This line is causing the error
DECLARE_MESSAGE_MAP()
};
BOOL MyApp::InitInstance()
{
MainWindow* mainWindow = new MainWindow();
m_pMainWnd = mainWindow;
mainWindow->Create(NULL, L"Main Window");
mainWindow->ShowWindow(m_nCmdShow);
return TRUE;
}
MyApp myApp;
int MainWindow::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
SetTimer(1, 2000, NULL);
return 0;
}
void MainWindow::OnClose()
{
if (MessageBox(L"Close?", L"Close", MB_YESNO | MB_ICONQUESTION) == IDYES)
{
KillTimer(1);
CFrameWnd::OnClose();
}
}
LRESULT MainWindow::OnTimer(WPARAM wParam, LPARAM lParam)
{
MessageBeep(MB_ICONQUESTION);
return 0;
}
When I try to compile I get the following error:
Error 1 error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall MainWindow::GetMessageMap(void)const " (?GetMessageMap@MainWindow@@MBEPBUAFX_MSGMAP@@XZ) D:\Projects\MinimumMFC\MinimumMFC\MinimumMFC.obj MinimumMFC