[英]open dialog in MFC C++
I'm trying to open a file via the default open button in menu in a MFC project in visual studio 2013. I have used a browse button and I'v used "OnBnClickedButton" function to get the address of opened file but now there is no such function. 我试图通过Visual Studio 2013的MFC项目中菜单中的默认打开按钮打开文件。我使用了浏览按钮,并使用“ OnBnClickedButton”功能获取打开文件的地址,但是现在有没有这样的功能。 what should I do?
我该怎么办?
请参阅MSDN页面上的CWinApp :: OnFileOpen
A default MFC application (SDI or MDI) created by the wizard does not have a private implementation of the Open (or Save) code, it will call the default framework code (see ScottMcP-MVP answer) 向导创建的默认MFC应用程序(SDI或MDI)没有公开(或保存)代码的私有实现,它将调用默认框架代码(请参见ScottMcP-MVP答案)
Normally, you should add an handler for the ID_FILE_OPEN in your application to call CFileDialog and handle the file yourself. 通常,应在应用程序中为ID_FILE_OPEN添加一个处理程序,以调用CFileDialog并自行处理该文件。
CFileDialog is better used as a modal dialog CFileDialog最好用作模式对话框
CFileDialog dlg(TRUE); // TRUE is to tell the dialog is used as an open CFileDialog.
if ( dlg.DoModal() == IDOK )
{
CString fullPathName = dlg.GetPathName(); // get the full path name of the selected file.
//... add some of your own code to open the file and read it.
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.