ImageEn, unit iemio

TImageEnMIO.ExecuteOpenDialog

TImageEnMIO.ExecuteOpenDialog


Declaration

function ExecuteOpenDialog(const InitialDir : WideString = ''; const InitialFileName : WideString = ''; AlwaysAnimate : boolean = False;
                           FilterIndex: integer = 0; const ExtendedFilters : WideString = ''; MultiSelect : boolean = False;
                           const Title : WideString = ''; const Filter : WideString = ''; DefaultFileType : TIOFileType = ioNone;
                           LimitToFileType : TIOFileType = ioNone; ShowFormats: TIEShowFormats = iesfImagesOnly) : String; overload;
function ExecuteOpenDialog(const Title : WideString; DefaultFileType : TIOFileType; LimitToFileType : TIOFileType = ioNone;
                           AlwaysAnimate : boolean = False; MultiSelect : boolean = False;
                           ShowFormats: TIEShowFormats = iesfImagesOnly) : String; overload;


Description

Prompts the user with the open dialog to select an image to load. It encapsulates the TOpenImageEnDialog component.



Parameter Description
InitialDir Folder displayed on opening (leave as '' for no default)
InitialFileName Default file name with extension (leave as '' for no default)
AlwaysAnimate Enable to animate GIF and AVI (without user needing to click the play button). Default is False
FilterIndex The index of the default selected item in the filter (one-based). Default is 0.
Note: While this can change, the first five items are generally:
1: Common graphics formats
2: All Graphics formats
3: JPEG
4: TIFF
5: GIF

However, it is generally safer to use the DefaultFileType parameter instead
ExtendedFilters Any additional file formats to add to the filter (example: 'Fun Bitmap|*.fun;*.fan')
MultiSelect Allow selection of multiple files. The returned string will contain a list of filename separated by the "|" character (e.g. 'C:\one.jpg|C:\two.jpg')
Title The dialog title. If unspecified the Windows default title is used
Filter Override the default filter with a custom one (e.g. 'JPEG Image (JPG)|*.jpg|GIF Image (GIF)|*.gif')
DefaultFileType Specify the file type that is displayed by default. This setting overrides FilterIndex, but is ignored if you have specified InitialFileName. Default is ioNone (-1)
LimitToFileType Limits the filter to a specified ImageEn file type, plus "All Supported Types" and "All Files" (only relevant if Filter is not set). If ioNone (-1) then all types are shown
ShowFormats Limit format to images, multi-frame images and/or videos (Has no effect if Filter has been specified)

Returns a null string ('') if the user clicks Cancel.

Note: An ImageEn open dialog will be used. To use a standard Windows Open dialog, enable UseWindowsOpenSaveDialogs


Examples

// Prompt user to load a file into an ImageEnMView
sFilename := ImageEnMView1.MIO.ExecuteOpenDialog;
if sFilename <> '' then
  ImageEnMView1.MIO.LoadFromFile(sFileName);

// Prompt user to load a file, defaulting to AVI format (second overloaded method)
sFilename := ImageEnMView1.MIO.ExecuteOpenDialog('Select your video', ioAVI);
if sFilename <> '' then
  ImageEnMView1.MIO.LoadFromFile(sFileName);

// Prompt user to load a file, forcing GIF format (second overloaded method)
sFilename := ImageEnMView1.MIO.ExecuteOpenDialog('Select an Image', -1, ioGIF);
if sFilename <> '' then
  ImageEnMView1.MIO.LoadFromFile(sFileName);

// Prompt user to load any multi-frame format
sFilename := ImageEnMView1.MIO.ExecuteOpenDialog( 'Select an Image', -1, -1, True, False, iesfMultiImagesOnly );
if sFilename <> '' then
  ImageEnMView1.MIO.LoadFromFile(sFileName);

// Execute the open dialog (allowing selection of multiple images) and load them
filenames := ImageEnMView1.MIO.ExecuteOpenDialog('', '', true, 1, '', true);
ImageEnMView1.MIO.LoadFromFiles(filenames);

// Convert Open/Save dialogs to use modern Windows style dialog
IEGlobalSettings().UseWindowsOpenSaveDialogs := True;
sFilename := ImageEnMView1.MIO.ExecuteOpenDialog();
if sFilename <> '' then
  ImageEnMView1.MIO.LoadFromFile(sFileName);