【发布时间】:2014-04-20 16:13:26
【问题描述】:
在我的 MFC SDI 应用程序中,在派生自 CDocument 的文档部分中,我添加了一个用于发布消息的用户消息处理程序,如下所示。我得到编译错误:
错误 C2440: 'static_cast' : 无法从 'void (__thiscall CMyDoc::* )(WPARAM,LPARAM)' 转换为 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' .
CMyDoc.cpp:
#define UWM_Message1 (WM_APP+1)
BEGIN_MESSAGE_MAP(CMyDoc, CDocument)
//{{AFX_MSG_MAP(CMyDoc)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
ON_MESSAGE(UWM_Message1, &CMyDoc::OnMyFunc)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CMyDoc::OnMyFunc(WPARAM wParam, LPARAM lParam)
{
int Len = (int)wParam;
BYTE * pBuf = (BYTE*)lParam;
//do stuff..
return;
}
CMyDoc.h:
在 CMyDoc 类中:
public:
afx_msg void OnMyFunc(WPARAM wParam, LPARAM lParam);
【问题讨论】:
标签: mfc