Solved

AfxMessgeBox "eats" thread messages

Posted on 1998-01-07
2
183 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
unable to delete all specified values regedit 38 895
bigDiff challenge 17 144
FizzBuzz challenge 9 87
Work with App store 7 122
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Suggested Courses

751 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