Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
2.60/5 (2 votes)
See more:
I am getting
JavaScript
error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CMyApp::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'


The code in my header file looks like:
C++
class CMyApp : public CWinApp
{
public:
	LRESULT OnMsg28(WPARAM, LPARAM); 


The code in the program looks like:
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
//{{AFX_MSG_MAP(CMyApp)
ON_MESSAGE(WM_MSG28, OnMsg28)

and


C#
LRESULT CMyApp::OnMsg28( WPARAM wParam, LPARAM lParam ) 
{
	static int	zero=0, one=1;
	int			rc;

<code>
	return 0;
}




I have used code like this many times in the past but this is the first time I am running into this problem. I googled this and tried several suggestions but ended up with the same results.
Posted
Comments
Sergey Alexandrovich Kryukov 10-Dec-15 21:53pm    
First of all, what makes you thinking that you can typecast between those types?
—SA

The answer is right in the error message. Cannot convert from CMyApp to CWnd.
 
Share this answer
 
See https://msdn.microsoft.com/en-us/library/k35k2bfs.aspx[^]. Windows messages are sent to Windows, not to applications. In MFC this means that your messages need to be handled by a class derived from CWnd.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900