关于MFC自定义消息--很幼稚的问题
我想在继承CDocument类的对象里使用自定义的消息,编译能通过,但是不可运行。恳切高手指点。Thanks in advance!!
在resource.h中:
#define IDM_MYMESSAGE 32773
在MyWinDoc.h中:
class CMyWinDoc : public CDocument
{
....
// Generated message map functions
protected:
//{{AFX_MSG(CMyWinDoc)
afx_msg void OnMyMessage();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
在MyWinDoc.cpp中:
IMPLEMENT_DYNCREATE(CMyWinDoc, CDocument)
BEGIN_MESSAGE_MAP(CMyWinDoc, CDocument)
//{{AFX_MSG_MAP(CMyWinDoc)
ON_COMMAND(IDM_MYMESSAGE, OnMyMessage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
......
void CMyWinDoc::OnMyMessage()
{
AfxGetMainWnd()->SendMessage(WM_COMMAND, IDM_MYMESSAGE);
}
类似的在CWinApp类中却可以很好的工作,Why?