VC 6.0 转 VS 2010 问题:error C2440: 'static_cast' 解决办法
2014-12-18 15:25
489 查看
VC 6.0 转 VS 2010 问题:error C2440: 'static_cast'
一定要注意,函数一定要带参数。
error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”1> 从基类型到派生类型的强制转换需要 dynamic_cast 或 static_cast
搜索发现为开发平台迁移问题。
由vc6.0升级至vs2005以上平台均会遇到这情况,原因为
VS2005 、VS 2010对消息的检查更为严格,以前在VC6下完全正常运行的消息映射在VS2005下编译不通过
// 生成的消息映射函数
virtual BOOL OnInitDialog();
afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
afx_msg void OnPaint();
afx_msg HCURSOR OnQueryDragIcon();
afx_msg void OnRecvData(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
BEGIN_MESSAGE_MAP(CChatDlg, CDialog)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
//}}AFX_MSG_MAP
ON_EN_CHANGE(IDC_EDIT_RECV, &CChatDlg::OnEnChangeEditRecv)
ON_BN_CLICKED(IDC_BTN_SEND, &CChatDlg::OnBnClickedBtnSend)
ON_MESSAGE(WM_RECVDATA,
&CChatDlg::OnRecvData)
END_MESSAGE_MAP()
编译错误提示:
error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
1> 从基类型到派生类型的强制转换需要 dynamic_cast 或 static_cast
更改定义:
afx_msg void OnRecvData(WPARAM wParam, LPARAM lParam);
为
afx_msg LRESULT OnRecvData(WPARAM wParam, LPARAM lParam);
编译通过
LRESULT是一个数据类型,
MSDN: 32-bit value returned from a window procedure or callback function
指的是从窗口程序或者回调函数返回的32位值。
原文出处:http://blog.163.com/bbluesnow@126/blog/static/277845452011441511611/
相关文章推荐
- error C2440: 'static_cast' 错误的解决方法
- parameter 3 from 'unsigned long (void *)' to 'unsigned long (__stdcall *)VC以类的成员函数作为线程调用函数时易出错问题解决办法
- GEF,EMF,RCP,Eclipse's plugin的几个问题(5) RCP Navigator View project name 为空解决办法
- Microsoft JET Database Engine 错误 '80004005' 操作必须使用一个可更新的查询。问题解决办法
- VC6编写的程序移植到VS2010中编译时error C2440: “static_cast”问题的解决
- vc 出现“fatal error C1085: Cannot write precompiled header file: 'Debug/xxx.pch': The parameter is incorrect“的错误的解决办法
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall MenuToolBar::* )(LPARAM,LRESULT *)' to 'void (__thiscall CCmd
- jmail.Message 错误 '8000ffff' 问题解决办法
- VC++ 6.0 右键 不能重载虚函数 显示"no virtual functions available to be overridden"问题的解决
- error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CchatDlg::* )(CPoint)' to 'UI
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CTrunkPage::* )(void)' to 'void (__thiscall CCmdTarget::* )(N
- 安装BCGControlBar 编译错误解决办法 fatal error C1033: cannot open program database '*:/**/vc60.idb'
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall MenuToolBar::* )(LPARAM,LRESULT *)' to 'void (__thiscall CCmd
- error C2664: 'RtCreateTimer' : cannot convert parameter 3 from 'int (void *)' to 'void (__stdcall *)(void *)'问题解决办法
- error C2440: 'static_cast' LRESULT LRESULT错误
- 问题 error C2065: '_beginthreadex' : undeclared identifier 的解决办法
- Unable to cast COM object of type 'System.__ComObject' to class type 的解决办法
- VC 6.0 “fatal error LNK1104: cannot open file "mfc42u.lib"”问题解决
- VC 6.0 “fatal error LNK1104: cannot open file "mfc42u.lib"”问题解决
- dede(织梦)从5.5升级到5.6出现的“Unknown column 'weight' in 'field list'”的问题的解决办法