|
-
January 18th, 2011, 05:19 PM
#1
CFileDialog cannot be subclassed in Windows 7?
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.
-
January 19th, 2011, 08:33 AM
#2
Re: CFileDialog cannot be subclassed in Windows 7?
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
Code:
BEGIN_MESSAGE_MAP(YourFileDlg, CFileDlg)
{
ON_BN_CLICKED(IDCANCEL, OnBtnCancel)
The OnBtnCancel would have signature 'afx_msg void OnBtnCancel;'
-
January 19th, 2011, 09:38 AM
#3
Re: CFileDialog cannot be subclassed in Windows 7?
 Originally Posted by itsmeandnobodyelse
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.
'
In Windows programming, normally, "subclassing" means to replace a default window procedure with another one, application-defined.
Last edited by ovidiucucu; January 20th, 2011 at 12:59 AM.
-
January 19th, 2011, 01:49 PM
#4
Re: CFileDialog cannot be subclassed in Windows 7?
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.
-
January 20th, 2011, 04:37 AM
#5
Re: CFileDialog cannot be subclassed in Windows 7?
 Originally Posted by ovidiucucu
In Windows programming, normally, "subclassing" means to replace a default window procedure with another one, application-defined.
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'.
-
January 20th, 2011, 06:00 AM
#6
Re: CFileDialog cannot be subclassed in Windows 7?
 Originally Posted by Shiney Vang
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.
Yes, exactly, and the flag is set to TRUE by default to use Vista style.
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
|