How to filter contents of IExplorerBrowser?


  • IExplorerBrowser control allows to set filtering by at least two ways:

    1. QueryInterface on IExplorerBrowser for IFolderFilterSite and then set IFolderFilter object. IFolderFilter::ShouldShow will be called to filter items. (An interesting side question is why IFolderFilterSite::SetFilter takes IUnknown rather than IFolderFilter? Can anything else be provided?)
    2. Set site (by for example IUnknown_SetSite) of IExplorerBrowser providing an object implementing IServiceProvider and provide through it ICommDlgBrowser interface. ICommDlgBrowser::IncludeItem will be called to filter items. (Yet from documentation it seems to be unadvised anyway as documentation advices to set CDB2GVF_NOINCLUDEITEM flag which prevents calls to IncludeItem.)

    But non of this methods works with Windows 7 libraries folders (which are not real file system folders but a merge of two corresponding folders: user's own and common). The functions are not called. This makes filtering on Windows 7 near to pointless.

    Yet this is possible somehow as IFileDialog does filtering (by file type) and it works with libraries folders. I'm not sure whether file dialog indeed uses embeded IExplorerBrowser but it seems so (Spy++ shows that the same window: class + procedure address is used by IExplorerBrowser and IFileDialog).

    So is there any way to do the filtering? Filtering by file type is enough for me now but being able to filter by a provided per item predicate (like IFolderFilter) would be generally more useful.


    I did so far some experiments while trying to overcome lack of filtering. I focused mainly on two directions:

    1. Force IExplorerBrowser to use IResultsFolder by calling FillFromObject with NULL argument. (IResultsFolder may be obtained by calling IExplorerBrowser::GetCurrentView asking for IFolderView. Then call IFolderView::GetFolder asking for IResultsFolder.) IResultsFolder allows to manually add and remove shown items.

      This however leads to some issues: (1) the folders tree on left side (with EBO_SHOWFRAMES) shows and selects an unnamed item with generic icon representing the IResultsFolder, (2) I don't know how to force it to not show it and select a different folder and then listen to selection changes in the tree, (3) double clicking a folder in such IResultsFolder opens a new explorer window with it rather then navigate into that folder in the same window, (4) probably drag and drop handling will be difficult if possible at all.
    2. Browse to folder normally (by IExplorer::BrowseTo* methods and then through user interaction) and then manually filter the items (possibly removing some). This filtering would be done in response to one of the IExplorerBrowserEvents notification.

      But again I failed to do that. There doesn't seem to be any (public) API allowing to remove items from IShellView/IFolderView. So I tried to get IDataObject representing all the items in the view (IShellView::GetItemObject with SVGIO_ALLVIEW) and since such data object has CFSTR_SHELLIDLIST format for both getting and setting it seems easy to modify the (shown) folder contents. But it does not work since the view generates IDataObject when asked to and looses any connection to it. Modifying data object received that way does not modify the view in any way. (It is easy to see that if you ask the view for data object and then ask once again you will get two different interfaces which is a strong hint that the interfaces do not interact with the view.)


    Any clues?

    Adam Badura
    • Edited by Adam Badura Tuesday, August 30, 2011 8:54 PM Minor editing and layout corrections
    Tuesday, August 30, 2011 8:57 AM

All replies

  • I was wondering if I could revive this old thread. I'm running into the exact same problem now on my own project. Adam, have you gotten any further in the several months since you posted last?
    Sunday, March 18, 2012 7:20 PM
  • I was wondering if I could revive this old thread. I'm running into the exact same problem now on my own project. Adam, have you gotten any further in the several months since you posted last?

    No, I gave up and didn't use this otherwise very promising interface. It is sad especially due to lack of any support even here, on Microsoft's forum.

    Adam Badura

    Sunday, March 18, 2012 10:32 PM