MFC CFileDialog用法例子。


 Set it to TRUE to construct a File Open dialog box. Set it to FALSE to construct a File Save As dialog box.

void CCompFileDlg::OnDirbrowser()

{

    // TODO: Add your control notification handler code here

    CFileDialog fileDialog(TRUE);

    if (fileDialog.DoModal() == IDOK) {

        CString pathName = fileDialog.GetPathName();

        int index = pathName.ReverseFind('\\');

        if (index == -1) {

            AfxMessageBox(L"The Directory is not correct!");

            return;

        }

        m_DirPathString = pathName.Left(index);

        UpdateData(FALSE);

    }

}

 

void CCompFileDlg::OnFilebrowser()

{

    // TODO: Add your control notification handler code here

    CFileDialog fileDialog(FALSE);

    if (fileDialog.DoModal() == IDOK) {

        m_FilePathString = fileDialog.GetPathName();

        UpdateData(FALSE);

    }

}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM