Wednesday, 6 June 2012

Undocumented feature - filebox filter

I was working with Uniface's filebox command today, allowing a user to select a file using the Windows selection dialog.  This is a handy feature and very simple to use, it's fairly well documented, but there is one thing missing.

The easiest way to trigger this selection dialog is like this...


The "All File (*.*)" option is added by default, and as far as I'm aware this cannot be removed.  However, it is normally useful to filter the files which appear, especially if it is being used to select a particular type of file.  You can add a filter like this...

  filebox "*.txt"

Notice that the title of the filter is built from the file extension in your filter - very clever.  You can even add multiple filters, like this...

  filebox "my*.txt·;*.txt"

However, In this example I have two different filters, but because they have the same file extension, the default titles are the same.  Well here's the undocumented bit; changing the title is very easy to do, like this...

  filebox "my*.txt=My text files·;*.txt=Text files"

Much better!  This allows you to create more user-friendly dialogs with helpfully named filters.

Summary: It is easy to rename the filters in a filebox selection dialog, if you know how.

No comments:

Post a Comment