Public dialog - OpenFileName structure

zhaozj2021-02-08  202

OpenFileName

The OpenFileName structure contains information that getopenFileName and GetSaveFileName functions are used to initialize the open or saved as dialog box. After the user closes the dialog, the system returns the selection information about the user to this structure.

Typedef struct tagofn {

DWORD LSTRUCTSIZE;

HWND HWNDOWNER;

Hinstance hinstance;

LPCTSTR LPSTRFILTER;

LPTSTR LPSTRCUSTOMFILTER;

DWORD NMAXCUSTFILTER;

DWORD NFILTERINDEX;

LPTSTR LPSTRFILE;

DWORD NMAXFILE;

LPTSTR LPSTRFILETITLE;

DWORD NMAXFILETITLE;

LPCTSTR LPSTRINIALDIR;

LPCTSTR LPSTRTILE;

DWORD FLAGS;

Word nfileoffset;

Word NfileExtension;

LPCTSTR LPSTRDEFEXT;

LPARAM LCUSTDATA;

LPOFNHOOKPROC LPFNHOOK;

LPCTSTR LPTEMPLATENAME;

#if (_WIN32_WINNT> = 0x0500)

Void * pvreserved;

DWORD DWRESERVED;

DWORD flagsex;

#ENDIF / / (_WIN32_WINNT> = 0x0500)

OpenFileName, * lpopenfilename;

member

LstructSize

Specifies the size of this structure, in bytes.

Windows 95/98 and Windows NT 4.0: Specially compiled for Windows 95/98 or Windows NT 4.0, and compiled with WINVER and _WIN32_WINNT> = 0x0500, using OpenFileName_Size_Version_400 for this member.

Windows 2000 and later: This parameter uses sizeof (OpenFileName).

HWndowner

Point to the handle of the owner dialog window. This member can be any valid window handle, or if the dialog does not have owner it can be NULL.

Hinstance

If

The Flags member sets the OFN_ENABLETEMPLATEHANDLE tag,

Hinstance members point to memory objects containing a dialog template. If the OFN_ENABLETEMPLATE tag is set,

Hinstance is a point to pass

LPTemplatename member named dialog template module. If both are not set, this member is ignored.

If the OFN_EXPLORER tag is set, the system uses the sub-window of the EXPLORER style to create a dialog as the specified template. If the OFN_EXPLORER tag is not set, the system uses templates to create an old style dialog.

LPSTRFILTER

Point a buffering of a pair of filter strings ending with empty characters. The last string in the buffer must end with two NULL characters.

The first string is a display string (eg, "text file") description, and the second character specifies the filter style (for example, "*. Txt"). To specify a plurality of filter styles for a display string, divide the style (for example, "*. TXT; *. Doc; *.,"). A style string can contain a valid file name character and an asterisk (*) wildcard. Spaces cannot be included in the style string. The system cannot change the order of the filter. It is displayed in the file type combo box by the order specified by lpstrfilter.

If the LPSTRFILTER is NULL, the dialog box cannot display any filters.

LPSTRCUSTOMFILTER

Point a static buffer that contains a pair of filter strings that are ended by empty characters, which is to retain the filter style selected by the user. The first string is to describe the display string of custom filter, and the second string is the filter style selected by the user. The first time your application is established, and the first string you specify can be any non-empty string. When a user selects a file, the dialog is copied to the current filter style to the second string. Keep the filter style can be

One of the specified styles specified in the LPSTRFILTER buffer, or the filter style entered by the user. The system uses this string to initialize user-defined file filters when the next dialog is established. in case

NfilterIndex members are 0, and the dialog uses custom filters.

If this member is NULL, the dialog box cannot retain the user-defined filter style.

If this member is not NULL, the value of the NMAXCustFilter member must specify the size of the LPSTRCUSTOMFILTER buffer in tchars. For the ANSI version, it is the number of bytes; for Unicode versions, it is the number of characters.

Nmaxcustfilter

Specify

LPSTRCUSTOMFILTER is ready

Tchars is the unit buffer size. For the ANSI version, it is the number of bytes; for Unicode versions, it is the number of characters. This buffer should minimize 40 characters long. in case

LPSTRCUSTOMFILTER members are NULL or point to NULL strings, and this member is ignored.

NfilterIndex

Specifies the index of the filter currently selected in the file type control. Buffer points

LPSTRFilter strings of a pair of defined filters. The index value of the first pair of strings of the filter is 1, the second pair is 2, and the like. 0 index pointed out

LPSTRCUSTOMFilter Specifies the custom filter. You can specify an index as the original filter description and filter style for the dialog. When the user selects a file,

NfilterIndex returns the index of the currently displayed filter.

If NFILTERINDEX is 0 and LPSTRCUSTOMFILTERs are NULL, the system uses the first filter in the LPSTRFILTER buffer. If all three members are 0 or NULL, the system does not use any filters, and no files are displayed in the list file of the dialog box.

LPSTRFILE

Point buffers that contain the file name used by the initialization file name editing control. If the initial value is not required, the first character of this buffer must be NULL. when

GetopenFileName or

When the GetSaveFileName function returns to success, this buffer contains the drive, path, file name, and extension of the selected file.

If the OFN_ALLOWMULTITISELECT tag is set and the user selects multiple files, buffering the file name of the selected file in the current directory. For the Explorer style dialog, directory, and file name strings are separated by NULL, there is an additional null after the file name. For the old style dialog, the string is separated by the space and the function is a file name with spaces. You can use the FindFirstFile function to convert between the length file name. If the user selects only one file, the LPSTRFILE string is not separated between the path and the file name. If the buffer is too small, the function returns false and the CommdlgeXtendedError function returns FnerR_Buffertoosmall .. In this case, the first two bytes of the LPSTRFILE buffer include the required size (bytes or characters).

Nmaxfile

Specify

LPSTRFILE buffer size,

Tchars is in units. For the ANSI version, it is the number of bytes; for Unicode versions, it is the number of characters. This buffer must be sufficient to store paths and file name strings, including NULL characters ending. If the buffer is too small,

GetopenFileName and

GetSaveFileName function returns false (false) buffer minimum should be 256 characters long.

LPSTRFileTitle

Point buffer (without path information) of the file name and extension of the file that receives the selected file. This member can be NULL.

NmaxFileTitle

Specify

LPSTRFILETITLE buffer size,

Tchars is in units. For an ANSI version, it is the number of bytes; for Unicode versions, it is the number of bytes. in case

LPSTRFILETITLE is NULL, which is ignored.

LPSTRINTIALDIR

Point to a string ended with empty characters, you can specify the initial directory in this string. Pointer to a null Terminated String That CAN Specify The Initial Directory. On different platforms, there is different algorithms in the initial directory.

Windows 2000:

If lpstrfile contains a path, this path is the initial directory. Otherwise, lpstrinitialdir is specified for the initial directory. If lpstrinitialdir is null, and the current directory contains some files that specifies the filter type, the initial directory is the current directory. Otherwise, if the application uses the open 哐 saved as dialog in the past, use the most recently selected path as the initial directory. However, if an application has not run for a long time, the path to which it saves will be discarded. Otherwise, the initial directory is the current user's private file directory (ie my document). Otherwise, the initial directory is a desktop folder.

WINDOWS 98:

LPSTRINIALDIR specifies the initial directory. If lpstrinitialdir is null and lpstrfile contains a path, then this path is the initial directory. Otherwise, if the current directory contains some files of the specified filter type, then the initialization directory is the current directory. Otherwise, the initial directory is the current user's private file directory (ie my document).

Early versions of Windows and Windows NT / 2000:

LPSTRINIALDIR specifies the initial directory. If lpstrinitialdir is null and lpstrfile contains a path, then this path is the initial directory. Otherwise, the initial directory is the current directory.

LPSTRTILE

Point to the string placed in the title bar of the dialog. If this member is NULL, the system uses the default title (saved as or open) Flags

Bit tag setting, you can use to initialize the dialog. When the dialog returns, these tags it set indicates the user's input. This member can be a combination of the following tags.

Tags Idmn_AllowmultiSelect Specify the file name list box to allow multiple choices. If you set up the OFN_EXPLORER tag, the dialog uses the Explorer style user interface; otherwise it uses the old-style user interface. If the user selects more than one file, the LPSTRFILE buffer returns the file name of all selected files in the current directory. NfileOffset members are offset (bytes or characters) to the first file name, and NFILEEXTENSION members are not used. For the Explorer style dialog, directory, and file names are separated by NULL, with additional null after the last file name. This format allows the Explorer style dialog to return a long text name that contains spaces. For old-style dialogs, directory and file strings are separated by spaces, the function is a file name with a space name. You can use the FindFirstFile function to convert between short text names and long file names. If you specify a custom template for an old style dialog, the definition of the file name list box must contain the lbs_extendedsel value. OFN_CREATEPROMPT If the user specifies a file that does not exist, this tag uses the dialog to prompt the user to create a new file. If the user selects a new file, the dialog is turned off and the function returns the specified name; otherwise, the dialog continues to stay. If you use this tag with the OFN_ALLOWMULTITISELECT tag, the dialog allows the user to specify a file that does not exist. OFN_DONTDTTORECENTWINDOWS 2000: Prevents the system from adding the quick-ended file to the recently used documentation. To retrieve the location of the directory, call the SHGETSPECIALFOLDERLOCATION function of the CSIDL_RECENT tag. The OFN_ENABLEHOOK is activated in the Hook function specified in the LPFNHOK member. OFN_ENABLEINCLUDENOTIFYWINDOWINDOWS 2000: When the user turns on a folder, cause the dialog to send a CDN_INCLUDEITEM notification message to your OFNHOOKPROC program. The dialog sends a notification for each project in the recently opened folder. These messages allow you to control a list of folder items that are displayed in the dialog. OFN_ENABLESIZINGWINDOWS 2000, Windows 98: Make the Explorer style dialog box can use your mouse or keyboard to adjust the size. When the default, the open and saving of the Explorer style is allowed to be resized, regardless of whether this tag is set. This tag is only necessary when you provide a hook program or custom template. The old style dialog is not allowed to adjust the size. OFN_ENABLETEMPLATE Indicates that the LPTemplatenAme member is the name of the dialog template resource, which is in the module identified by the Hinstance member. If the OFN_EXPLORER tag is set, the system uses the specified template to create a dialog, which is the sub-window of the default Explorer style dialog. If the OFN_EXPLORER tag is not set, the system uses the old-style dialog to replace the default dialog. The OFN_ENABLETEMPLATEHANDLE indicates a data block that contains the preload dialog template that Hinstance members can identify. If this tag is specified, the system ignores the LPTemplatename. If the OFN_EXPLORER tag is set, the system uses the specified template to create a dialog, which is the sub-window of the default Explorer style dialog. If the OFN_EXPLORER tag is not set, the system uses templates to create an old-style dialog to replace the default dialog. OFN_EXPLORER pointers any open or saved as a dialog box using the new Explorer style user module. For more information, see Explorer-Style Hook Procedures and Explorer-Style Custom Templates.

Under the default, open and saved as dialog box uses the Explorer style user interface, regardless of whether this tag is set. This tag is only required when you provide a hook program or a custom template or setting the OFN_ALLOWMULTITISELECT tag. If you want to use the old style interface, omit the OFN_EXPLORER tag and provide an instead of the old style template or hook program. If you want to use the old style but do not need a custom template or hook program, simply provide a hook program that returns false. OFN_EXTENSIONDIFFERENT Specifies the extension of a file input by the user to the extension specified by LPSTRDeFext. If LPSTRDEFEXT is NULL, the function does not use this tag. OFN_FILEMUSTEXIST Specifies the user only in the file name login field to enter the name of the existing file. If this tag is specified and the user enters an invalid name, the dialog program displays a waiting message box. If this tag is specified, the OFN_PATHMUSTEXIST tag is also used. The OFN_FORCESHOWHIDDENWINDOWS 2000: Forces the file that is hidden in the system and hide the property, the display of the user settings or does not display the hidden file. Otherwise, the file with the system and hidden tags is not displayed. OFN_HIDEREADOONLY hides the read-only check box. OFN_LONGNAMES For the old style dialog, this tag causes the dialog to use long file names. If this tag is not specified, or if the OFN_ALLOWMULTITISELECT tag is also set, the Old-style dialog box uses a file name (8.3 format) with a file name with space. The Explorer style dialog ignores this tag, usually displays a long file name. Ofn_nochangedir Restores the current directory to its initial value when the user changes the directory when searching the file. The OFN_NodeReferenceLinks Boot dialog returns the path and file name for the selected shortcut (.LNK) file. If this value is not specified, the dialog returns the path and file name of the file referenced by this shortcut. Ofn_nolongnames For the old style dialog, this identity causes the dialog to use the short message name (8.3 format). The Explorer style dialog ignores this tag, usually displays a long file name. OFN_NONETWORKBUTTON hides and displays the style button. The file specified by OFN_NOREADOONLYRETURN Specifies the read-only check box, not in the write-protected directory. The OFN_NOTESTFILECREATE specifies that the file is not established before the dialog is turned off. This tag should be specified if the application saves files to a built-in-style sharing. When an application specifies this tag, the library cannot check the write protection, the disk is full, open the drive door or network protection. The application uses this tag must be carefully executed, because once the file is turned off, it cannot be reopened. The OFN_NOVALIDATE Specifies the public dialog to allow invalid characters in the returned file name. Typically, the program being called uses a hook program to check the file name via the FileoKstring message. If the text box in the edit control is empty or only the space is included, the file and directory list box are updated. If the text box in the edit control contains something else, the setting value of NfileOffset and NfileExtension is generated by analyzing text. No default extension is added to the text, nor is therefore copied to the cache specified by LPStrFileTitle. If the value specified by NFileOffset is less than 0, the file is invalid. Otherwise, the file name is valid. If OFN_NOVALIDATE is not specified, NfileExtension and NFileOffset can be used. The OFN_OVERWRITEPROMPT If the selected file already exists, use the Save As dialog to generate a message box.

The user must confirm if this file is cleared. OFN_PATHMUSTEXIST Specifies the path and file name that the user can only enter. If this tag is used and the user is typed in the file name input field, the dialog function displays a waiting message. When the dialog is established, the option is displayed when the dialog is established. This tag indicates that only the status of read-only the check box when the dialog is turned off. OFN_SHAREAWARE pointed out that if the OpenFile function fails because the network sharing conflict, this error is ignored and the dialog returns the selected file name. If this tag is not set, the dialog box sends a notification to your hook program when the user selects a network sharing conflict. If you set the OFN_EXPLORER tag, the dialog sends a cDN_shareviological message to the hook program. If you don't set the OFN_EXPLORER, the dialog box sends a message to the hook program for SHAREVISTRING. OFN_SHOWHELP makes the dialog box display help buttons. HWndowner members must specify a window, which is a message registered as a HelpMsggString registered as the receiving dialog box, and sends this message when the user clicks the help button. When the user clicks on the Help button, a dialog of an Explorer style sends a cdn_help notification message to your hook program. NfileOffset

Specify starting from the path to pass

LPSTRFILE specified file name string based on 0 offset,

Tchars is in units. For the ANSI version, it is the number of bytes; for Unicode versions, it is the number of characters. For example, if

LPSTRFILE points to the following strings, "C: /Dir1/dir2/file.ext", which contains the position value 13 indicating the "file.ext" string offset.

If the user selects more than one file, the NFileOffset is offset to the first file name.

NfileExtension

Specify starting from the path to pass

LPSTRFILE specified in the file name string extension based on 0 offset,

Tchars is in units. For an ANSI version, it is the number of bytes; for Unicode versions, it is the number of bytes. For example, if

LPSTRFILE points to the following strings, "C: /Dir1/dir2/file.ext", which contains the value of 18. If the user does not enter an extension and

LPSTRDEFEXT is NULL, and the offset specified by this member is the end character NULL. If the user enters a "." As the last character in the file name, this member is 0.

LPSTRDEFEXT

Point buffering containing the default extension. If the user forgot to enter the extension,

GetopenFileName and

GetSaveFileName Additional this extension is in the file name. This string can be any length, but only three characters are attached. String should not contain a period (.). If this member is null and the user forgets to enter an extension, there will be no extension is attached.

LCUSTDATA

Specify the data defined by the application, this data is

The hook program transmitted by the system of the LPFNHOOK member recognizes. System sends

WM_INITDIALOG message to the program, message

The LPARAM parameter points to the specified when the dialog is established.

OpenFileName structure. Hook programs can be obtained using this pointer

LCUSTDATA value.

LPFNHOOK

Point to a hook program. unless

The Flags member contains the OFN_ENABLEHOK tag, or this member will be ignored.

If the OFN_EXPLORER tag is not set in the Flags member, LPFNHOOK points to an OFNHOOKPROCOLDSTYLE hook program, which is intentionally received from the dialog box. The hook program returns false to pass a message to the default dialog program or return TRUE to discard the message.

If OFN_Explorer is set, LPFNHOOK points to an OFNHOKPROC hook program. This hook program receives the notification message issued from the dialog. This hook program also receives the message of additional controls defined by a sub-dialog template. The hook program does not intentionally receive the message of the standard control of the default dialog. LPTemplatename

Point to a string ended with empty characters, strings are the name of the dialog template resource, and resources are saved can be

The Hinstance member identifies the module. For limited dialog resources, this can be passed

The value returned by makeintResource. Unless

The Flags member sets the OFN_ENABLETEMPLATE tag, or this member is ignored.

If the OFN_EXPLORER tag is set, the system uses the specified template to create a dialog, which is the sub-window of the default Explorer style dialog. If the OFN_EXPLORER tag is not set, the system uses templates to create an old-style dialog to replace the default dialog box.

PVReServed

Retained.

DWRESERVED

Retained.

Flagsex

Windows 2000: Setting the bit tag, you can use to initialize the dialog. This member can be a combination of the following tags.

The tag contains OFN_EX_NOPLACESBAR If this tag is set, the location column is not displayed. If this tag is not set, the Explorer style dialog box contains a location bar that typically uses the file icon, such as a favorites and desktop.

demand

Windows NT / 2000: Need Windows NT 3.1 or higher. Windows 95/98: WINDOWS 95 or higher. Header: Defines in CommDlg.h; contained in Windows.h. Unicode: As a unicode and ansi structure definition.

See

Common Dialog Box Library Overview, Common Dialog Box Structure, GetopenFileName, GetsaveFileName, ShgetspecialFolderLocation

Built on Thursday, May 11, 2000

转载请注明原文地址:https://www.9cbs.com/read-3423.html

New Post(0)