Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Resurrecting MFC/Visual Studio 6.0 project in VS2010

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

like image 479
OneGuyInDc Avatar asked May 16 '12 11:05

OneGuyInDc


2 Answers

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

like image 198
Joseph Willcoxson Avatar answered Nov 15 '22 06:11

Joseph Willcoxson


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.

like image 25
PhilMY Avatar answered Nov 15 '22 08:11

PhilMY