vc 如何改错

来源:百度知道 编辑:UC知道 时间:2024/06/22 11:50:30
error C2440: 'type cast' : cannot convert from '' to 'void (__stdcall *)(unsigned int,unsigned int,unsigned long,unsigned long,unsigned long)'
None of the functions with this name in scope match the target type
error C2065: 'MyMess' : undeclared identifier

原代码:if((TimerID_10ms = timeSetEvent(wTimerRes_10ms, wAccuracy,(LPTIMECALLBACK)TenMilliSecondProc, // 回调函数
(DWORD)(1), // 用户传送到回调函数的数据;
TIME_PERIODIC)) == 0)//周期调用定时处理函数
{
AfxMessageBox("不能计时"); }

void PASCAL TenMilliSecondProc(int timerID,int msg,DWORD dwUser,DWORD dw1,DWORD dw2)
{

MyMess();

}

MyMess()在开始时有定义过:
class CMy123Dlg : public CDialog
{

// Construction
public:
double MyMess();

不知错在何处?急

MyMess()是一个类中的成员函数吧?那么你在调用时,应该使用“.”操作符通知编译器它是某个类中的成员,如果直接写
MyMess();
编译器会把它当作一个普通函数,非类的成员,如果你没有声明过,当然编译器不知道了。
所以应该这么写:
XXX.MyMess();
其中XXX是CMy123Dlg类的一个对象。

下面是我的学习笔记中的一部分,你看看吧,讲的是__stdcall与__cdecl的区别。也许能解决你的问题。
------------------
LRESULT CALLBACK WinSunProc(//LRESULT 长整型的结果码.
#define CALLBACK __stdcall //标准调用约定,也是Pascal调用约定 ,在参数的传递顺序与堆站的请除有差异.”__stdcall()”是API函数 注意带下划线的函数前的下划线是两横不是一横
#define PASCAL __stdcall
#define WINAPIV __cdecl //C语言调用约定//编译时默认的函数
因编译器默认的约定是__cdecl,而标准的(绝大多数函数)约定是__stdcall,因此在声明函数时,要用__stdcall来声明.至于CALLBACK是助记符.注意两种不同的语言代码移植是特别要注意.如从C向C++移植.