Denis Adamchuk
2008-09-08 09:12:00 UTC
Hi everyone,
I'm writing an application where Windows messages are used in a special
manner and want to clarify how flexible is access to the thread message queue.
I've read the MSDN article about PeekMessage and many web sites where
different opinions are expressed. My questions are the following...
1) What really does PeekMessage()?
Does it process messages sent from other threads by means of
SendMessage-family routines or just picks a message from the queue (or from
where?) and give me a chance to analyze it and process it by myself?
2) Does PeekMessage process ALL sent messages that are available now or only
one of them?
3) According to the MSDN - PeekMessage() does both things I've mentioned
above.
But what do wMsgFilterMin and wMsgFilterMax arguments mean?
Does PeekMessage pick from the queue messages from identifiers from the
range or does it process only such messages sent to the current thread?
4) The most confusing one :)
What is tuned by PM_QS_*** flags - behavior for implicit message processing
or behavior for message picking?
If PM_QS*** define what messages I want to proceed why there are any flags
except the PM_QS_SENDMESSAGE (since PeekMessage() is devoted to process only
SendMessage() messages)?
Otherwise if PM_QS*** define what messages I want to pick why there is the
PM_QS_SENDMESSAGE flag if the messages that were sent will be processed
implicitly and I never get them as a result?
5) PeekMessage() does not fill lpMsg output parameter with a message(s) it
has processed?
6) Is it possible to disable an implicit message processing inside
PeekMessage() and make it to return as lpMsg messages that were sent from
another threads via SendMessage-routines BUT only within a defined range?
7) What is PM_NOYIELD?
Thanks in advance!
It will be great if this post become a consolidated place of information
about PeekMessage() for those who search...
I'm writing an application where Windows messages are used in a special
manner and want to clarify how flexible is access to the thread message queue.
I've read the MSDN article about PeekMessage and many web sites where
different opinions are expressed. My questions are the following...
1) What really does PeekMessage()?
Does it process messages sent from other threads by means of
SendMessage-family routines or just picks a message from the queue (or from
where?) and give me a chance to analyze it and process it by myself?
2) Does PeekMessage process ALL sent messages that are available now or only
one of them?
3) According to the MSDN - PeekMessage() does both things I've mentioned
above.
But what do wMsgFilterMin and wMsgFilterMax arguments mean?
Does PeekMessage pick from the queue messages from identifiers from the
range or does it process only such messages sent to the current thread?
4) The most confusing one :)
What is tuned by PM_QS_*** flags - behavior for implicit message processing
or behavior for message picking?
If PM_QS*** define what messages I want to proceed why there are any flags
except the PM_QS_SENDMESSAGE (since PeekMessage() is devoted to process only
SendMessage() messages)?
Otherwise if PM_QS*** define what messages I want to pick why there is the
PM_QS_SENDMESSAGE flag if the messages that were sent will be processed
implicitly and I never get them as a result?
5) PeekMessage() does not fill lpMsg output parameter with a message(s) it
has processed?
6) Is it possible to disable an implicit message processing inside
PeekMessage() and make it to return as lpMsg messages that were sent from
another threads via SendMessage-routines BUT only within a defined range?
7) What is PM_NOYIELD?
Thanks in advance!
It will be great if this post become a consolidated place of information
about PeekMessage() for those who search...