Simplest method to create an OpenFileDialog and return the pathname to edittext box using MFC applications

前端 未结 1 848
一向
一向 2021-01-24 12:09

How to create a MFC application in which I want to implement an OpenFileDialog box and the resultant path name to be displayed on the edittext box.

相关标签:
1条回答
  • 2021-01-24 12:30

    Here is an example that will help you get started:

    const TCHAR szFilter[] = _T("CSV Files (*.csv)|*.csv|All Files (*.*)|*.*||");
    CFileDialog dlg(FALSE, _T("csv"), NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, szFilter, this);    
    if(dlg.DoModal() == IDOK)
    {
        CString sFilePath = dlg.GetPathName();
        m_FilePathEditBox.SetWindowText(sFilePath);
    }
    
    0 讨论(0)
提交回复
热议问题