我若直接用SetTimer(1,100,NULL) 报错

解决方案 »

  1.   

    就是大红叉  Debug Assertion Failed!
      

  2.   

    不可能啊  我没做什么事呢还
    运行到SetTimer(1,100,NULL);
    就这样了 单步调试时可以看见
      

  3.   

    我想 可能是因为 不是在窗口对应的CView类下 操作 的原因吧
      

  4.   

    OnTimer 肯定没问题
    只是一句MessageBox况且它还运行不到OnTimer
    只是到SetTimer就运行不下去了
      

  5.   

    运行到SetTimer了,不就调用OnTimer了?
      

  6.   

    中间不是还要等一会那么 
    再说 OnTimer里就一句话 绝对没问题啊
      

  7.   

    CTestView::OnDraw(CDC *pDC)
    {CGOODDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    // TODO: add draw code for native data here
       Ctime t;
       t.OnDraw(pDC);
    }
    Ctime::OnDraw(CDC *pDC)
    {
       CDocument* pDoc = GetDocument();
    // TODO: add draw code here
       SetTimer(1,100,NULL);
    }
    void Ctime::OnTimer(UINT nIDEvent) 
    {
    // TODO: Add your message handler code here and/or call default
    MessageBox("gggg");
    CScrollView::OnTimer(nIDEvent);
    }
    //class Ctime : public CScrollView
      

  8.   

    OnDraw()函数是一个多次调用的函数,在你程序初始化时已经调用了一次OnDraw(),也就已经
    用第一个计数器了,确保你OnDraw第二次执行时第一个计时器资源已经释放了,可以在
    SetTimer(1,100,NULL)前加上KillTimer(1)函数。