Reputation: 1565
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
Upvotes: 6
Views: 2453
Reputation: 6040
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
Upvotes: 9
Reputation: 2651
There were breaking changes in MFC7.0, including:
The function parameter in the
ON_MESSAGE
macro must match the type
afx_msg LRESULT (CWnd::*)(WPARAM, LPARAM)
Your ProgressDialog::OnFinished
method needs to now return an LRESULT
.
Upvotes: 1