MESSAGE在x64编译时生成错误

MESSAGE在x64编译时生成错误

本文介绍了WM_MESSAGE在x64编译时生成错误。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(使用Visual Studio 2012,与VS2015的行为相同)



我想用一个简单的WM_MESSAGE处理程序做一个简单的64位MFC对话框应用程序。



这就是我所做的。



1.打开VS2012

2.创建基于MFC对话框的新应用程序。 (默认为32位)

3.添加我的消息处理程序代码(WM_MESSAGE和处理程序代码)

4.编译:一切正常。

5添加新的x64配置(从基础win32开始)

6.编译:WM_MESSAGE上的编译错误



 1> ------ Build build:Project:MFCApplication1,Configuration:Release x64 ------ 
1> MFCApplication1Dlg.cpp
1> MFCApplication1Dlg.cpp( 66 ):错误C2440:' static_cast':无法转换为' HRESULT(__ cdecl CMFCApplication1Dlg :: * )(WPARAM,LPARAM)'' LRESULT(__ cdecl CWnd :: *)(WPARAM,LPARAM) '
1>在范围内名称的所有函数都不匹配目标类型





相关代码:



 BEGIN_MESSAGE_MAP(CMFCApplication1Dlg,CDialogEx)
...
ON_MESSAGE(WM_MY_MESSAGE,MyMessageHandle)
END_MESSAGE_MAP()





  class  CMFCApplication1Dlg: public  CDialogEx 
{
// ...
HRESULT MyMessageHandle(WPARAM wParam,LPARAM lParam);
// ...
};





 HRESULT CMFCApplication1Dlg :: MyMessageHandle(WPARAM wParam,LPARAM lParam)
{
return 0 ;
}





处理程序签名似乎没问题。 ( HRESULT f(WPARAM,LPARAM)),消息地图看起来没问题。



有很多消息像在互联网上,但它们都与糟糕的处理程序原型有关(通常来自旧的Visual Studio移植)。



任何我可能忽略的想法?



我有点难过。



谢谢。

Max 。

解决方案

(using Visual Studio 2012, same behaviour with VS2015)

I wanted to do a simple 64 bit MFC dialog application with a simple WM_MESSAGE handler.

This is what I did.

1. Open VS2012
2. Create new MFC dialog based application. (default is 32bit)
3. Add my message handler code (WM_MESSAGE and handler code)
4. Compile: All OK.
5. Add new x64 configuration (from base win32)
6. Compile: Compilation error on WM_MESSAGE

1>------ Build started: Project: MFCApplication1, Configuration: Release x64 ------
1>  MFCApplication1Dlg.cpp
1>MFCApplication1Dlg.cpp(66): error C2440: 'static_cast' : cannot convert from 'HRESULT (__cdecl CMFCApplication1Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__cdecl CWnd::* )(WPARAM,LPARAM)'
1>          None of the functions with this name in scope match the target type



The related code:

BEGIN_MESSAGE_MAP(CMFCApplication1Dlg, CDialogEx)
...
	ON_MESSAGE(WM_MY_MESSAGE, MyMessageHandle )
END_MESSAGE_MAP()



class CMFCApplication1Dlg : public CDialogEx
{
//...
	HRESULT MyMessageHandle(WPARAM wParam, LPARAM lParam );
//...
};



HRESULT CMFCApplication1Dlg::MyMessageHandle(WPARAM wParam, LPARAM lParam )
{
	return 0;
}



Handler signature seems to be OK. ( HRESULT f(WPARAM, LPARAM) ), Message Map looks ok.

There are tons of messages like that on the internets, but they all related to having a bad handler prototype (usually from porting from an older Visual Studio).

Any idea that I might have overlooked ?

I'm kind of stumped.

Thanks.
Max.

解决方案


这篇关于WM_MESSAGE在x64编译时生成错误。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 17:30