MFC 入门级问题
照书上写的代码在红色部分出现错误:error C2065: 'OnLButtonDown' : undeclared identifier
使用的是VC++6.0 选择的是"Use MFC in a Shared DLL"
#include <afxwin.h>
class CHelloApp:public CWinApp
{
public:
virtual BOOL InitInstance();
};
CHelloApp theApp;
class CMainFrame:public CFrameWnd
{
public:
CMainFrame()
{
Create(NULL,"hello",WS_OVERLAPPEDWINDOW,CRect(0,0,400,300));
}
protected:
afx_msg void OnLButtonDown(UINT nFlags,CPoint point);
DECLARE_MESSAGE_MAP()
};
BEGIN_MESAGE_MAP(CMainFrame,CFrameWnd)
ON_WM_LBUTTONDOWN() //ERROR
END_MESSAGE_MAP()
void CMainFrame::OnLButtonDown(UINT nFlags,CPoint point)
{
MessageBox("Hello","问候",0);
CFrameWnd::OnLButtonDown(nFlags,point);
}
BOOL CHelloApp::InitInstance()
{
m_pMainWnd=new CMainFrame();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return TRUE;
}