转自原文 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)。

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

  1. 无法从“void (__thiscall CtestDlg::* )(void)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”

      按照孙鑫的教程添加自定义消息时,如果是VC6.0开发环境,也许没有什么 问题,但在VS2008中编译会报错的 无法从"void (__thiscall CtestDlg::* )(voi ...

  2. c语言-error C2440: “static_cast”: 无法从“UINT (__thiscall CHyperLink::* )(CPoint)”转换为“LRESULT (__thiscall CWnd::* )(CPoint)”

    出现这个错误的原因可是“人力不可抗拒”之原因造成的,因为旧版本的 ON_WM_NCHITTEST 宏使用了 UINT (__thiscall CWzButton::* )(CPoint); 类型的类成 ...

  3. error C2440 “static_cast” 无法从“void (__thiscall C* )(void)...

    1.VC6中,说可以把函数在头文件中定义为:afx_msg void OnProgress()这样 但是在VS2005及以上,要求很严格,必须函数返回值为LRESULT类型,所以在VS2005及以上, ...

  4. error C2440: 'static_cast' : cannot convert from 'UINT (__thiscall CStaticLink::* )(CPoint)' to 'LRESULT (__thiscall CWnd::* )(CPoint) (转)

    原文转自 http://blog.csdn.net/yinxing408033943/article/details/7601698 解决方法: 找到  UNIT CStaticLink::OnNcH ...

  5. static_cast” : 无法从“void (__thiscall CMainFrame::* )(NMTOOLBARA *,LRESULT *)”转换为“void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT

    static_cast” : 无法从“void (__thiscall CMainFrame::* )(NMTOOLBARA *,LRESULT *)”转换为“void (__thiscall CCm ...

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

    在Visual Studio 2010中,即使代码是完完全全按照孙鑫视频中的敲,也会在出现error C2440,这是因为开发平台由VC6.0升级至VS2010,需要将原有的项目迁移.VS2010对消 ...

  7. error C2440

    error C2440: "初始化": 无法从"std::_List_const_iterator<std::_List_val<std::_List_sim ...

  8. OpenGL与vs编程——error C2440: “glMaterialfv”: 无法从“GLfloat”转换为“const GLfloat *”

    void setMaterial(const GLfloat mat_diffuse[4],GLfloat mat_shininess){static const GLfloat mat_specul ...

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

    原文地址:http://blog.csdn.net/onlyou930/article/details/5602654 圆环套圆环之迭代器 话说这一日是风平浪静,万里乌云,俺的心情好的没得说,收到命令 ...

随机推荐

  1. hiho1041 - 树,遍历

    题目链接 给一棵树,给一个序列,问能不能按这个序列遍历这棵树,满足每条边最多经过两次. -------------------------------------------------------- ...

  2. c++string类的简单介绍

    #include "iostream" #include "string" using namespace std; /*@author:浅滩 *family: ...

  3. TypeError: Cannot use 'in' operator to search for 'length' in....

    前台页面读取商品属性是字符串形式,数据库中存储商品属性是集合形式,前台数据存入数据库中数据格式会自动转,后台数据回显到前台数据格式需要手动转换,否则会报异常 错误信息提示:

  4. springboot --> web 应用开发-CORS 支持

    一.Web 开发经常会遇到跨域问题,解决方案有:jsonp,iframe,CORS 等等 CORS 与 JSONP 相比 1. JSONP 只能实现 GET 请求,而 CORS 支持所有类型的 HTT ...

  5. 【转】 C#学习笔记14——Trace、Debug和TraceSource的使用以及日志设计

    [转] C#学习笔记14——Trace.Debug和TraceSource的使用以及日志设计 Trace.Debug和TraceSource的使用以及日志设计   .NET Framework 命名空 ...

  6. [转]GLTF-3D图形界的JPEG

    GLTF简介 1.glTF(GL TransmissionFormat),即图形语言交换格式,它是一种3D内容的格式标准,由Khronos Group管理(Khronos Group还管理着OpenG ...

  7. cocos2d-iphone 动作

    (1)CCMoveTo [CCMoveTo alloc]initWithDuration:<#(ccTime)#> position:<#(CGPoint)#> 參数说明 : ...

  8. Constructor call must be the first statement in a constructor

    super()和this ()不能共存.否则编译时会报异常. Constructorcall must be the first statement in a constructor 换句话说就是su ...

  9. codeforces #313(div 2)

    B. Gerald is into Art time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

  10. sass06 mixin

    scss @mixin cont{ //mixin是关键字 color:red; } body{ @include cont; //使用默认值 } @mixin cont($color: red ){ ...