I am trying to build a MFC Visual Studio 6.0 project in Visual Studio 2010. The compiler gives me an error:
error C2440: 'static_cast' : cannot convert from 'void (__thiscall ProgressDialog::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
//--------------------------------- // Message map
BEGIN_MESSAGE_MAP(ProgressDialog, CDialog) ON_BN_CLICKED(IDC_CANCEL, OnCancelClicked) ON_MESSAGE(MSG_FINISHED, OnFinished) END_MESSAGE_MAP()
Any suggestions - ?
Pedro
Change your ON_MESSAGE macro to ON_MESSAGE_VOID. The ON_MESSAGE macro returns a LRESULT from receiving WPARAM and LPARAM arguments. Your compiler error message states that your OnFinished() method is void arguments returning void. That's what the ON_MESSAGE_VOID macro handles.
ADDITION:
Refer to bottom of C++ Q & A -- Microsoft Systems Journal July 1999
There were breaking changes in MFC7.0, including:
Your
ProgressDialog::OnFinished
method needs to now return anLRESULT
.