error C2440: ’static_cast’
来源:互联网 发布:大数据关键技术包括 编辑:程序博客网 时间:2024/05/02 06:56
转帖:http://blog.csdn.net/stilling2006/archive/2010/06/18/5676794.aspx
error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
1> 从基类型到派生类型的强制转换需要 dynamic_cast 或 static_cast
搜索发现为开发平台迁移问题。
由vc6.0升级至vs2005以上平台均会遇到这情况,原因为
VS2005对消息的检查更为严格,以前在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位值
补充:在实现函数的时候,程序最后返回0就可以了。
...
afx_msg LRESULT OnRecvData(WPARAM wParam, LPARAM lParam)
{
...
return 0;
}
- error C2440: ’static_cast’
- error C2440: ’static_cast’
- error C2440: ’static_cast’
- error C2440: 'static_cast'
- error C2440: 'static_cast'
- error C2440: 'static_cast' LRESULT LRESULT错误
- error C2440: 'static_cast' LRESULT LRESULT错误
- error C2440: 'static_cast' 错误的解决方法
- error C2440: 'static_cast' LRESULT LRESULT错误
- error C2440: ‘static_cast‘ LRESULT LRESULT错误
- vs2008 error C2440: “static_cast”: ……
- error C2440: 'static_cast' LRESULT LRESULT错误
- error C2440: 'static_cast' 错误的解决方法
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)...
- VS2008 V2010 平台迁移中:error C2440: "static_cast"
- error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)...
- 值得期待的 Microsoft + Nokia
- ADODB是如何完成符号转义的
- Qt入门之二——Hello Qt!
- 51单片机驱动能力(拉电流_灌电流)及上拉电阻
- xp与ubuntu双系统下使用一键GHOST
- error C2440: ’static_cast’
- Linux入门的最基本的命令: basic command 以及终端使用的快捷方式
- 灌电流和拉电流的概念及记忆方法
- 几个电子技术方面的名词
- 关于TCP打洞技术(P2P)
- 以假乱真的【酷点】 - Windows下 模仿 Apple 界面
- ASP.NET 3.5(C#)系列3-新一代事务机制
- c/c++ 传引用,数组传引用 区别
- 躲bpx检测方法总结