关于版本visual studio或函数声明的错误 [英] Error regarding version visual studio or function declaration
本文介绍了关于版本visual studio或函数声明的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨!
我要将visual studio 2006项目转换为visual studio 2008但是按钮点击事件发生了一些错误
在头文件函数中声明为
afx_msg int OnOk();
在.cpp文件消息地图中声明为
ON_BN_CLICKED(IDC_OK ,OnOk)// ON_BN_CLICKED(IDC_OK(Control_Name),OnOk(Event_Name))
&最后定义为
Hi!
I am going to convert visual studio 2006 project to visual studio 2008 but there is some error occured for button click event
In Header file function declared as
afx_msg int OnOk();
In .cpp file message map it declared as
ON_BN_CLICKED(IDC_OK, OnOk)//ON_BN_CLICKED(IDC_OK(Control_Name), OnOk(Event_Name))
& at last it defined as
int communication::OnOk()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
{
//Some code
}
return 0;
}
错误显示: -
Error shows that:-
error C2440: 'static_cast' : cannot convert from 'int (__thiscall communication::* )(void)' to 'AFX_PMSG'
什么是解决方案?
What is solution for that?
推荐答案
AFX_PMSG
定义为public typedef void(CCmdTarget :: * AFX_PMSG)(void)
这意味着返回类型为void。
AFX_PMSG
is defined aspublic typedef void( CCmdTarget::* AFX_PMSG )( void )
That means the return type is void.
尝试将返回类型从int更改为void。通常OnOK不会返回我认为的任何内容(自从您的旧项目版本以来可能在框架中发生了变化)。顺便说一下这个CDialog类?如果是,那肯定是无效的返回类型
Try changing the return type from int to void. Usually OnOK does not return anything I believe (might have changed in the framework since your old project version). Btw is this CDialog class? If yes, it definitely has to be void return type
这篇关于关于版本visual studio或函数声明的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文