Solved

AfxMessgeBox "eats" thread messages

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Prevent this page from creating additional dialogs. 3 523
FizzBuzz challenge 9 80
mapBully challenge 6 127
mapAB Challlenge 35 143
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

786 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