Public dialog box -- openfilename Structure

Source: Internet
Author: User
Tags first string
Openfilename

OpenfilenameStructure containsGetopenfilenameAndGetsavefilenameThe function is used to initialize the information of the open or Save As dialog box. After the user closes the dialog box, the system returns the user selection information 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       lpstrInitialDir;   LPCTSTR       lpstrTitle;   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
Specify the size of this structure, in bytes.

Windows 95/98 and Windows NT 4.0:When compiling Windows 95/98 or Windows NT 4.0 with winver and _ win32_winnt >=0x0500, openfilename_size_version_400 is used for this member.

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

Hwndowner
The handle pointing to the owner dialog box. This member can be any valid window handle, or it can be null if the dialog box has no owner.
Hinstance
If FlagsThe ofn_enabletemplatehandle tag is set in the member, HinstanceThe member points to the memory object that contains a dialog template. If the ofn_enabletemplate tag is set, HinstanceIs LptemplatenameThe module of the member naming dialog box template. If neither of them is set, this member is ignored.

If the ofn_explorer flag is set, the system uses the subwindow of the default explorer dialog box as the specified template to create a dialog box. If the ofn_explorer tag is not set, the system uses the template to create an Old Style dialog box.

Lpstrfilter
A buffer pointing to a filter string ending with null characters. The last string in the buffer must end with two null characters.

The first character string is the display string of the filter description (for example, "text file"), and the second character specifies the filter style (for example, "*. txt "). To specify multiple filter styles for a display string, use semicolons (";") to separate the styles (for example, "*. txt; *. Doc; *. Bak "). A style string can contain valid file name characters and asterisk (*) wildcards. The style string cannot contain spaces.

The system cannot change the filter order. It pressesLpstrfilterThe specified order is displayed in the file type combo box.

IfLpstrfilterIs null. No filter is displayed in the dialog box.

Lpstrcustomfilter
Point to a static buffer that contains a pair of filter strings ending with null characters to retain the filtering style selected by the user. The first string describes the display string of the custom filter, and the second string is the filter style selected by the user. In the first application creation dialog box, the first string you specify can be any non-empty string. When you select a file, copy the Current Filter style to the second string in the dialog box. The reserved filter style can be in LpstrfilterOne of the specified styles in the buffer, or the filter styles entered by the user. When the next dialog box is created, the system uses this string to initialize the User-Defined file filter. If NfilterindexThe Member is 0, and the custom filter is used in the dialog box.

If the member is null, the dialog box cannot retain the custom filter style.

If the member is not null,NmaxcustfilterThe value of the member must be specifiedTcharsUnitLpstrcustomfilterThe buffer size. For the ANSI version, it is the number of bytes; For the Unicode version, it is the number of characters.

Nmaxcustfilter
Specify LpstrcustomfilterPrepare TcharsThe buffer size in units. For the ANSI version, it is the number of bytes; For the Unicode version, it is the number of characters. This buffer should be at least 40 characters long. If LpstrcustomfilterThe Member is null or a string pointing to null. This member is ignored.
Nfilterindex
Specifies the index of the selected filter in the file type control. Buffer pointing LpstrfilterContains a pair of defined filter strings. The index value of the first string of the filter is 1, and the second string is 2. 0 index indicates that LpstrcustomfilterThe specified custom filter. You can specify an index in the dialog box as the initial filter description and filter style. When you select a file, NfilterindexReturns the index of the currently displayed filter.

IfNfilterindexIs 0 andLpstrcustomfilterIs null.LpstrfilterThe first filter in the buffer. If all three members are 0 or null, the system does not use any filters and does not display any files in the list file of the dialog box.

Lpstrfile
Point to the buffer that contains the file name used by the initialization file name editing control. If no initial value is required, the first character of the buffer must be null. When GetopenfilenameOr GetsavefilenameWhen the function returns success, the buffer contains the drive, path, file name, and the selected file extension.

If the ofn_allowmultiselect mark is set and multiple files are selected, the buffer contains the file name of the selected file in the current directory. For the explorer Style dialog box, the directory and file name strings are separated by null, and there is an additional null after the file name. In the Old Style dialog box, strings are separated by spaces and the function uses short file names for names with spaces. You can useFindfirstfileThe function is converted between Long and Short file names. If you select only one file,LpstrfileThe string is not separated between the path and the file name.

