Fct_Open_FileName

 

Open a pop-up window with a file browser.

 

 

Syntax

 

int  Fct_Open_FileName(

          char *title,

          char *format_dscr,

          int max_files,

          char files[][MAX_PATH]

) ;

 

 

Parameters

 

title

A text string that will be displayed at the top of the window.

 

format_dscr

A buffer containing pairs of null-terminated filter strings. The last string in the buffer must be terminated by two NULL characters.

The first string in each pair is a display string that describes the filter (for example, "Text Files"), and the second string specifies the filter pattern (for example, "*.TXT"). To specify multiple filter patterns for a single display string, use a semicolon to separate the patterns (for example, "*.TXT;*.DOC;*.BAK"). A pattern string can be a combination of valid file name characters and the asterisk (*) wildcard character. Do not include spaces in the pattern string.

The system does not change the order of the filters. It displays them in the File Types combo box in the order specified in format_dscr.

If format_dscr is NULL, the dialog box does not display any filters.

 

max_files

The maximum number of files that can be opened.

 

files

An array of pointer to strings that will be filled with the selected files name and path.

 

 

Return value

 

This function return the number of files that have been selected.

 

 

Remarks

 

This function open a dialogue box using the "GetOpenFileName" mechanism.

 

 

Requirements

 

Header:

          sliceO_include.hpp

 

 

Library:

          sliceO_Structures.lib

 

 

 

Example

 

 

static          char          szFilterIma[] = "Dicom Files (*.dcm,*.dic)\0*.dcm;*.dic\0"

                                        "All Files (*.*)\0*.*\0"

                                        "\0" ;

 

 

// ------------------------------------------------------------------------

//          Sub_Menu_File_Click

// ------------------------------------------------------------------------

int          Sub_Menu_File_Click( void )

{

char          files[MAX_SIMULTANEOUS_FILES][MAX_PATH] ;

 

          ...

 

          if ( but_file[OPEN_GLI].Select( KEY_PRESS ) ) {

 

              but_file[OPEN_GLI].Cur_Value = 1 ;

              but_file[OPEN_GLI].Adjust() ;

 

              // --- get the file names ---

              int ret = Fct_Open_FileName( "Read Image Files", szFilterIma, MAX_SIMULTANEOUS_FILES, files ) ;

              if ( ! ret ) {

                    but_file[OPEN_GLI].Cur_Value = 0 ;

                    but_file[OPEN_GLI].Adjust() ;

                    return( 1 ) ;

              }

 

              // --- we read the files by placing the appropriate command in the pipe ---

              int Output_Pipe = _open( Default_Pipe_Name, O_CREAT | O_WRONLY | O_APPEND, 0666 ) ;

                              

              for ( i=0; i < ret; i++ ) {

                    char str[MAX_PATH] ;

                    sprintf( str, "read: image \"%s\"\n", files[i] ) ;

                    _write( Output_Pipe, str, (unsigned int) strlen(str) ) ;

              }

 

              but_file[OPEN_GLI].Cur_Value = 0 ;

              but_file[OPEN_GLI].Adjust() ;

          }

 

          ...

}

 

See also