Click here to Skip to main content
15,897,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi!
I am going to convert visual studio 2006 project to visual studio 2008 but there is some error occured for button click event
In Header file function declared as
afx_msg int OnOk();

In .cpp file message map it declared as
ON_BN_CLICKED(IDC_OK, OnOk)//ON_BN_CLICKED(IDC_OK(Control_Name), OnOk(Event_Name))

& at last it defined as
C#
int communication::OnOk()
{
    // TODO: Add your control notification handler code here
    UpdateData(TRUE);
   {
           //Some code
   }
    return 0;
}


Error shows that:-
VB
error C2440: 'static_cast' : cannot convert from 'int (__thiscall communication::* )(void)' to 'AFX_PMSG'

What is solution for that?
Posted

AFX_PMSG is defined as public typedef void( CCmdTarget::* AFX_PMSG )( void )

That means the return type is void.
 
Share this answer
 
Try changing the return type from int to void. Usually OnOK does not return anything I believe (might have changed in the framework since your old project version). Btw is this CDialog class? If yes, it definitely has to be void return type
 
Share this answer
 

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



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