If the buffer is too small, the function returns false andCommdlgextendederrorThe function returns fnerr_buffertoosmall .. In this case,LpstrfileThe first two bytes of the buffer contain the required size (bytes or characters ).

Nmaxfile
Specify LpstrfileBuffer size, Tchars. For the ANSI version, it is the number of bytes; For the Unicode version, it is the number of characters. This buffer must be sufficient for storing the path and file name strings, including the ending null characters. If the buffer size is too small, GetopenfilenameAnd GetsavefilenameThe minimum length of the false buffer returned by the function should be 256 characters.
Lpstrfiletitle
The buffer (without path information) that directs to the file name and extension of the selected file ). This member can be null.
Nmaxfiletitle
Specify LpstrfiletitleBuffer size, Tchars. For the ANSI version, it is the number of bytes; For the Unicode version, it is the number of bytes. If LpstrfiletitleIs null. This member is ignored.
Lpstrinitialdir
Point to a string ending with an empty character. 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 are different operating rules for selecting the initial directory.

Windows 2000:

  1. IfLpstrfileContains a path, which is the initial directory.
  2. Otherwise,LpstrinitialdirThe specified directory is the initial directory.
  3. IfLpstrinitialdirIs null, and the current directory contains some files of the specified filter type. The initial directory is the current directory.
  4. Otherwise, if the application used to open the "Save As dialog box" in the past, use the recently selected path as the initial directory. However, if an application has not been running for a long time, the path it saves will be discarded.
  5. Otherwise, the initial directory is the private file directory (my documents) of the current user ).
  6. Otherwise, the initial directory is a desktop folder.

Windows 98:

  1. LpstrinitialdirSpecify the initial directory.
  2. IfLpstrinitialdirIs null andLpstrfileContains a path, which is the initial directory.
  3. Otherwise, if the current directory contains some files of the specified filtering type, the initialization directory is the current directory.
  4. Otherwise, the initial directory is the private file directory (my documents) of the current user ).

Earlier versions of Windows and Windows NT/2000:

  1. LpstrinitialdirSpecify the initial directory.
  2. IfLpstrinitialdirIs null andLpstrfileContains a path, which is the initial directory.
  3. Otherwise, the initial directory is the current directory.
Lpstrtitle
Point to the string placed in the title bar of the dialog box. If this member is null, the system uses the default title (save as or open)
Flags
Bit Flag settings, you can use to initialize the dialog box. When the dialog box returns, the tags it sets indicate the user input. This member can be a combination of the following tags.

Mark Meaning
Ofn_allowmultiselect You can select multiple names in the specified file name list box. If you have set the ofn_explorer tag at the same time, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.

If you select more than one file,LpstrfileBuffer returns the names of all selected files in the current directory.NfileoffsetThe Member is the offset (in bytes or characters) to the first file name, andNfileextensionMembers are not used. For the explorer Style dialog box, the directory and file name are separated by null, And the last file name is followed by an additional null. This format enables the Explorer-Style dialog box to return long file names containing spaces. For the Old Style dialog box, the directory and file string are separated by spaces. The function uses short file names for file names with spaces. You can useFindfirstfileThe function converts short and long file names.

If you specify a custom template for the Old Style dialog box, the definition of the file name list must contain the lbs_extendedsel value.

Ofn_createprompt If you specify a file that does not exist, the mark dialog box prompts you whether to create the file. If you choose to create this file, the dialog box is closed and the function returns the specified name. Otherwise, the dialog box continues. If you use this tag with the ofn_allowmultiselect mark, the dialog box allows you to specify a non-existent file.
Ofn_dontaddtorecent Windows 2000:Prevent the system from adding shortcuts to the selected files to the recently used documents. The location of the directory to be retrieved is also indicated by csidl_recent.ShgetspecialfolderlocationFunction.
Ofn_enablehook ActivateLpfnhookThe hook function specified by the Member.
Ofn_enabletransferdeno= Windows 2000:When a user opens a folder, a dialog box is sentCdn_includeitemNotify the message to yourOfnhookprocProgram. The dialog box sends a notification to each project in the recently opened folder. These messages allow you to control the list of folder items displayed in the dialog box.
Ofn_enablesizing Windows 2000, Windows 98:The explorer Style dialog box can be resized with the mouse or keyboard. The explorer-style open and save as dialog box allows you to adjust the size regardless of whether the flag is set. This flag is only required when you provide a hook program or custom template. The Old Style dialog box cannot be resized.
Ofn_enabletemplate NoteLptemplatenameThe Member is the name of the template resource pointing to the dialog box.HinstanceIn the member Identification Module.

