A CFileDialog Question
-
Greetings: I need to launch a CFileDialog box but I need to implement special file name filtering. That is, I might filter with a file name extension like "TXT", however, I need to filter even further by excluding files that have certain sub-strings embedded in their names. The wild card method is not going to work here because I need to exclude file names that have certain characteristics, not include them. This requirement has been thrust upon me and I simply have to find a solution. I can't see anything in the documentation that says you can do this. Any suggestions? Thank you, Mark
-
Greetings: I need to launch a CFileDialog box but I need to implement special file name filtering. That is, I might filter with a file name extension like "TXT", however, I need to filter even further by excluding files that have certain sub-strings embedded in their names. The wild card method is not going to work here because I need to exclude file names that have certain characteristics, not include them. This requirement has been thrust upon me and I simply have to find a solution. I can't see anything in the documentation that says you can do this. Any suggestions? Thank you, Mark
Jethro63 wrote:
This requirement...
Does it also include using
CFileDialog
?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
-
Jethro63 wrote:
This requirement...
Does it also include using
CFileDialog
?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
Hi David: No, not necessarily. I am becoming resigned to the possibility that I'll just have to construct my own selection dialog. No big deal, just another little thing on the great-big pile. But I was expecting (or hoping) that under the hood of CFileDialog, there might be a mechanism, an optional callback function perhaps, where each time the dialog was about to add another entry to the list box embedded in the dialog, the callback would first be called and you could use this callback to do any manner of screening that you need and say "yes" or "no" to adding the file. No such luck, apparently. So, I'm open to suggestions but I need to get this done. It is a minor requirement in the grand scheme of things but I have already spent a lot of time trying to come up with a solution. Thanks, Mark
-
Hi David: No, not necessarily. I am becoming resigned to the possibility that I'll just have to construct my own selection dialog. No big deal, just another little thing on the great-big pile. But I was expecting (or hoping) that under the hood of CFileDialog, there might be a mechanism, an optional callback function perhaps, where each time the dialog was about to add another entry to the list box embedded in the dialog, the callback would first be called and you could use this callback to do any manner of screening that you need and say "yes" or "no" to adding the file. No such luck, apparently. So, I'm open to suggestions but I need to get this done. It is a minor requirement in the grand scheme of things but I have already spent a lot of time trying to come up with a solution. Thanks, Mark
-
Hi David: No, not necessarily. I am becoming resigned to the possibility that I'll just have to construct my own selection dialog. No big deal, just another little thing on the great-big pile. But I was expecting (or hoping) that under the hood of CFileDialog, there might be a mechanism, an optional callback function perhaps, where each time the dialog was about to add another entry to the list box embedded in the dialog, the callback would first be called and you could use this callback to do any manner of screening that you need and say "yes" or "no" to adding the file. No such luck, apparently. So, I'm open to suggestions but I need to get this done. It is a minor requirement in the grand scheme of things but I have already spent a lot of time trying to come up with a solution. Thanks, Mark
Creating your own dialog would be the easier choice. You could also allow the CFileDialog to do it's job, then before showing it to the user, iterate through it's list box performing your own additional scan of the files. All you need to do is find the window handle to it's listbox, then use the normal api functions to remove items.
-
Look up CDN_INCLUDEITEM in MSDN.
You may be right
I may be crazy
-- Billy Joel --Within you lies the power for good, use it!!!
-
Creating your own dialog would be the easier choice. You could also allow the CFileDialog to do it's job, then before showing it to the user, iterate through it's list box performing your own additional scan of the files. All you need to do is find the window handle to it's listbox, then use the normal api functions to remove items.
Does this dialog expose the handle to its list box? Is there not a risk of screwing things up? For example, maybe I can remove the entries from the list box but what if there is an under-lying collection (like, say, CStringArray) that contains the entries and these entries are not removed? The list box would become un-synchronized with the internal list... Thank you, Mark
-
Does this dialog expose the handle to its list box? Is there not a risk of screwing things up? For example, maybe I can remove the entries from the list box but what if there is an under-lying collection (like, say, CStringArray) that contains the entries and these entries are not removed? The list box would become un-synchronized with the internal list... Thank you, Mark
did CDN_INCLUDEITEM work for you? As I recall it does not quite work as you would first expect... I needed to do exactly what you did, the only solution I could find was provided by Paul DiLascia: http://msdn.microsoft.com/msdnmag/issues/03/10/CQA/ There doesn't seem to be any under-lying collection, as this solution worked fine for me...the only problem is in this solution is you're deleting unwanted files from the list after they have been added rather than just excluding them in the first place...
-
did CDN_INCLUDEITEM work for you? As I recall it does not quite work as you would first expect... I needed to do exactly what you did, the only solution I could find was provided by Paul DiLascia: http://msdn.microsoft.com/msdnmag/issues/03/10/CQA/ There doesn't seem to be any under-lying collection, as this solution worked fine for me...the only problem is in this solution is you're deleting unwanted files from the list after they have been added rather than just excluding them in the first place...
Another similar option would be to populate the dialogs list with an obviously stupid file extension, then add the items yourself.