只显示文件夹的窗体,就像保存文件时的窗体,但是只得到路径和文件名,不保存。谢了先

解决方案 »

  1.   

    LPMALLOC pMalloc;
    BROWSEINFO bi;
    LPITEMIDLIST pidl; 
    ::ZeroMemory(m_directory,sizeof(m_directory));
    ::ZeroMemory(&bi, sizeof(bi));

    // Gets the Shell's default allocator
    if (::SHGetMalloc(&pMalloc) == NOERROR)
    {
    // Get help on BROWSEINFO struct - it's got all the bit settings.

    bi.hwndOwner=NULL;
            bi.pidlRoot=NULL;//为NULL,则已桌面为根,
    bi.lpszTitle=_T("请选择文件夹");//
    bi.ulFlags=BIF_RETURNONLYFSDIRS;
    bi.lpfn=NULL;
    bi.lParam=NULL;
    bi.pszDisplayName = m_directory; 
    // This next call issues the dialog box.
    if ((pidl = ::SHBrowseForFolder(&bi)) != NULL)
    {
    if (!::SHGetPathFromIDList(pidl, m_directory)) 
    pMalloc->Free(pidl); 
    CString strDir  = m_directory;
        SetDlgItemText(IDC_EDIT1,strDir );

    pMalloc->Release();

    } //
      

  2.   

    http://community.csdn.net/Expert/topic/3492/3492349.xml?temp=.5031855显示浏览文件夹和显示保存/打开系统对话框是有区别的,如果是前者,就是上面的网址的回复;
    否则是CFileDialog的调用
      

  3.   

    问】如何实现文件夹浏览选择对话框?
    答】
    #include <windows.h>
    #include <string.h>
    //This is needed for virtually 
    //everything in BrowseFolder.
    #include <shlobj.h>   
    //BROWSE FOLDER - Opens a browse folder dialog.
    void BrowseFolder( void )
    {
        TCHAR path[MAX_PATH];
        BROWSEINFO bi = { 0 };
        bi.lpszTitle = ("All Folders Automatically Recursed.");
        LPITEMIDLIST pidl = SHBrowseForFolder ( &bi );
        if ( pidl != 0 )
        {
            // get the name of the folder and put it in path
            SHGetPathFromIDList ( pidl, path );
            //Set the current directory to path
            SetCurrentDirectory ( path );
            //Begin the search
            SearchFolder( path );
            // free memory used
            IMalloc * imalloc = 0;
            if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )
            {
                imalloc->Free ( pidl );
                imalloc->Release ( );
            }
        }
    }//BROWSE FOLDER
      

  4.   

    BROWSEINFO browseInfo; 
    LPITEMIDLIST pItemIDList;
    TCHAR szDisplayName[256] = "";
    TCHAR szPath[MAX_PATH];

    // Initialize browse info structure
    browseInfo.hwndOwner = m_hWnd;
    browseInfo.pidlRoot = NULL;
    browseInfo.pszDisplayName = szDisplayName;
    browseInfo.lpszTitle = "请选择目录:";
    browseInfo.lParam = 0;
    browseInfo.lpfn = NULL;
    browseInfo.ulFlags = 0;//BIF_BROWSEINCLUDEFILES | BIF_EDITBOX | BIF_DONTGOBELOWDOMAIN ;
    browseInfo.iImage = 0;

    // Open dialog
    pItemIDList = SHBrowseForFolder(&browseInfo);

    // Get path
    SHGetPathFromIDList(pItemIDList, szPath);

    // If OK button was pressed and a valid path was selected
    if (szPath[0])

    // Do something with szPath ...
    m_strRootPath=szPath;
    strFind=m_strRootPath+"\\*.*";
    UpdateData(FALSE);