If the ofn_explorer flag is set, the system uses the specified template to create a dialog box, which is a subwindow of the default explorer Style dialog box. If the ofn_explorer tag is not set, the Old Style dialog box is used to replace the default dialog box.

Ofn_enabletemplatehandle NoteHinstanceMembers can recognize data blocks that contain the pre-loaded dialog template. If this tag is specified, the system ignores it.Lptemplatename.

If the ofn_explorer flag is set, the system uses the specified template to create a dialog box, which is a subwindow of the default explorer Style dialog box. If the ofn_explorer tag is not set, the system uses the template to create an Old Style dialog box to replace the default dialog box.

Ofn_explorer Indicates that any new Explorer-style user modules are used in the open or Save As dialog box. For more information, see Explorer-style hook procedures and explorer-style custom templates.

By default, the open and save as dialog box uses the Explorer-style user interface, regardless of whether this flag is set. This tag is required only when you provide a hook program or custom template or set the ofn_allowmultiselect tag.

If you want to use the old style interface, omit the ofn_explorer tag and provide a replacement 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 and let it return false.

Ofn_extensiondifferent Specify the extension andLpstrdefextThe specified extension is different. IfLpstrdefextIs null. This flag is not used by the function.
Ofn_filemustexist You can only enter the name of an existing file in the Login Field of the file name. If the tag is specified and the user enters an invalid name, the dialog box shows a waiting message box. If this tag is specified, the ofn_pathmustexist tag is also used.
Ofn_forceshowhidden Windows 2000:The system and hidden attribute files are forcibly displayed to overwhelm the display or hidden files set by the user. Otherwise, files with system and hidden tags are not displayed.
Ofn_hidereadonly Hide the read-only check box.
Ofn_longnames For the Old Style dialog box, this mark causes the dialog box to use a long file name. If this tag is not specified, or if the ofn_allowmultiselect tag is also set, the Old Style dialog box uses a short file name (in the 8.3 format) for the file name with spaces ).

Ignore this flag in the explorer Style dialog box. A long file name is usually displayed.

Ofn_nochangedir If you change the directory when searching for a file, restore the initial value of the current directory.
Ofn_nodereferencelinks The Guide dialog box returns the path and file name for the selected shortcut (. lnk) file. If this value is not specified, the dialog box returns the path and file name of the file referenced by this shortcut.
Ofn_nolongnames For the Old Style dialog box, This identifier causes the dialog box to use the short file name (8.3 format ).

Ignore this flag in the explorer Style dialog box. A long file name is usually displayed.

Ofn_nonetworkbutton Hide and display style buttons.
Ofn_noreadonlyreturn Specify that the returned file does not contain the read-only check box and is not in the write-protected directory.
Ofn_notestfilecreate The specified file is not created before the dialog box is closed. If the application saves the file to a created non-image sharing, this tag should be specified. When an application specifies this flag, the library cannot check write protection, the disk is full, open the drive door or network protection. The application must be careful when using this flag, because once the file is closed, it cannot be re-opened.
Ofn_novalidate The public dialog box allows invalid characters in the returned file name. Typically, the program being called uses a hook programFileokstringMessage check file name. If the text box in the editing control is empty or contains only spaces, the file and directory list boxes are updated. If the text box in the editing control contains something elseNfileoffset andNfileextensionIs generated by analyzing the text. No Default extension is added to text, and no text is copiedLpstrfiletitleThe specified buffer.

IfNfileoffsetThe specified value is smaller than 0, and the file is invalid. Otherwise, the file name is valid. If ofn_novalidate is not specified,NfileextensionAndNfileoffsetCan be used.

Ofn_overwriteprompt If the selected file already exists, use the Save As dialog box to generate a message box. You must confirm whether the file is overwritten.
Ofn_pathmustexist Specify the path and file name that the user can only enter. If this tag is used and you type an effective path and file name in the input field of the file name, the function of the dialog box displays a waiting message.
Ofn_readonly When the dialog box is created, the selected read-only check box is displayed. This flag indicates the status of the read-only check box when the dialog box is closed.
Ofn_policaware Indicates that ifOpenfileThe function fails because of a network share conflict. This error is ignored and the selected file name is returned in the dialog box.

