我得到了“错误C2440:'static_cast':无法从'LRESULT'转换等等 [英] I'm getting "error C2440: 'static_cast' : cannot convert from 'LRESULT" etc

查看:320
本文介绍了我得到了“错误C2440:'static_cast':无法从'LRESULT'转换等等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在

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:

class CMyApp : public CWinApp
{
public:
	LRESULT OnMsg28(WPARAM, LPARAM); 





程序中的代码如下:

BEGIN_MESSAGE_MAP(CMyApp,CWinApp)

// {{AFX_MSG_MAP(CMyApp)

ON_MESSAGE(WM_MSG28,OnMsg28)











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

and


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

<code>
	return 0;
}









我用的是这样的代码过去很多次,但这是我第一次遇到这个问题。我用Google搜索并尝试了几个建议,但结果却相同。





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.

推荐答案

答案在错误信息中是正确的。无法从CMyApp转换为CWnd。
The answer is right in the error message. Cannot convert from CMyApp to CWnd.


请参阅 https:// msdn .microsoft.com / zh-CN / library / k35k2bfs.aspx [ ^ ]。 Windows消息将发送到Windows,而不是应用程序。在MFC中,这意味着您的消息需要由派生自 CWnd 的类处理。
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.


这篇关于我得到了“错误C2440:'static_cast':无法从'LRESULT'转换等等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