请教高手,定时器TIMER问题
部分程序如下:
 case WM_CREATE: 
  // Start the timer. 
  idTimer=SetTimer(hWnd, 1, 100, NULL); 
  break;
 case WM_TIMER://定时器消息
   DrawEls();
  break;我的定时器就是不工作,WM_TIMER事件根本就没有发生,这是什么原因。请高手作答。

解决方案 »

  1.   

    不行啊,我的这段程序是在
    LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
    {
    int wmId, wmEvent;
    //PAINTSTRUCT ps;
    //HDC hdc;
    TCHAR szHello[MAX_LOADSTRING];
    LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) 
    {

            case WM_CREATE: 
     
                // Calculate the starting point.             // Start the timer. 
     
                idTimer=SetTimer(hWnd, 100, 100 ,NULL);      break;
    case WM_TIMER://定时器消息
         DrawEls();
     break;
    }
    要是改成SetTimer(this,100,100,NULL);
    编译时会出错如下
    error C2673: 'WndProc' : global functions do not have 'this' pointers
      

  2.   

    你有发送消息WM_CREATE了吗?执行
            case WM_CREATE: 
     
                // Calculate the starting point.             // Start the timer. 
     
                idTimer=SetTimer(hWnd, 100, 100 ,NULL); 
    这段语句了吗?
      

  3.   

    UINT SetTimer( UINT nIDEvent, UINT nElapse, void (CALLBACK EXPORT* lpfnTimer)(HWND, UINT, UINT, DWORD) );所以就写:idTimer=SetTimer(100, 100 ,NULL); 其中,第一个100是:nIDEvent=100