Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
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()


The code compiles in VC5, but not VC2005.

Can someone please point me in the right direction?

Thanks in advance
Tim
Posted
Updated 5-Jan-10 18:16pm
v2

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 )
 
Share this answer
 
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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900