Displays the system’s Open File dialog box and allows the user to select a file or enter a file name.
Windows CE platforms
The initdir and aFlag options
are not currently supported in PocketBuilder, and in Windows CE,
the pathname must be the My Documents directory
or its subdirectory. You cannot use an array of string variables
for the filename argument.
GetFileOpenName ( title, pathname, filename {, extension {, filter { , initdir { , aFlag } } } } )
GetFileOpenName ( title, pathname, filename[ ] {, extension {, filter { , initdir { , aFlag } } } } )
Argument |
Description |
---|---|
title |
A string whose value is the title of the dialog box. |
pathname |
A string variable in which you want to store the returned path and file name. |
filename, filename[ ] |
A string variable in which the returned file name is stored or an array of string variables in which multiple selected file names are stored. Specifying an array of string variables enables multiple selection in the dialog box. |
extension (optional) |
A string whose value is a 1- to 3-character default file extension. The default is no extension. |
filter (optional) |
A string whose value is a text description of the files to include in the list box and the file mask that you want to use to select the displayed files (for example, *.* or *.exe). The format for filter is: description,*. ext
The default is: "All Files (*.*),*.*"
|
initdir (optional) |
A string whose value is the initial directory name. The default is the current directory. |
aFlag (optional) |
An unsigned long whose value determines which options are enabled in the dialog box. The value of each option’s flag is calculated as 2 to the power of (index -1), where index is the integer associated with the option. The value of the aggregate flag passed to GetOpenFileName is the sum of the individual option flags. See the table in the Usage section for a list of options, the index associated with each option, and the option’s meaning. |
Integer. Returns 1 if it succeeds, 0 if the user clicks the Cancel button or Windows cancels the display, and -1 if an error occurs. If any argument’s value is null, GetFileOpenName returns null.
If you specify a DOS-style file extension and the user enters a file name with no extension, PocketBuilder appends the default extension to the file name. If you specify a file mask to act as a filter, PocketBuilder displays only files that match the mask.
You use the filter argument to limit the types of files displayed in the list box and to let the user know what those limits are. For example, to display the description Text Files (*.TXT) and only files with the extension .TXT, specify the following for filter:
"Text Files (*.TXT),*.TXT"
To specify more than one file extension in filter, enter multiple descriptions and extension combinations and separate them with commas. For example:
"PIF files, *.PIF, Batch files, *.BAT"
The dialog boxes presented by GetFileOpenName and GetFileSaveName are system dialog boxes. They provide standard system behavior, including control over the current directory. When users change the drive, directory, or folder in the dialog box, they change the current directory or folder. The newly selected directory or folder becomes the default for file operations until they exit the application, unless the optional initdir argument is passed.
The aFlag argument is used to pass one
or more options that determine the appearance of the dialog box.
For each option, the value of the flag is 2^(index -1)
,
where index is an integer associated with each
option as shown in the following table. You can pass multiple options
by passing an aggregate flag, calculated by adding the values of
the individual flags.
If you do not pass an aFlag, the Explorer-style open file dialog box is used. If you do pass a flag, the old-style dialog box is used by default. Some options do not apply when the Explorer-style dialog box is used. For those that do apply, add the option value for using the Explorer-style dialog box (2) to the value of the option if you want to display an Explorer-style dialog box.
For example, passing the flag 32768 (2^15) to the GetFileSaveName function opens the old-style dialog box with the Read Only check box selected by default. Passing the flag 32770 opens the Explorer-style dialog box with the Read Only check box selected by default.
In the following example, the dialog box has the title Open and displays text files, batch files, and INI files in the Files of Type drop-down list.
// instance variables // string is_filename, is_fullname int li_fileid if GetFileOpenName ("Open", is_fullname, is_filename, & "txt", "Text Files (*.txt),*.txt,INI Files " & + "(*.ini), *.ini,Batch Files (*.bat),*.bat") & < 1 then return li_fileid = FileOpen (is_fullname, StreamMode!) FileRead (li_fileid, mle_notepad.text) FileClose (li_fileid)
Copyright © 2004. Sybase Inc. All rights reserved. |
![]() |