Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

PostThreadMessage problem

62 views
Skip to first unread message

Gaffer

unread,
Feb 12, 2002, 5:13:08 PM2/12/02
to
I have an MDI application where a secondary thread occasionally uses
PostThreadMessage() to notify the main application thread of an event.
The main thread's message map uses ON_THREAD_MESSAGE to route the
message to the handler function.

This works fine normally, but if a menu is open when the message is
posted, the message never arrives. PostThreadMessage() always returns
non-zero.

Knowledge base article 0142415 addressed a problem which sounded like
mine, but when I override PreTranslateMessage() as in the example, I
find that lost messages never appear there either.

Again, if a menu is open, the message never arrives, but if no menu is
open the message always arrives. PreTranslateMessage sees only those
messages that are posted when no menus are open.

Any ideas?

Thanks,
Gaffer

Doug Harrison [MVP]

unread,
Feb 12, 2002, 5:23:48 PM2/12/02
to
Gaffer wrote:

See this KB article:

http://support.microsoft.com/default.aspx?scid=kb;EN-US;q183116

--
Doug Harrison [VC++ MVP]
Eluent Software, LLC
http://www.eluent.com
Tools for Visual C++ and Windows

Gaffer

unread,
Feb 12, 2002, 11:01:11 PM2/12/02
to
"Doug Harrison [MVP]" <d...@mvps.org> wrote in message news:<m65j6usj4iddh6tqa...@4ax.com>...

Thanks, Doug. That is helpful. Odd that I didn't find it when I did
the search that turned up O142415...

Scott McPhillips

unread,
Feb 12, 2002, 11:09:58 PM2/12/02
to
Gaffer wrote:
>
> I have an MDI application where a secondary thread occasionally uses
> PostThreadMessage() to notify the main application thread of an event.
> ...

As you discovered, that is a fatal mistake. Never PostThreadMessage to
a thread that contains GUI things. Use PostMessage to an HWND.

--
Scott McPhillips [VC++ MVP]

0 new messages