Re: How does PeekMessage really work?
On Tue, 9 Sep 2008 09:39:01 -0700, Denis Adamchuk
<DenisAdamchuk@discussions.microsoft.com> wrote:
Malachy, thanks for your explanation.
I've carefully read the article by Raymond.
In the OldNewThing discussion I found a similar question about inter-thread
sent messages which are kept in a "separate place". This one is very
important for me now but it is still unanswered:
"Can I retrieve sent messages as if they were posted messages, and then
dispatch them? I would like to be able to filter out, for example, Shatter
attacks. "
In other words I would like to disable sent messages to be processed
(dispatched) within PeekMessage or allow it only for group of messages
(filter by ID).
I think those are two different questions. I don't know how to accomplish
the former (maybe a message hook?), but you're supposed to be able to
accomplish the latter with PeekMessage. Note that it won't help with MFC's
or Windows' internal GetMessage loops, use of WaitMessage, etc.
I suppose the root cause of my confusion is the PM_QS_SENDMESSAGE.
I still don't understand how this flag affect the PeekMessage() execution.
In my application PeekMessage() delivers sent messages to the WndProc in the
both cases:
::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);
::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_QS_SENDMESSAGE);
Moreover, when I set all PM_QS_* flags except PM_QS_SENDMESSAGE
PeekMessage() does the same.
Yeah, the documentation is confusing, because the default is to process
sent messages! It may be that specifying nothing processes everything,
while if you specify PM_QS_POSTMESSAGE, you will suppress the processing of
sent messages. Are you sure that:
::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE | PM_QS_POSTMESSAGE);
processes pending interthread sent messages?
--
Doug Harrison
Visual C++ MVP