本文整理汇总了C++中CWinApp::PumpMessage方法的典型用法代码示例。如果您正苦于以下问题:C++ CWinApp::PumpMessage方法的具体用法?C++ CWinApp::PumpMessage怎么用?C++ CWinApp::PumpMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWinApp
的用法示例。
在下文中一共展示了CWinApp::PumpMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessGUIMessages
virtual void ProcessGUIMessages()
{
// Adapted from MFC's CWinThread::Run() (thrdcore.cpp).
_AFX_THREAD_STATE* pState = AfxGetThreadState();
CWinApp* pApp = AfxGetApp();
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(&pState->m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// call OnIdle while in bIdle state
if (!pApp->OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
}
// phase2: pump messages while available
while (::PeekMessage(&pState->m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{
// pump message, but quit on WM_QUIT
if (!pApp->PumpMessage())
{
Terminate();
pApp->ExitInstance();
}
}
::Sleep(0);
}
示例2: ShMsgPump
void ShMsgPump()
{
// if we do MFC stuff in an exported fn, call this first!
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
DWORD dInitTime = GetTickCount();
MSG m_msgCur; // current message
CWinApp *pWinApp = AfxGetApp();
while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE) &&
(GetTickCount() - dInitTime < 200) )
{
pWinApp->PumpMessage();
}
}