Resurrecting MFC/Visual Studio 6.0 project in VS20

2019-06-24 00:03发布

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

2条回答
我想做一个坏孩纸
2楼-- · 2019-06-24 00:29

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

查看更多
我欲成王,谁敢阻挡
3楼-- · 2019-06-24 00:33

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.

查看更多
登录 后发表回答