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