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?
Printable View
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?
This is virtually impossible...can you post your project here (excluding the debug and release directory)?
This is impossible.. u pls use RebuildAll from the Build menu. and try to debug it.
jim
Sounds to me like your OnInitDialog declaration in your dialog isn't the same as the virtual function in CDialog.
It should be
Darwen.Code:BOOL OnInitDialog();
How do you know it isn't called?
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.
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.
Well you did not tell us that. Of course OnInitDialog is not called.Quote:
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.
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?
Quote:
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_
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.Quote:
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.
So I don't know why OnInitDialog is not being called. The only possibility is that there are two instances of your CFileDialog.
UP - I've got the same problem.
We've got the same answers !
(show your lines)
But I've got the answer! :D
Set m_bVistaStyle to FALSE.