Solved

AfxMessageBox on A Modeless Dialog giving problem

Posted on 2006-06-29
11
924 Views
Last Modified: 2013-11-20
Hi Friends
  I have created an MFC application in which a Modeless Dialog  has been created.
In the OnInitDialog of the Modelsss Dialog i have displayed a AfxMessageBox.

The problem is that sometimes the AfxMessageBox gets hidden & i am not able to click the same.

Am i doing wrong as said above ?

Regards
0
Comment
Question by:vikrant_kpr
[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
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17008324
check MS knowledge based article Q138681 and see if this is case with you..
http://www.kbalertz.com/Q138681/Windows.Flash.Disappear.Applications.aspx <==

As said above to resolve this problem, change the line that sets the m_pMainWnd to point to dialog object, into a comment. Or set m_pMainWnd for the CWinApp-derived object to NULL before control gets to the CWnd::OnNcDestroy function for the dialog object. One way of doing this is to override the OnNcDestroy function for the CDialog-derived object. In the overridden function, set the m_pMainWnd to NULL before calling the base class.

In short remove the "m_pMainWnd = &dlg" kinda line from 'InitInstance()' and check if your message-boxes appears......

-MAHESH
0
 

Author Comment

by:vikrant_kpr
ID: 17008412
Hi Mahesh
   Thanks for the same , but it talks of creation of a Modal Dialog when closing one Modal Dialog.
My problem is that when creating a Modal Dialog on Modeless Dialog , the Modal Dialog disappears sometimes.

Regards
0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17008435
still have you checked by modifying same if your AfxMessageBox is visible ...also can you post your initdialog code ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:vikrant_kpr
ID: 17008465

BOOL CMyDialog::OnInitDialog()
{
.
.
.
AfxMessageBox("Hello"");

Created like as given below
CMyDialog* vl_pDialog=new CMyDialog(AfxGetMainWnd());
vl_pDialog->Create(IDD_DIALOG1);
vl_pDialog->ShowWindow(SW_SHOW);


0
 
LVL 22

Expert Comment

by:mahesh1402
ID: 17008543
I cannot see any problems with this .....if you create one simple dialog and one child dialog and simply invoke AfxMessageBox on InitDialog of child dialog it works..you may try that by building sample dialog based application......

Its happening sometimes or you never get messagebox ?...try by removing your dialog and recreating it from scratch..

-MAHESH
0
 

Author Comment

by:vikrant_kpr
ID: 17008568
Mahesh
   Yes even i cannot see anything wrong into the same, but still sometimes the messagebox goes hidden.
The Application is used by the users & they face the problem & is not replicable on my pc.

Regards
 
0
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 75 total points
ID: 17008702
Make certain that the dialog is actually displayed before the message box

CMyDialog* vl_pDialog=new CMyDialog(AfxGetMainWnd());
vl_pDialog->Create(IDD_DIALOG1);
vl_pDialog->ShowWindow(SW_SHOW);   //<<-----------------
vl_pDialog->DisplayMessageBox();    //<<----------------

and in the CMyDialog a public function
void CMyDialog::DisplayMessageBox()
{
  AfxMessageBox("Hello");
}
0
 
LVL 39

Assisted Solution

by:itsmeandnobodyelse
itsmeandnobodyelse earned 50 total points
ID: 17011710
>>>> but still sometimes the messagebox goes hidden.

How to you invoke the modeless dialog? By keyboard Enter or Space on some button? Or by mouse-click? If yes, the problem could occur because you made a couple of key strokes or clicks and the last keystroke or mouseclick happens after the messagebox was shown. Hence, the dialog or view where you pressed the button was invoked and the messagebox was hidden cause it was modal to the modeless dialog but not to the first dialog.

Regards, Alex
 
0
 

Author Comment

by:vikrant_kpr
ID: 17016379
Alex
  The Modelsss dialog is invoked by an Icon on the Toolbar.
User clicks on that icon or alternatively can select from the menu.
Now how the problem can be resolved ?

Regards
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 17016429
Have you tried my suggestion?
0
 

Author Comment

by:vikrant_kpr
ID: 17016457
Thanks Alex
I will try that
Actually for getting the actual result
i will have to deploy my application to the users & then i will get the report

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
In this post we will learn different types of Android Layout and some basics of an Android App.
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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

691 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