error C2440: “static_cast”: 无法从“LRESULT (__thiscall CTextProgressCtrl::* )(UINT,LPCTSTR)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)

转自原文 error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...

error C2440: “static_cast”: 无法从“LRESULT (__thiscall CTextProgressCtrl::* )(UINT,LPCTSTR)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)。

开发平台由VC6.0升级至VS2005以上的版本,需要将原有的项目迁移,可能碰到类似错误:error C2440:  “static_cast” 无法从“void (__thiscall C* )(void)...

旧版本的C++工程升级后出现的该问题,VS2005之后的版本对消息的检查更为严格,以前在VC6下完全正常运行的消息映射在VS2005下编译不通过。

ON_MESSAGE(WM_message,OnMyMessage);  

OnMyMessage返回值必须为LRESULT,其形式为:afx_msg LRESULT OnMyMessage(WPARAM, LPARAM);如果不符合,则有错误提示:

error C2440: “static_cast”: 无法从“void (__thiscall  CXXX::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)” 在匹配目标类型的范围内没有具有该名称的函数
error C2440: “static_cast”: 无法从“void (__thiscall  CXXX::* )(void)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”在匹配目标类型的范围内没有具有该名称的函数 

解决方法如下:

首先,把原来的消息函数返回值类型改为LRESULT,函数内可以随便写个return TRUE;

然后消息函数的参数必须改写成(WPARAM wParam,LPARAM lParam)而不论这两个参数是否用得到;

最后,消息映射如ON_MESSAGE(WM_message,& OnMyMessage)。

时间: 2024-08-09 02:20:58

error C2440: “static_cast”: 无法从“LRESULT (__thiscall CTextProgressCtrl::* )(UINT,LPCTSTR)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)的相关文章

消息传递MFC error C2440 “static_cast” 无法从“void (_thiscall )(void)”转换为“LRESULT

转载至:http://www.educity.cn/wenda/566627.html error C2440 “static_cast” 无法从“void (__thiscall )(void)”转换为“LRESULTerror C2440 “static_cast” 无法从“void (__thiscall CPppView )(void)”转换为“LRESULT (__thiscall CWnd )(WPARAM,LPARAM)” 不能转换void (_thiscall CMainFram

error C2440: “static_cast”: 无法从“void (__thiscall CMainFrame::* )

在VC++6.0向导中完成项目迁移到VS2012版的错 编译时遇到两个问题,首先是 error C2440: "static_cast": 无法从"void (__thiscall CMainFrame::* )(BOOL,HTASK)"转换为"void (__thiscall CWnd::* )(BOOL,DWORD)" 1>          从基类型到派生类型的强制转换需要 dynamic_cast 或 static_cast err

MFC “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”

编译错误提示: 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);为a

error C2440

error C2440: “static_cast”: 无法从“void (__thiscall CChatDlg::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”1>        从基类型到派生类型的强制转换需要 dynamic_cast 或 static_cast 搜索发现为开发平台迁移问题.由vc6.0升级至vs2005以上平台均会遇到这情况,原因为 VS2005对消息的检查更为严格,以前在VC6下

关于vs2008的error C2440

关于vs2008的error C2440 (2012-04-24 18:27:11) 转载▼ 不能转换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 (__th

cocos2d-x 编译问题集合之error C2440: “类型转换”: 无法从“void (__thiscall ::* )(void)”转换为“

1.提示为 error C2440: "类型转换": 无法从"void (__thiscall xx::* )(void)"转换为"cocos2d::SEL_CallFuncN" 提示前 调用语句为 callfuncN_selector(GameMenu::menuEnter) menuEnter这个方法里边是没有形参的 导致了这个问题出现 修改办法为 将menuEnter这个方法改成menuEnter(CCNode * node) 加入这个形参

孙鑫视频改变窗口过程函数中出现error C2440错误的解决方法

在Visual Studio 2010中,即使代码是完完全全按照孙鑫视频中的敲,也会在出现error C2440,这是因为开发平台由VC6.0升级至VS2010,需要将原有的项目迁移.VS2010对消息的检查更为严格,以前在VC6.0下完全正常运行的消息映射在VS2010下编译不通过. 百度了解决方法如下(亲测可用): 例如:TestDlg.cpp中ON_REGISTERED_MESSAGE(WM_INITDIALOG, &CTestDlg::OnInitDialog):第一:把原来的消息函数返

C++ error C2440: “类型转换” : 无法从“std::vector::iterator”转换为“

原文地址:http://blog.csdn.net/onlyou930/article/details/5602654 圆环套圆环之迭代器 话说这一日是风平浪静,万里乌云,俺的心情好的没得说,收到命令清理A区(写部分代码,其中有在VC6下己完成的代码要移植到VC7下),一路上很轻松,用‘饭得标’的话来说就是‘卡卡’地!在快完成时出现错误. error C2440: “类型转换” : 无法从“std::vector<_Ty>::iterator”转换为“PPkgHead”with[_Ty=BYT

cocos3 error C2440

>d:\program files (x86)\microsoft visual studio 11.0\vc\include\xrefwrap(431): error C2440: “return”: 无法从“void”转换为“bool” (..\Classes\HelloWorldScene.cpp) 1> void 类型的表达式不能转换为其他类型 1> d:\program files (x86)\microsoft visual studio 11.0\vc\include\fu