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

出现这个错误的原因可是“人力不可抗拒”之原因造成的,因为旧版本的 ON_WM_NCHITTEST 宏使用了

UINT (__thiscall CWzButton::* )(CPoint);

类型的类成员函数指针,其定义如下:

#define ON_WM_NCHITTEST() \

{ WM_NCHITTEST, 0, 0, 0, AfxSig_wp, \

(AFX_PMSG)(AFX_PMSGW)(UINT (AFX_MSG_CALL CWnd::*)(CPoint))&OnNcHitTest },

但是新版本变成了:

#define ON_WM_NCHITTEST() \

{ WM_NCHITTEST, 0, 0, 0, AfxSig_l_p, \

(AFX_PMSG)(AFX_PMSGW) \

(static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(CPoint) > (&ThisClass :: OnNcHitTest)) },

注意返回值类型由UINT改成了LRESULT,再加上static_cast的严格检查,所以就出错了。修改的方法就是将你的OnNcHitTest函数由:

afx_msg UINT OnNcHitTest(CPoint point);

改成:

afx_msg LRESULT OnNcHitTest(CPoint point);

 

UINT CHyperLink::OnNcHitTest(CPoint /*point*/)

改成:

LRESULT CHyperLink::OnNcHitTest(CPoint /*point*/)   
 

将UINT改成LRESULT

http://msdn.microsoft.com/zh-cn/library/sy5tsf8z.aspx

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

上一篇:六种主流编程语言(C、C++、Python、JavaScript、PHP、Java)特性对比


下一篇:MeeGo Touch服务框架