错误 1 error C2440: “static_cast”: 无法从“void (__thiscall ClientDlg::* )
来源:互联网 发布:淘宝积分兑换优酷会员 编辑:程序博客网 时间:2024/05/16 17:59
不能转换void (_thiscall CMainFrame::*)(void)to LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)2010-05-13 11:35开发平台由VC6.0升级至VS2005,需要将原有的项目迁移,可能碰到类似错误:
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
error C2440: 'static_cast' : cannot convert from 'void (__thiscall CMainFrame::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
VS2005对消息的检查更为严格,以前在VC6下完全正常运行的消息映射在VS2005下编译不通过
ON_MESSAGE(WM_message,OnMyMessage);
OnMyMessage返回值必须为LRESULT,其形式为:afx_msg LRESULT OnMyMessage(WPARAM, LPARAM);如果不符合,则有错误提示:
error C2440: “static_cast”: 无法从“void (__thiscall CPppView::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
在匹配目标类型的范围内没有具有该名称的函数
error C2440: “static_cast”: 无法从“void (__thiscall CPppView::* )(void)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
在匹配目标类型的范围内没有具有该名称的函数
解决方法如下:
首先,把原来的消息函数返回值类型改为LRESULT,函数内可以随便写个return TRUE; 然后消息函数的参数必须改写成(WPARAM wParam,LPARAM lParam)而不论这两个参数是否用得到;最后,消息映射如ON_MESSAGE(WM_message,& OnMyMessage)
0 0
- 错误 1 error C2440: “static_cast”: 无法从“void (__thiscall ClientDlg::* )
- 错误 1 error C2440: “static_cast”: 无法从“void (__thiscall ClientDlg::* )
- 错误 4 error C2440: “static_cast”: 无法从“void (__thiscall HelloWorld::*
- error C2440: “static_cast”: 无法从“void (__thiscall CXXDlg* )(void)”转换为“LRESULT (__thiscall CWnd:的错误
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)...
- error C2440: “static_cast”: 无法从“void (__thiscall CMainFrame::* )(void)
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)...
- error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...
- error C2440: “static_cast”: 无法从“void (__thiscall xxxxxx::* )(LON
- error C2440: “static_cast”: 无法从“void (__thiscall CChat
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)”
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARA
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall
- iOS网络请求总结
- 第二章第4题
- 安装cocoapods管理第三方库时的问题
- JAVA 获取当前执行的函数名、当前运行的类名等等信息
- 如何通过匹配||切分字符串
- 错误 1 error C2440: “static_cast”: 无法从“void (__thiscall ClientDlg::* )
- 算法导论11.2-4未占用槽分配存储
- 工作中积累的日期、数字处理方法
- 细化-从百度识图效果对智能识图的一些思考2
- Java网络编程从入门到精通(31):非阻塞I/O简介
- Spark源码IDEA远程调试
- 安装eclipse中html/jsp/xml editor插件
- 软考路——进程与线程
- Java 基础知识课堂笔记