Re: CWinThread Can't Receive Custom Message in some case
- From: "Jason .Y" <lin.yang.jason@xxxxxxxxx>
- Date: Mon, 14 Sep 2009 20:16:02 -0700 (PDT)
On 9月14日, 下午9时15分, "Doug Harrison [MVP]" <d....@xxxxxxxx> wrote:
PRB: PostThreadMessage Messages Lost When Posted to UI Threadhttp://support.microsoft.com/kb/183116
Also, if you're going to use thread messages, you can start numbering them
anywhere. Basing them on WM_USER is kinda strange :) For more on what the
message ranges mean, see:
Which message numbers belong to whom?http://blogs.msdn.com/oldnewthing/archive/2003/12/02/55914.aspx
That said, it's a good idea to keep the UI all in one thread, your
program's main thread. Presumably, it has some sort of window that could be
the target for all your custom WM_APP-based messages. If not, you can
create a hidden message-only window for this purpose.
--
Doug Harrison
Visual C++ MVP
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.
----
Jason
.
- Follow-Ups:
- Re: CWinThread Can't Receive Custom Message in some case
- From: Doug Harrison [MVP]
- 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]
- 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: is there any good libray for printing preview in MFC ?
- 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
|