Solved

MessageBox in Dialog based app

Posted on 1998-08-01
9
213 Views
Last Modified: 2013-11-19
I'm trying to understand the following behavior.  In an App Wizard generated dialog based app, within the InitInstance() function, I can show a message box before dlg.DoModal() is called,  but after returning, it is not possible to show a message box.  Any call to a message box function after the dialog is dismissed simply does nothing. Could someone explain why.

Thank you,
Bruce O'Reilly
0
Comment
Question by:boreilly
  • 6
  • 2
9 Comments
 
LVL 1

Accepted Solution

by:
chacko earned 100 total points
ID: 1320051
Message Box needs the parent window. In your case after the dialog is shown, there is no more parent available. But if you give the first parameter as NULL, there will be a messagebox created as orphan.
0
 
LVL 2

Expert Comment

by:duneram
ID: 1320052
In a dialog app, the dialog is the main window.  When you close the dialog, the EndDialog is called and in that process the message loop is terminated with a special WM_NULL sent as the last message.

I suspect because you message loop is dead, the dialog app won't let you display anything.  You should do your handling in the OK or Cancel of that dialog (or whatever response code is).

If you were writing a win32 console app, you could display message boxes wherever you want.  I supposed its because you are not using MFC to do the dirty work.  The fact that MFC has put in their window proc handler, but then told it to turn off (It only works if the dialog window handle is valid.  See Wincore.cpp 's
'int CWnd::RunModalLoop(DWORD dwFlags)'

would imply the system one may not be being called in this instance.
0
 
LVL 2

Expert Comment

by:duneram
ID: 1320053
that's a wrong answer.    Specifiying NULL is actually the desktop window so you are putting the desktop as the owner of the window.  
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

Author Comment

by:boreilly
ID: 1320054
Chacko's answer doesn't help.  It only tells me what I already suspected.  It's too general.  Making the parent window NULL also doesn't work.

Duneram's comment, although not a complete answer points me in a direction where I can do some further investingation.  It was quite helpful.

0
 
LVL 2

Expert Comment

by:duneram
ID: 1320055
true its not a complete answer, but you have already accepted the other.  Now the only people who can help you are the one's who have provided comments/answers to this thread.  You'll either have to get chacko or me to solve it or blow another 100 pts in a different question where everyone will be able to see it.  Or you could have ee admin reopen the question.

However it works out, good luck...
0
 

Author Comment

by:boreilly
ID: 1320056
How can I contact ee admin?
0
 
LVL 2

Expert Comment

by:duneram
ID: 1320057
true its not a complete answer, but you have already accepted the other.  Now the only people who can help you are the one's who have provided comments/answers to this thread.  You'll either have to get chacko or me to solve it or blow another 100 pts in a different question where everyone will be able to see it.  Or you could have ee admin reopen the question.

However it works out, good luck...
0
 
LVL 2

Expert Comment

by:duneram
ID: 1320058
0
 
LVL 2

Expert Comment

by:duneram
ID: 1320059
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
string initialization in java 11 115
MaxSpan challenge 9 108
building a service to accessed via telnet client, want colors ? 4 94
mapAB Challlenge 35 160
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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

820 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