error C2440: 'static_cast'
来源:互联网 发布:sony更新挂起网络 编辑:程序博客网 时间:2024/05/02 00:59
一定要注意,函数一定要带参数。
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
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位值。
0 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)...
- 史上最详细bitbucket入门手册,手把手操作指南
- android文件混淆详解
- 360浏览器强制使用兼容模式
- Java中有关Null的9件事
- 在ie上使用xpath时selenium运行缓慢的解决办法
- error C2440: 'static_cast'
- android启航
- 体验Android Studio 1.0稳定版
- 【springMVC】之静态文件访问
- Struts2<6>国际化
- oracle 发送带附件邮件(smtp)
- C#性能优化集锦
- 深入浅出MFC Message Mapping 消息映射
- 解决IIS7.0部署文件在 windows 2008 R2 64位C盘中无法注册问题