Custom filter CFileDialog

Rahul Gupta
Rahul Gupta used Ask the Experts™
I want to implement a openfiledialog using CFileDialog with custom filter,
where I can get list of files and choose one by one which one to be shown or not,

For this I have tried to hook with OPENFILENAME's HookProc, But it only gets callback for old style dialog I want to implement it for new style dialog,

Could anyone please explain me, how can I implement this type of filter with new style explorer dialog, using any possible way or workaround.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Hello Rahul,

I need to ask. What do you mean by custom filter?
Are we talking about the file type combobox which lets you filter by extension?
FileDialog example
Or some other form of filter?
In that case can you please explain a little bit more?

In case it's about the file type box, how do your parameters lpszDefExt and lpszFilter look like?



I need to filter files from a special filter criteria,
where I open each and every file, check some internal properties, validate them whether the file has be to shown in dialog list or not, then only specific files only which has passed the criteria should be displayed to user in dialog list to choose.

For Old style there was a notification code called CDN_INCLUDEITEM,
my hookproc function receive this message in form of WM_NOTIFY message,
But the problem with this method is, it is only for oldstyle dialog, (the same dialog you have attached)
and this does not work with many of files as its documentation says.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial