MsgWaitForMultipleObjects The MsgWaitForMultipleObjects function returns when one of the following occurs: Either any one or all of the specified objects are in the signaled state. The objects can include input event objects, which you specify using the dwWakeMask parameter. The time-out interval elapses. DWORD MsgWaitForMultipleObjects( DWORD nCount, // number of handles in array CONST HANDLE pHandles, // object-handle array BOOL fWaitAll, // wait option DWORD dwMilliseconds, // time-out interval DWORD dwWakeMask // input-event type ); dwWakeMask choose QS_ALLINPUT
The MsgWaitForMultipleObjects function returns when one of the following occurs:
Either any one or all of the specified objects are in the signaled state. The objects can include input event objects, which you specify using the dwWakeMask parameter.
The time-out interval elapses. DWORD MsgWaitForMultipleObjects(
DWORD nCount, // number of handles in array
CONST HANDLE pHandles, // object-handle array
BOOL fWaitAll, // wait option
DWORD dwMilliseconds, // time-out interval
DWORD dwWakeMask // input-event type
);
dwWakeMask choose QS_ALLINPUT
在CB中,只要在循环中加上一句:
Application->ProcessMessages();
即可,不知道VC中是否可以同样实现,(这么简单的功能我不想用多线程)
While(::GetMessage(&message,NULL,0,0)){
::TranslateMessage(&message);
::DispatchMessage(&message);
}还可以用PeekMessage
MSG msg ;
::PeekMessage(&msg, NULL, 0, 0, PM_REMOVE));
::DispatchMessage(&msg) ;
试试。