-
February 10th, 2004, 04:15 AM
#1
OnInitDialog not called
Hello,
I have a dialog in my application. I am bringing it up by calling DoModal method. The dialog does show up. However, OnInitDialog is never called. Any reason why would this happen?
-
February 10th, 2004, 04:34 AM
#2
This is virtually impossible...can you post your project here (excluding the debug and release directory)?
-
February 10th, 2004, 04:43 AM
#3
This is impossible.. u pls use RebuildAll from the Build menu. and try to debug it.
jim
-
February 10th, 2004, 04:47 AM
#4
Sounds to me like your OnInitDialog declaration in your dialog isn't the same as the virtual function in CDialog.
It should be
Code:
BOOL OnInitDialog();
Darwen.
-
February 10th, 2004, 05:09 PM
#5
How do you know it isn't called?
-
February 10th, 2004, 05:12 PM
#6
In MFC Visual Studio, build the project in Debug mode and set a breakpoint in your OnInitDialog() function.
Otherwise, use a MessageBox(NULL, "In InitDialog", 0, 0 ) as the first line in InitDialog() to see if it pops up when you run the program.
Andrew Ferlitsch
-
February 10th, 2004, 06:29 PM
#7
The declaration is as follows:
virtual BOOL OnInitDialog();
One reason I know it is not being called is that I have a break point in OnInitDialog method but it is never invoked. I have a break point in the constructor of the dialog which IS invoked.
Another reason I know it is not being called is that the stuff I want to happen in OnInitDialog isn't happen. It is supposed to disable some controls, set context-sensitivie help IDs and initialize some member variables. All of that doesnt happen.
The most bizarre thing is that the dialog does show up. All the controls are there, although the ones that should be disabled arent and they have no context-sensitive help (because OnInitDialog is never called)
By the way, my dialog is dervied from CFileDialog and it is using a dialog template resource. Basically, what I am doing is adding a couple of controls to standard file dialog.
-
February 10th, 2004, 06:36 PM
#8
Originally posted by kzseattle
By the way, my dialog is dervied from CFileDialog and it is using a dialog template resource. Basically, what I am doing is adding a couple of controls to standard file dialog.
Well you did not tell us that. Of course OnInitDialog is not called.
-
February 10th, 2004, 09:59 PM
#9
But OnInitDialog is a virtual function and CFileDialog is derived from CDialog and my dialog is derived from CFileDialog. So why wouldnt OnInitDialog be called? I dont thing it is a correct statement to say that OnInitDialog is not invoked for CFileDialog-derived classes. How else could one initialize the controls then?
-
February 10th, 2004, 10:32 PM
#10
Originally posted by kzseattle
But OnInitDialog is a virtual function and CFileDialog is derived from CDialog and my dialog is derived from CFileDialog. So why wouldnt OnInitDialog be called? I dont thing it is a correct statement to say that OnInitDialog is not invoked for CFileDialog-derived classes. How else could one initialize the controls then?
Have you created a Message Map to WM_INITDIALOG in your CFileDialog-derived class? Maybe you added OnInitDialog() by hand. Try using the class wizard (Ctrl+W).
Hope that helps.
_msd_
While memory is getting abundant, it is not an excuse for wasting it with bad programming design/practice.
-
February 10th, 2004, 10:54 PM
#11
For OnInitDialog method, you dont need to add a message map entry of WM_INITDIALOG. The framework is supposed to call this method anyway.
-
February 10th, 2004, 11:48 PM
#12
Originally posted by kzseattle
For OnInitDialog method, you dont need to add a message map entry of WM_INITDIALOG. The framework is supposed to call this method anyway.
Yes, everything you say is correct. I am sorry I doubted you. I had forgotten that CFileDialog calls OnInitDialog like other dialogs do.
So I don't know why OnInitDialog is not being called. The only possibility is that there are two instances of your CFileDialog.
-
July 8th, 2011, 04:26 AM
#13
Re: OnInitDialog not called
UP - I've got the same problem.
-
July 8th, 2011, 04:53 AM
#14
Re: OnInitDialog not called
We've got the same answers !
(show your lines)
-
July 8th, 2011, 09:29 AM
#15
Re: OnInitDialog not called
But I've got the answer!
Set m_bVistaStyle to FALSE.
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
|