C ++编译错误-消息映射 [英] c++ compile error - Message Map

查看:84
本文介绍了C ++编译错误-消息映射的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我希望有人能帮助我.我正在将VC5应用程序升级到VC2005,我遇到一个无法解决的编译错误.我花了很多时间在此上,我对导致错误的原因有了基本的了解,但是由于我对C ++还是很陌生,因此我对如何解决该错误感到困惑. br/>
错误是;

错误C2440:``static_cast'':无法从``void(__thiscall CSearchPedsDlg :: *)(void)''转换为``void(__thiscall CCmdTarget :: *)(NMHDR *,LRESULT *)''

令人讨厌的代码是ON_NOTIFY行;

Hi Guys,

I''m hoping someone can help me. I''m upgrading a VC5 application to VC2005, I have one compilation error that I''m unable to resolve. I''ve spent a fair amount of time on this, I get the basic idea of what is causing the error, but I''m at a loss on how to resolve it as I''m still pretty new to C++.

The error is;

error C2440: ''static_cast'' : cannot convert from ''void (__thiscall CSearchPedsDlg::* )(void)'' to ''void (__thiscall CCmdTarget::* )(NMHDR *,LRESULT *)''

The offending code is the ON_NOTIFY lines;

BEGIN_MESSAGE_MAP(CSearchPedsDlg, CDialog)
	//{{AFX_MSG_MAP(CSearchPedsDlg)
	ON_BN_CLICKED(IDC_ADD1, OnAdd1)
	ON_BN_CLICKED(IDC_ADD2, OnAdd2)
	ON_BN_CLICKED(IDC_DEL1, OnDel1)
	ON_BN_CLICKED(IDC_DEL2, OnDel2)
	ON_BN_CLICKED(IDC_PRINT, OnPrint)
	ON_BN_CLICKED(IDC_SELECT, OnSelect)
	ON_BN_CLICKED(IDC_LIST1, OnList1)
	ON_BN_CLICKED(IDC_LIST2, OnList2)
	ON_BN_CLICKED(IDC_DELALL1, OnDelall1)
	ON_BN_CLICKED(IDC_DELALL2, OnDelall2)
	ON_BN_CLICKED(IDC_SEARCHALL, OnSearchall)
	ON_BN_CLICKED(IDC_DESCENDOF, OnDescendof)
	ON_NOTIFY(NM_DBLCLK, IDC_SEARCHFOR, OnAdd1)
	ON_NOTIFY(NM_RETURN, IDC_SEARCHFOR, OnAdd1)
	ON_NOTIFY(NM_DBLCLK, IDC_SEARCHLIST, OnAdd2)
	ON_NOTIFY(NM_RETURN, IDC_SEARCHLIST, OnAdd2)
	ON_BN_CLICKED(IDC_CLEAR, OnClear)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()



该代码在VC5中编译,但在VC2005中编译.

有人可以指出正确的方向吗?

在此先感谢
Tim



The code compiles in VC5, but not VC2005.

Can someone please point me in the right direction?

Thanks in advance
Tim

推荐答案

ON_NOTIFY的处理函数的原型已更改.您应该从
更改功能原型
void CSearchPedsDlg::FunName()


void CSearchPedsDlg::FunName(NMHDR* pNmhdr,LRESULT *lResult )
The protoype of handler function of ON_NOTIFY has changed. you should change the function proto from

void CSearchPedsDlg::FunName()
to

void CSearchPedsDlg::FunName(NMHDR* pNmhdr,LRESULT *lResult )


伙计,MFC很丑.我忘记了.

我将删除有问题的事件,然后使用IDE再次将它们连接起来,期望它将使用您现在升级到的版本中更喜欢使用MFC的任何东西来连接它们. VC5-哇,这是一个了不起的飞跃.
Man, MFC is ugly. I had forgotten.

I would remove the events in question, then use the IDE to hook them up again, expecting that it would hook them up using whatever MFC prefers to use in the version you''re now upgrading to. VC5 - wow, that''s a stellar leap.


这篇关于C ++编译错误-消息映射的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