Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 855
  • Last Modified:

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
0
James Atkin
Asked:
James Atkin
  • 2
1 Solution
 
waysideCommented:
Try changing ON_MESSAGE in your message map to ON_THREAD_MESSAGE.
0
 
waysideCommented:
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.
0
 
James AtkinSenior Principle Software EngineerAuthor Commented:
Excellent...

Thanks for the exceptionally fastest response!

James
0

Featured Post

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now