Link to home
Start Free TrialLog in
Avatar of Member_2_99151
Member_2_99151

asked on

Error 13 error C2440 when converting MFC6 app to MFC8...

I have an old MFC6 application that i have ported across to MFC 8 (2005).

It fails compilation with the following message

Error 13 error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CMyAppName::* ) (WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' d:\source\MyApp\app1.cpp 164

The CPP file has the following:
ON_MESSAGE(WM_MYMESSAGE1, OnMyMessage1)
and
LRESULT CMyAppName::OnMyMessage1(WPARAM wParam, LPARAM lParam)
{
   ULONG p1 = static_cast<ULONG> ( wParam );
   ULONG p2 = static_cast<ULONG> ( lParam );
   ...
}

the Header file has the following:
afx_msg LRESULT OnMyMessage1(WPARAM wParam, LPARAM lParam);
There are words about this all over the internet but no simple step guides as to how to convert it!

Any help would be appreciated.

Best regards,

James
ASKER CERTIFIED SOLUTION
Avatar of wayside
wayside

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wayside
wayside

You'll probably have to change your function to

afx_msg void OnMyMessage1(WPARAM wParam, LPARAM lParam); // <- doesn't return anything

If you have to have a return value, only solution I see is to push this function into a class that derives from CWnd.
Avatar of Member_2_99151

ASKER

Excellent...

Thanks for the exceptionally fastest response!

James