TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
Specifying Custom Filters in FileBrowser
 
   
 Posted: 1 April 2002
 
   
 
 Written for: Paradox 9
 
   
 
Audience: Intermediate
 
       
   

Question: I'm trying to use FileBrowser() or FileBrowserEx() to prompt the user for a file using a different extension than the ones supported by AllowableTypes. How do I do this?

Answer: Define a custom filter of allowable file extensions, as shown in the following code sample:

method pushButton(var eventInfo Event)
var
   fbiXFile  FileBrowserInfo   ; data for systemSaveAs() function.
   loRetval  Logical           ; Value returned to calling process.
   strValue  String            ; Holds filenames
endVar

   ; initialize local vars
   loRetval = TRUE
   strValue = "USERDATA.INI"

   fbiXFile.Title          = "Open File"
   fbiXFile.CustomFilter   = "INI Files|*.ini|All Files|*.*|"
   fbiXFile.Alias          = ":PRIV:"
   fbiXFile.DefaultExt     = "INI"

   ; Call the SaveAs wrapper function
   loRetval = getFileName( strValue, fbiXFile )

   if loRetval then

      msgInfo( "FYI", "The user chose to import " +
               strValue + "." )
   else

      msgStop( "File Browser Cancelled", "The user either cancelled " +
               "the FileBrowser or an invalid file was selected." )

   endIf

endMethod

This example prompts the user to select an INI file and may be useful if you're having trouble using the fbIni FileBrowserFileTypes for this.

Related Articles:

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 31 May 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]