Re: CWinThread Can't Receive Custom Message in some case
- From: "Doug Harrison [MVP]" <dsh@xxxxxxxx>
- Date: Tue, 15 Sep 2009 00:05:45 -0500
On Mon, 14 Sep 2009 20:16:02 -0700 (PDT), "Jason .Y"
<lin.yang.jason@xxxxxxxxx> wrote:
Thank you very much for your help!
but I still have a question:according to the article <PRB:
PostThreadMessage Messages Lost When Posted to UI Thread>, all the
message send to a UI thread by PostThreadMessage would be lost when
the UI Thread is showing a modal dialog box.
"When an UI thread is involved in modal behavior, the thread pumps
messages in a message loop internal to the modal system rather than in
the thread's main message loop. Messages that are posted to a window
can still be dispatched to the window procedure of the target window,
because the messages are associated with a window. However, thread
messages need to be handled directly by the message loop, because they
cannot be automatically dispatched elsewhere. Since the secondary
message loop does not know about the thread message, it will be
dropped."
but in fact,the message won't be lost if I don't manipulate the dialog
very frequently. then I'm comfused:why message send by
PostThreadMessage would not get lost in this situation?As the message
loop internal to the modal dialog is the primary message loop.the
thread message should be drop.
IIRC, MFC runs its own message loop for modal dialogs, and it must be
handling thread messages in some way. I stopped using thread messages a
long time ago, and I don't remember how MFC handles them. You can set a
breakpoint on your message handler, and looking at the function call stack
in the debugger will tell you how you got there. As for the messages being
lost when you "manipulate" the dialog, that must be due to Windows running
a secondary message loop per the KB article.
--
Doug Harrison
Visual C++ MVP
.
- Follow-Ups:
- Re: CWinThread Can't Receive Custom Message in some case
- From: Jason .Y
- Re: CWinThread Can't Receive Custom Message in some case
- References:
- CWinThread Can't Receive Custom Message in some case
- From: Jason .Y
- Re: CWinThread Can't Receive Custom Message in some case
- From: Doug Harrison [MVP]
- Re: CWinThread Can't Receive Custom Message in some case
- From: Jason .Y
- CWinThread Can't Receive Custom Message in some case
- Prev by Date: Re: is there any good libray for printing preview in MFC ?
- Next by Date: Re: CWinThread Can't Receive Custom Message in some case
- Previous by thread: Re: CWinThread Can't Receive Custom Message in some case
- Next by thread: Re: CWinThread Can't Receive Custom Message in some case
- Index(es):
Relevant Pages
|