C++
--
Questions
--
Followers
Top Experts
CFileDialog problem with ZIP files
Hi everybody,
I have a problem in a MFC application where I yet wasn't able to find a solution, I hope someone here can help me. In my application I have following trivial code:
I found this is not a general problem of the open-file common dialog, because I get a valid filename to a temporary created file using this none-MFC code:
Does anyone have an idea if this can be fixed without replacing every CFileDialog (my application is quite huge, there are about 120 functions where CFileDialog is used)?
If there's no possibility to avoid CFileDialog returns an empty file string maybe anyone has an idea if it's possible to avoid ZIP files are shown as folders in a CFileDialog? This would be a suitable workaround for me.
Thanks in advance,
Best regards,
ZOPPO
I have a problem in a MFC application where I yet wasn't able to find a solution, I hope someone here can help me. In my application I have following trivial code:
CFileDialog dlg( TRUE );
if ( dlg.DoModal() == IDOK )
{
AfxMessageBox( dlg.GetFileName() );
}
This usually works as expected, but I found (at least in Windows 7) this displays an empty message box in case the file selected in the open-file dialog is contained in a ZIP file which can be opened in via the folder bar as shown here:
I found this is not a general problem of the open-file common dialog, because I get a valid filename to a temporary created file using this none-MFC code:
TCHAR buf[MAX_PATH + 1] = {};
OPENFILENAME ofn = { sizeof( OPENFILENAME ) };
ofn.Flags = OFN_FILEMUSTEXIST;
ofn.lpstrFile = buf;
ofn.nMaxFile = MAX_PATH;
if ( FALSE != GetOpenFileName( &ofn ) )
{
MessageBox( NULL == ofn.lpstrFile ? "ERROR!" : ofn.lpstrFile );
}
Beside this I even found my application can open such a file using DDE if it's double-clicked in the Explorer.Does anyone have an idea if this can be fixed without replacing every CFileDialog (my application is quite huge, there are about 120 functions where CFileDialog is used)?
If there's no possibility to avoid CFileDialog returns an empty file string maybe anyone has an idea if it's possible to avoid ZIP files are shown as folders in a CFileDialog? This would be a suitable workaround for me.
Thanks in advance,
Best regards,
ZOPPO
Zero AI Policy
We believe in human intelligence. Our moderation policy strictly prohibits the use of LLM content in our Q&A threads.
SOLUTION
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
Hi sarabande,
thanks for that idea, I'll think about it and make some tests. A problem is this even means I'll have to change a large amount of code, in addition to try to find a way to override some MFC functionality which internally use CFileDialog, but maybe it's worthwhile if it's not much more than replacing a class name.
I just took a look into CFileDialog and think I first need to understand how it works, unfortunateley I'm not quite sure how to do this since CFileDialog (at least in VS 2010) is implemented using some IFileDialog interface, I'm not sure if it's is already created when OnInitDialog (which in fact isn't implemened for CFileDialog) is called, all I found yet is the interface is created in the constructor and the dialog is shown in CFileDialog::DoModal using IModalWindow::Show, I don't know yet whether the dialog is already created at that time or where/how I can subclass controls in there.
I'll try to further understand how this works, maybe best is to try to find whether the problem comes from IFileDialog or from the way how it's used in CFileDialog.
So I'll make more tests and debugging. I'll keep you informed, but maybe with long breaks in between because I'll go for a 3-week holiday now, in this time I'll check my mails only sporadically :o)
Have a nice day,
best regards,
ZOPPO
thanks for that idea, I'll think about it and make some tests. A problem is this even means I'll have to change a large amount of code, in addition to try to find a way to override some MFC functionality which internally use CFileDialog, but maybe it's worthwhile if it's not much more than replacing a class name.
I just took a look into CFileDialog and think I first need to understand how it works, unfortunateley I'm not quite sure how to do this since CFileDialog (at least in VS 2010) is implemented using some IFileDialog interface, I'm not sure if it's is already created when OnInitDialog (which in fact isn't implemened for CFileDialog) is called, all I found yet is the interface is created in the constructor and the dialog is shown in CFileDialog::DoModal using IModalWindow::Show, I don't know yet whether the dialog is already created at that time or where/how I can subclass controls in there.
I'll try to further understand how this works, maybe best is to try to find whether the problem comes from IFileDialog or from the way how it's used in CFileDialog.
So I'll make more tests and debugging. I'll keep you informed, but maybe with long breaks in between because I'll go for a 3-week holiday now, in this time I'll check my mails only sporadically :o)
Have a nice day,
best regards,
ZOPPO
yes, active-x controls probably could not easily subclassed.
I wonder whether the ability of the explorer to show zip files as folders actually is a capability of the explorer itself or whether the winzip (or your favorite zip) would provide that. if the latter, your issues could be simply a bug. to check that you may try to delete the association of zip files temporarily in the explorer or install another zip utility.
Sara
I wonder whether the ability of the explorer to show zip files as folders actually is a capability of the explorer itself or whether the winzip (or your favorite zip) would provide that. if the latter, your issues could be simply a bug. to check that you may try to delete the association of zip files temporarily in the explorer or install another zip utility.
Sara
Hi Sara,
IMO it's the explorer himself, it even works before any third-party ZIP software is installed on a clean machine. IMO it's implemented as a shell extension, in registry I found the registered InProcServer32 for .ZIP extension is %SystemRoot%\system32\zipf ldr.dll, so it's part of Windows. And I still don't think it's a general Windows problem, I guess it's just a bug in MFC implementation.
BTW: didn't yet continue testing this issue since I'm still in holidays, I just was checking my mails and saw your comment ...
I wish you a Merry Christmas,
best regards,
ZOPPO
IMO it's the explorer himself, it even works before any third-party ZIP software is installed on a clean machine. IMO it's implemented as a shell extension, in registry I found the registered InProcServer32 for .ZIP extension is %SystemRoot%\system32\zipf
BTW: didn't yet continue testing this issue since I'm still in holidays, I just was checking my mails and saw your comment ...
I wish you a Merry Christmas,
best regards,
ZOPPO






EARN REWARDS FOR ASKING, ANSWERING, AND MORE.
Earn free swag for participating on the platform.
membership
Log in or create a free account to see answer.
Signing up is free and takes 30 seconds. No credit card required.
I found the solution myself, but for the spent time/effort I assigned some points to Sara too ...
C++
--
Questions
--
Followers
Top Experts
C++ is an intermediate-level general-purpose programming language, not to be confused with C or C#. It was developed as a set of extensions to the C programming language to improve type-safety and add support for automatic resource management, object-orientation, generic programming, and exception handling, among other features.