Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

AfxMessageBox on A Modeless Dialog giving problem

Posted on 2006-06-29
11
Medium Priority
?
976 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
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 45

Accepted Solution

by:
AndyAinscow earned 225 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 150 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 45

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

564 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