void TApp::Idle(DWORD timeout) { TApp *app = TApp::GetApp(); DWORD start = GetTickCount(); MSG msg; while (::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { if (app->PreProcMsg(&msg)) continue; ::TranslateMessage(&msg); ::DispatchMessage(&msg); if (GetTickCount() - start >= timeout) break; } }