急急急!!!点击我的对话框上的“浏览”按钮,要弹出一个标准的文件浏览框,怎么办??

解决方案 »

  1.   

    CFileDialog dlg(true);
    or
    LPMALLOC pMalloc;
    if (::SHGetMalloc(&pMalloc) == NOERROR)
    {
    BROWSEINFO bi;
    char pszBuffer[MAX_PATH];
    LPITEMIDLIST pidl;
    bi.hwndOwner = GetSafeHwnd();
    bi.pidlRoot = NULL;
    bi.pszDisplayName = pszBuffer;
    bi.lpszTitle = _T("Select a Starting Directory");
    bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
    bi.lpfn = NULL;
    bi.lParam = 0;
    if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
    {
    if (::SHGetPathFromIDList(pidl, pszBuffer))

    // DoingSomethingUseful(pszBuffer);
    AfxMessageBox(pszBuffer);
    }
    pMalloc->Free(pidl);
    }
    pMalloc->Release();
    }
      

  2.   

    CString str;
    CFileDialog m_ldFile(TRUE,_T("txt"),_T("*.txt"),OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
    _T("(*.txt)|*.txt|"));
    if(m_ldFile.DoModal() == IDOK)
        str = m_ldFile.GetPathName();