Controlling Which Files with the Same Ext The TOpenDialog presents to the user

Hi All,

Our application works with a number different file types that all the same extension. When the user invokes Import, I want to present the user with only the files that can be imported (they could be one of 3 types that all have the same extension.)

Can I iterate through the current folder and add only the importable files into the TOpendialog file display area?

regards

Brian

This used to be part of I think it was raize extended shell views etc because I think you’ll need to make your own dialog unless you can see an event in the open dialog for filtering. Maybe check the open dialogs from jvcl and raize also

Can’t you just use the TOpenDialog.Filter ?

https://docwiki.embarcadero.com/Libraries/Alexandria/en/Vcl.Dialogs.TOpenDialog.Filter

If you can filter by the full filename (not just extension), the TOpenDialog would probably be simplest option.

There is also the following: Creating Custom File Dialogs: ShellBrowser Delphi Components (embarcadero.com)

Otherwise something like the following might be usable.

Create a form, and drop on a TShellTreeView component.
(Obtainable with some of the older Delphi Demos, you will need to alter it for your Delphi)

RAD Studio Demo Code / Code / [r2029] /branches/RadStudio_XE6/Object Pascal/VCL/ShellControls (sourceforge.net)

Also have a TDBGrid component on the form. (and an underlying memory table)

Then in the onchange event of the TShellTreeView component

  • Empty the TDBGrid
  • Check if any of the files with the required extension are present in the chosen directory.
  • Presumably check the contents of the files to determine if they are the required ones
  • Add matching files to the TDBGrid