: error C2440: “static_cast”: 无法从“void (__thiscall CBCGPInformationBar::* )(WPARAM,LPARAM)”转换为“LRESU
2012-12-13 17:43
645 查看
: error C2440: “static_cast”: 无法从“void (__thiscall CBCGPInformationBar::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
C++ 2011-06-11 11:33
2546人阅读 评论(4)收藏
举报
“static_cast”无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)”
不能转换void (_thiscall CMainFrame::*)(void)to LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)开发平台由VC6.0升级至VS2005,需要将原有的项目迁移。
可能碰到类似错误:
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)”在匹配目标类型的范围内没有具有该名称的函数
解决方法如下:
例如:TransparentWnd.cpp中ON_MESSAGE(WM_LIBEN,OnLiben):
第一:把原来的消息函数返回值类型改为LRESULT(找到OnLiben定义,如Viod CTransparentWnd::OnLiben(WPARAM wParam,LPARAM lParam)改成LRESULT CTransparentWnd::OnLiben(WPARAM
wParam,LPARAM lParam),声明处也要改,如afx_msg LRESULT OnLiben(WPARAM wParam,LPARAM lParam););
第二:函数内可以随便写个return
TRUE;
第三:然后消息函数的参数必须改写成(WPARAM wParam,LPARAM lParam)而不论这两个参数是否用得到;
第四:消息映射如ON_MESSAGE(WM_message,& OnMyMessage
原帖地址http://hi.baidu.com/%C3%D7%BF%CD%D3%D0%D3%D1/blog/item/03fa9c1573c1171c314e155b.html
error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall
分类:C++ 2011-06-11 11:33
2546人阅读 评论(4)收藏
举报
“static_cast”无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)”
不能转换void (_thiscall CMainFrame::*)(void)to LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)开发平台由VC6.0升级至VS2005,需要将原有的项目迁移。
可能碰到类似错误:
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)”在匹配目标类型的范围内没有具有该名称的函数
解决方法如下:
例如:TransparentWnd.cpp中ON_MESSAGE(WM_LIBEN,OnLiben):
第一:把原来的消息函数返回值类型改为LRESULT(找到OnLiben定义,如Viod CTransparentWnd::OnLiben(WPARAM wParam,LPARAM lParam)改成LRESULT CTransparentWnd::OnLiben(WPARAM
wParam,LPARAM lParam),声明处也要改,如afx_msg LRESULT OnLiben(WPARAM wParam,LPARAM lParam););
第二:函数内可以随便写个return
TRUE;
第三:然后消息函数的参数必须改写成(WPARAM wParam,LPARAM lParam)而不论这两个参数是否用得到;
第四:消息映射如ON_MESSAGE(WM_message,& OnMyMessage
原帖地址http://hi.baidu.com/%C3%D7%BF%CD%D3%D0%D3%D1/blog/item/03fa9c1573c1171c314e155b.html
相关文章推荐
- error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscal
- 错误 1 error C2440: “static_cast”: 无法从“void (__thiscall CTCPDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)” 解决问题
- error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRE
- error C2440: “static_cast”: 无法从“void (__thiscall CPppView::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscal
- 【转】error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)”
- error C2440: “static_cast”: 无法从“void (__thiscall CMYQQDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__th
- error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thisca
- error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRE
- error C2440: “static_cast”: 无法从“void (__thiscall CXPButton::* )(WPARAM,LPARAM)”转换为“LRESULT (__thisca
- error C2440: “static_cast”: 无法从“void (__thiscall CTransparentWnd::* )(WPARAM,LPARAM)”转换为“LRESULT (__
- error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT
- “static_cast”: 无法从“void (__thiscall CMyNetChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
- 2440: “static_cast”: 无法从“void (__thiscall CMainDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd:
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)”
- error C2440: “static_cast”: 无法从“LRESULT (__thiscall CTextProgressCtrl::* )(UINT,LPCTSTR)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)
- error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)
- error C2440: “static_cast”: 无法从“void (__thiscall CXXDlg* )(void)”转换为“LRESULT (__thiscall CWnd:的错误
- error C2440: 'static_cast' : cannot convert from 'void (__thiscall CChatDlg::* )(WPARAM,LPARAM)' to
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__t
- error C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thisca