单线程做比较耗CPU的进度条显示

  当在一个线程中做识别或者比较耗时的运算时,往往UI不能及时的刷新,这样进度条就不能正常工作.

可以采用一下方法,每次运算完一次就调用下面:

void DoEvents()
{
    MSG msg;
    if (::PeekMessage(&msg,NULL,0,0,PM_REMOVE)) { //′óWindows???¢?óáD?Dè?3????¢
        if (msg.message== WM_QUIT)//è?1????¢?aí?3?£?·¢?íí?3????¢
        {
            ::PostQuitMessage(-1);
        }
        if(!AfxGetApp()->PreTranslateMessage(&msg))//è?1??T·¨?¤′|àí???¢
        {
            ::TranslateMessage(&msg);//×a?????¢
            ::DispatchMessage(&msg);//·¢?í???¢
        }
    }
    AfxGetApp()->OnIdle(0);AfxGetApp()->OnIdle(1);//???¢?óáD?a??ê±?D??ò???ê±??
}

你可能感兴趣的:(工作,UI,null)