UINT SetTimer(
  HWND hWnd,              // handle of window for timer messages
  UINT nIDEvent,          // timer identifier
  UINT uElapse,           // time-out value
  TIMERPROC lpTimerFunc   // address of timer procedure
);自己新建一个.cpp文件,里面需用到定时器,当定时时间到时去执行相应的函数:
HWND m_hWnd;
SetTimer(m_hWnd,1,Sec,AfxBeginThread(con_RecvThread, &concentrator)); 
其中AfxBeginThread(con_RecvThread, &concentrator)是当定时到时,所要执行的函数,它在另一个.cpp中。请问m_hWnd是什么?我应该怎样获得? 我现在的错误是:error C2660: 'SetTimer' : function does not take 4 parameters执行 cl.exe 时出错.    请高手指点呀!

解决方案 »

  1.   

    不是基于对话框的,应该每个类都可以拥有error C2660: 'SetTimer' : function does not take 4 parameters大致意思是,SetTimer 没有4个参数的类型的函数
    如果是对话框类中就不需要第一个参数的句柄如果楼主是用VS系列的编译器,可以看一下智能提示,有多少个参数,一般设置定时器是这样使用的: // 启动定时器
    SetTimer( 2 , 1000 , NULL );
      

  2.   

    m_hWnd是窗口句柄.如果是对话框程序的话,添加消息映射就行,这个参数不用输入的.如不是,换个函数吧.GetTickCount,timeSetEvent,QueryPerformanceFrequency, QueryPerformanceCounter等.
      

  3.   

    SetTimer(m_hWnd,1,Sec,AfxBeginThread(con_RecvThread, &concentrator));的第四个参数数就是线程函数,第一个参数应该怎样写呢?是不是NULL就可以了?
      

  4.   

    这个是API的定义CWnd类中已经做了重载
    http://msdn.microsoft.com/en-us/library/49313fdf(v=vs.80).aspx
      

  5.   

    从错误信息上看现在的错误是:error C2660: 'SetTimer' : function does not take 4 parameters执行 cl.exe 时出错. 请高手指点呀!
    直接用
    SetTimer(1,Sec,AfxBeginThread);
    不过函数AfxBeginThread的原型不对,应该是VOID CALLBACK TimerProc(
      HWND hwnd,     // handle of window for timer messages
      UINT uMsg,     // WM_TIMER message
      UINT idEvent,  // timer identifier
      DWORD dwTime   // current system time
    );