开发者

mfc event doesn't get called while afxMessageBox is open

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