I have an MFC event. I declare it like this: const UINT WM_SECEVENT = RegisterWindowMessage(_T("My Event")); I raise the event by: ::PostThreadMessageA(dwCurThreadId, WM_SECEVENT, (WPARAM)pMsgParam,0); In my MessageMap, I wrote: ON_REGISTERED_THREAD_MESSAGE(WM_SECEVENT, OnThreadSecEvent);
Everything works fine, when WM_SECEVENT is raised, OnThreadSecEvent starts to run. The problem is, that I also have a yes/no afxMessageBox. While the afxMessageBox is running, my program don't "catch" the event, and OnThreadSecEvent is not开发者_开发问答 getting called. How can I fix that problem?
Thanks
Does posting to a window in the thread instead of to the thread message queue itself work for your purposes?
http://support.microsoft.com/kb/183116
Rather than using PostThreadMessage to post messages to a UI thread, use PostMessage to post messages to a window owned by that thread. Since messages directed to a window can be dispatched by a secondary message loop, the messages is still handled properly, even when the thread is not running in its primary message loop.
精彩评论