The OpenFileDialogEx described in this CodeProject article is an extension of the standard OpenFileDialog. The primary intention of that extension is to modify the display of the dialog, but there are some additional bells and whistles. For example, OFDEx adds a few events, for File changed, Folder change, etc.
Someone pointed out that the CDN_INCLUDEITEM notification seems like it would satisfy the desire to filter the list of files shown in the dialog,. It seems like it would, but it does not. The CDN_INCLUDEITEM does not do what you might think or want.
According to this MSDN Mag article,
If you create your dialog with
OFN_ENABLEINCLUDENOTIFY, Windows sends
your hook procedure a CDN_INCLUDEITEM
notification for every item it adds to
the open list. If you return FALSE,
Windows excludes the item. The problem
is, Windows doesn't notify you for
ordinary files, only pseudo-objects
like namespace extensions. When you
read the documentation through a
magnifying glass, the print is
perfectly clear: "The dialog box
always includes items that have both
the SFGAO_FILESYSTEM and
SFGAO_FILESYSANCESTOR attributes,
regardless of the value returned by
CDN_INCLUDEITEM." Apparently the
Redmondtonians added CDN_INCLUDEITEM
for their own purposes, which didn't
include filtering ordinary file names.
In other words, in response to CDN_INCLUDEITEM, you cannot return FALSE for regular files, to exclude them from the dialog. In contrast to the doc which says, the response from the CDN_INCLUDEITEM is ignored for regular files, in my experience, the CDN_INCLUDEITEM is not even sent for regular files, at least not on my Vista machine.
So is it possible to exclude files dynamically? Well, yes, in C++; In response to the CDN_FOLDERCHANGED message, you can get and set the contents of the CListCtrl that contains the files. I haven't figured out how to set this list in C#.