In my MFC SDI application, In the document section derived from CDocument, I have added a user message handler for posting messages as follows. I get the compilation error:
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMyDoc::* )(WPARAM,LPARAM)' to '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:
inside the class CMyDoc:
public:
afx_msg void OnMyFunc(WPARAM wParam, LPARAM lParam);