Solved

AfxMessgeBox "eats" thread messages

Posted on 1998-01-07
2
177 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

911 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

Need Help in Real-Time?

Connect with top rated Experts

27 Experts available now in Live!

Get 1:1 Help Now