Solved

AfxMessgeBox "eats" thread messages

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

757 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

16 Experts available now in Live!

Get 1:1 Help Now