I have a class that subclasses CFileDialog. It works fine in XP but in Windows 7, it does not call the overriden functions. For example, I cannot hit my breakpoint in my class' OnCancel function. But no issue in XP.
Printable View
I have a class that subclasses CFileDialog. It works fine in XP but in Windows 7, it does not call the overriden functions. For example, I cannot hit my breakpoint in my class' OnCancel function. But no issue in XP.
Normally 'subclassing' means that you have a class derived from a control and you want to redirect messages sent to the baseclass of the control to your derived classed.
How did you make a 'subclassing' of a CFileDlg? Do you mean you derived from it and provided 'virtual void OnCancel()' ?
If so, it could fail if a new implementation of the control didn't call OnCancel virtually. You may try adding an own message map to your file dialog class where you try to catch the BN_CLICKED on IDCANCEL button
The OnBtnCancel would have signature 'afx_msg void OnBtnCancel;'Code:BEGIN_MESSAGE_MAP(YourFileDlg, CFileDlg)
{
ON_BN_CLICKED(IDCANCEL, OnBtnCancel)
The issue has been resolved. Looks like in VS 2008, CFileDialog uses a Vista style file dialog. The constructor includes a boolean to switch back to pre-Vista.
In MFC all member controls of a dialog or formview need to get subclassed in order to get the message map mechanism working. That was done technically by subclassing the window associated to the control by an appropriate function of the MFC framework. CWnd has member functions PreSubclassWindow, SubclassWindow, UnSubclassWindow for that purpose. See MFC sources cmdtarg.cpp, ctlcore.cpp, dlgdata.cpp, wincore.cpp and more. In first MFC versions the subclassing wasn't done automatically for your own classes derived from a standard control class but you had to do the subclassing manually. Now it is done automatically for all member controls added to the DoDataExchange member function and you need extra work only for dynamically created controls where you want to handle messages by your own derived control class.
So the 'subclassing' has got a second meaning and what is 'normally' is dependent on whether you do Windows programming or MFC programming.
A CFileDialog however isn't a control but a modal dialog which doesn't need to get subclassed by the calling dialog cause it has its own message pump. So, the OP apparently meant neither 'Windows subclassed' nor 'MFC subclassed' but simply 'derived'.