Can it be done? I am not familiar enough with the queue servicing
functions. They all seem to have little catch-22's that make me hesitant to
fill in the empty "else" clause below.
BOOL MyWaitWithMessageLoop(HANDLE hEvent) {
MSG msg;
DWORD dwWaitResult;
while ( TRUE ) {
dwWaitResult = MsgWaitForMultipleObjects(1, &hEvent, FALSE,
INFINITE, QS_SENDMESSAGE | QS_POSTMESSAGE);
if ( dwWaitResult == WAIT_OBJECT_0 ) return TRUE;
else {
/* empty the queue; check for WM_QUIT */
}
}
}
For example, I am tempted to say
while ( PeekMessage(&msg, hWndMe, 0, 0, TRUE) {
if ( msg.message == WM_QUIT ) return FALSE;
DispatchMessage(&msg);
}
but I read that PeekMessage() **automatically** dispatches 'sent' messages.
I also read, of GetQueueStatus(), that "The presence of a QS_ flag in the
return value does not guarantee that a subsequent call to the GetMessage or
PeekMessage function will return a message" and that makes me hesitant to
use GetQueueStatus(). How can I finish off this emulation of
AtlWaitWithMessageLoop()? Thanks.
Note that my window needn't worry about any input, timers, or anything that
deals with it's being shown (it's never shown).
--
- Vince