|
-
May 1st, 1999, 12:50 PM
#1
AfxMessageBox
Can anyone explain to me why m_pMainWnd = &uDlg; under the CClassMainApp::InitInstance() function causes the AfxMessageBox() function to stop working. If it is // commented out AfxMessageBox() works fine? Oh and this is in a Dialog based app!
Thanks! Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
-
May 3rd, 1999, 03:48 PM
#2
Re: AfxMessageBox
You can use MessageBox() intead. i had that problem , but when i used MessageBox() it worked.
-
May 4th, 1999, 04:09 PM
#3
Re: AfxMessageBox
I'll take a shot.
Are you trying to use AfxMessageBox in myApp.InitInstance()? If so you are probably trying to do so AFTER the main dialog has been destroyed already, so you can't attach AfxMessageBox to it because it is no longer there.
-
May 5th, 1999, 07:08 AM
#4
Re: AfxMessageBox
Actually the m_pMainWnd = &uDlg; is something that is setup by the Application Wizard when the project was created, but it is definately before the dialog is ever used. So I still don't understand why it would affect AfxMessageBox? But thanks for giving it a shot!
Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
-
May 5th, 1999, 02:28 PM
#5
Re: AfxMessageBox
I actually meant, it only effects AfxMessageBox in you InitInstance method.
Here is an example of some InitInstance code:
CMyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
// if you attempt to use AfxMessageBox after DoModal returns the m_pMainWnd may be invalid // because the destructor may have been called already.
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
If you are having problems with AfxMessageBox in some other method that's a different story.
-
May 10th, 1999, 09:51 AM
#6
Re: AfxMessageBox
I see what you are saying and maybe I should have re-worded the question and asked what is the m_pMainWnd &dlg; for. Is it the Address of the Main Dalog Window? If yes what would be an example for its use? I am fairly new to Visual C++ so please forgive me if I seem a little dense!
Thanks for responding I need to understand how these thing work!
Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
-
May 10th, 1999, 11:57 AM
#7
Re: AfxMessageBox
I tried sending you a private message but I kept getting errors.
Your instance of CDialog will become the main window when you set
m_pMainWnd = &dlg
I'm sure there are many uses for a pointer to the main window (m_pMainWnd) but I do not pretend to know them all.
One use is to position additional windows according to your Main Window, for instance a "please wait.." window or a progress bar window or even MessageBoxes can all be centered on the main window.
You'll find you'll learn something every day and that should be a good thing!
-
May 10th, 1999, 12:17 PM
#8
Re: AfxMessageBox
Thanks for the info and I am learning every day and it is a Good thing! Appreciate your time and effort. You gave me some new insight about m_pMainWnd and at least now I understand some uses for it!
Thanks Again!
Charlie
Everything is Free Until You Have to Pay for it....
Platform is Windows 2000/XP Professional, Visual C++ 6.0
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|