BOOL PeekAndPump()
{
static MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return FALSE;
}
}
return TRUE;
}
本文介绍了一个使用PeekMessage和PumpMessage实现的消息泵循环处理函数BOOLPeekAndPump()。该函数通过不断检查是否有待处理的消息,并调用PumpMessage进行消息处理,实现了应用程序的消息循环,直到接收到退出消息。
BOOL PeekAndPump()
{
static MSG msg;
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE))
{
if (!AfxGetApp()->PumpMessage())
{
::PostQuitMessage(0);
return FALSE;
}
}
return TRUE;
}

被折叠的 条评论
为什么被折叠?
