Question:What is the function of getopenfilename? It is better to have an example.
Original Discussion link:Http://community.csdn.net/expert/topicview1.asp? Id = 723371
Forum:Basic ClassAudit Team:VC/MFC
Questioner:MuhuairuReleased:
Thanks:Acptvc
Keywords:VC/mfc function base class HTTP reference file name hwnd null handle getopenfilename openfilename ofn
Answer:What is the function of getopenfilename? It is better to have an example.
------------------------------------------------------------- The getopenfilename function is used to create an open dialog box, allowing you to specify the drive, directory, and one or more file names to open. Its prototype is as follows:
Bool getopenfilename (
Lpopenfilename lpofn // initialization data
);
The parameter lpofn is a pointer to the openfilename structure, which contains the information required to initialize the "open" dialog box. When this function returns, this structure contains the user's selected information.
You can refer to the following code:
Openfilename ofn; // Common Dialog Box Structure
Char szfile [260]; // buffer for file name
Hwnd; // owner window
Handle Hf; // file handle
// Initialize openfilename
Zeromemory (& ofn, sizeof (openfilename ));
Ofn. lstructsize = sizeof (openfilename );
Ofn. hwndowner = hwnd;
Ofn. lpstrfile = szfile;
Ofn. nmaxfile = sizeof (szfile );
Ofn. lpstrfilter = "All/0 *. */0 text/0 *. txt/0 ";
Ofn. nfilterindex = 1;
Ofn. lpstrfiletitle = NULL;
Ofn. nmaxfiletitle = 0;
Ofn. lpstrinitialdir = NULL;
Ofn. Flags = ofn_pathmustexist | ofn_filemustexist;
// Display the open dialog box.
If (getopenfilename (& ofn) = true)
HF = createfile (ofn. lpstrfile, generic_read,
0, (lpsecurity_attributes) null,
Open_existing, file_attribute_normal,
(Handle) null );
For more information, see:
Http://msdn.microsoft.com/library/default.asp? Url =/library/en-US/shellcc/platform/commctls/winui/commdlg_3cbp.asp
-Microsoft Global Technical Center VC Technical Support
This post is provided as "the status quo" without any guarantee and does not grant any rights. For more information, see the terms of use.
Http://support.microsoft.com/directory/worldwide/zh-cn/community/terms_chs.asp ).
To create a better discussion environment for you, please join our user satisfaction survey
(Http://support.microsoft.com/directory/worldwide/zh-cn/community/survey.asp? Key = (S, 49854782 )).