ON_EVENT 报错

错误提示:

error C2440: 'initializing' : cannot convert from 'const wchar_t [1]' to 'UINT'

error C2440: 'initializing' : cannot convert from 'AFX_PMSG' to 'UINT_PTR'

error C2078: too many initializers

错误原因:

放在了

BEGIN_MESSAGE_MAP(CCSDIDemoView, CView)
...
END_MESSAGE_MAP()

正确的应该放在:

BEGIN_EVENTSINK_MAP(CSDMSCom1View, CView)
//{{AFX_EVENTSINK_MAP(CAboutDlg)
ON_EVENT(CSDMSCom1View, IDC_MSCOMM1, 1 /* OnComm */, OnComm, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

在头文件中在函数事件响应函数前面加上
DECLARE_EVENTSINK_MAP()

原文地址:https://www.cnblogs.com/vcerror/p/4289099.html