Solved

MessageBox in Dialog based app

Posted on 1998-08-01
9
203 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
 

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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
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

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: 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…
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

12 Experts available now in Live!

Get 1:1 Help Now