你可以看看CWinApp::Run(),你可能会重载它。但你要加什么代码?

解决方案 »

  1.   

    重载CWinApp::OnIdle()
    例子:
    BOOL CMyApp::OnIdle(LONG lCount)
    {
       // In this example, as in most applications, you should let the
       // base class CWinApp::OnIdle complete its processing before you
       // attempt any additional idle loop processing.
       if (CWinApp::OnIdle(lCount))
          return TRUE;      // The base class CWinApp::OnIdle reserves the lCount values 0 
       // and 1 for the framework's own idle processing.   If you wish to
       // share idle processing time at a peer level with the framework,
       // then replace the above if-statement with a straight call to
       // CWinApp::OnIdle; and then add a case statement for lCount value
       // 0 and/or 1. Study the base class implementation first to 
       // understand how your idle loop tasks will compete with the 
       // framework's idle loop processing.   switch (lCount)
       {
          case 2:
             Task1();
             return TRUE; // next time give Task2 a chance
          case 3:
             Task2();
             return TRUE; // next time give Task3 and Task4 a chance
          case 4:
             Task3();
             Task4();
             return FALSE; // cycle through the idle loop tasks again
       }
       return FALSE;
    }