Solved

AfxMessgeBox "eats" thread messages

Posted on 1998-01-07
2
181 Views
Last Modified: 2013-11-20
I have a CWinThread derived class that implements a thread with a message queue.  Other threads post thread messages (hWnd = NULL) to this thread using PostThreadMessage().  Normally everything works fine, but if this thread displays a message box, any thread messages that are posted to it while the message box is displayed, are lost.  Is this the way things should work?  Is there a way not to lose the messages posted while the message box is displayed?
0
Comment
Question by:boreilly
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 200 total points
ID: 1313576
Yes, because it uses its own internal message loop to display the message box. Normally, you do not want to have a worker thread displaying UI objects. If you need this capability, the better thing to do is to not use anything that can bring up its own message loop (i.e. MessageBox or AfxMessageBox). Instead, use a modeless dialog, and if you're using Visual C++ 5.x, then you can also use modal dialogs.


0
 

Author Comment

by:boreilly
ID: 1313577
I would like to give a grade of excellent, but the wording of the answer is not perfectly clear to me.  When you say "Yes, because it uses its own internal message loop", does "it" refer to MessageBox()?  Are you saying that the messagebox functions implement their own message loops? Do they intercept all messages to the thread?

Thank you very much.
Bruce
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 190
ffmpeg - "rtsp://...... Operation not permitted" 4 86
isEverywhere  challenge 19 82
FizzBuzz challenge 9 82
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question