If this flag is not set, when the selected file name conflicts with network sharing, the dialog box will send a notification to your hook program. If you have set the ofn_explorer flag, the dialog box is sentCdn_1_violationSend messages to the hook program. If you have not set ofn_explorer, send it in the dialog boxVistringThe registered message is sent to the hook program.

Ofn_showhelp Display the Help button in the dialog box.HwndownerThe member must specify a window, which is sent as the receiving dialog boxHelpmsgstringRegistered message. The message is sent in the dialog box when you click the Help button.

When you click the Help button, An Explorer-Style dialog box is sentCdn_helpNotify the message to your hook program.

Nfileoffset
Specify from path start to pass LpstrfileThe specified file name string is 0-based offset Tchars. For the ANSI version, it is the number of bytes; For the Unicode version, it is the number of characters. For example, if LpstrfilePoint to the following string, "C:/dir1/dir2/file. Ext", which contains the position value 13 indicating the "file. Ext" string offset.

If you select more than one file,NfileoffsetIs the offset to the first file name.

Nfileextension
Specify from path start to pass LpstrfileIn the specified file name string, the extension is 0-based offset Tchars. For the ANSI version, it is the number of bytes; For the Unicode version, it is the number of bytes. For example, if LpstrfilePoint to the following string, "C:/dir1/dir2/file. Ext", which contains 18 values. If the user does not enter an extension and LpstrdefextIs null. The offset specified by this member is the end character null. If you enter a "." As the final character in the file name, the Member is 0.
Lpstrdefext
Point to the buffer containing the default extension. If you forget to enter the extension, GetopenfilenameAnd GetsavefilenameAppend the extension to the file name. This string can be any length, but only the first three characters are appended. A string cannot contain a period (.). If the member is null and the user forgets to enter an extension, no extension is appended.
Lcustdata
Specifies the data defined by the application. LpfnhookHook program uploaded by the system recognized by members. When the system sends Wm_initdialogMessages to programs, messages LparamThe parameter points to OpenfilenameStructure. The hook program can use this pointer to obtain Lcustdata.
Lpfnhook
Points to a hook program. Unless FlagsThe member contains the ofn_enablehook tag, or the member is ignored.

IfFlagsThe ofn_explorer tag in the member is not set,LpfnhookPoint toOfnhookprocoldstyleHook program, which intentionally receives messages from the dialog box. The hook program returns false to pass a message to the default Dialog Box program or returns true to discard the message.

If ofn_explorer is set,LpfnhookPoint toOfnhookprocHook program. This hook program receives notifications from the dialog box. This hook program also receives messages from additional controls defined by a subdialog template. The hook program does not intentionally receive messages from standard controls in the default dialog box.

Lptemplatename
Point to a string ending with an empty character. The string is the name of the template resource in the dialog box. HinstanceIn the member Identification Module. For limited dialog box resources MakeintresourceReturned value. Unless FlagsThe ofn_enabletemplate tag is set in the member, or the member is ignored.

If the ofn_explorer flag is set, the system uses the specified template to create a dialog box, which is a subwindow of the default explorer Style dialog box. If the ofn_explorer tag is not set, the system uses the template to create an Old Style dialog box to replace the default dialog box.

Pvreserved
Retained.
Dwreserved
Retained.
Flagsex
Windows 2000:Set the bit flag. You can use it to initialize the dialog box. This member can be a combination of the following tags.

Mark Meaning
Ofn_ex_noplacesbar If this tag is set, the location bar is not displayed. If this tag is not set, the explorer-Style dialog box contains the location bar of commonly used file icons, such as favorites and desktop.

Requirement

Windows NT/2000:Windows NT 3.1 or higher is required.
Windows 95/98:Windows 95 or higher is required.
Header:Defined in commdlg. h; included in windows. h.
UNICODE:It is defined as a Unicode and ANSI structure.

See

Common Dialog Box library overview, Common Dialog Box structures,Getopenfilename,Getsavefilename,Shgetspecialfolderlocation

Built on Thursday, May 11,200 0

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.