Partager via


CShellManager::BrowseForFolder

Displays a dialog box that enables the user to select a shell folder.

BOOL BrowseForFolder(
   CString& strOutFolder,
   CWnd* pWndParent = NULL,
   LPCTSTR lplszInitialFolder = NULL,
   LPCTSTR lpszTitle = NULL,
   UINT ulFlags = BIF_RETURNONLYFSDIRS,
   LPINT piFolderImage = NULL
);

Parameters

  • [out] strOutFolder
    The string used by the method to store the path of the selected folder.

  • [in] pWndParent
    A pointer to the parent window.

  • [in] lplszInitialFolder
    A string that contains the folder that is selected by default when the dialog box is displayed.

  • [in] lpszTitle
    The title for the dialog box.

  • [in] ulFlags
    Flags specifying options for the dialog box. See BROWSEINFO for the detailed description.

  • [out] piFolderImage
    A pointer to the integer value where the method writes the image index of the selected folder.

Return Value

Nonzero if the user selects a folder from the dialog box; otherwise 0.

Remarks

When you call this method, the application creates and shows a dialog box that enables the user to select a folder. The method will write the path of the folder into the strOutFolder parameter.

Example

The following example demonstrates how to retrieve a reference to a CShellManager object by using the CWinAppEx::GetShellManager method and how to use the BrowseForFolder method. This code snippet is part of the Explorer sample.

    CString strPath;
    // The this pointer points to the CExplorerView class which extends the CView class. 
    // CMFCShellListCtrl m_wndList 
    if (m_wndList.GetCurrentFolder (strPath) &&
        theApp.GetShellManager ()->BrowseForFolder (strPath, 
            this, strPath, _T("Copy the selected item(s) to the folder:")))
    {
        MessageBox (CString (_T("The selected path is: ")) + strPath);
    }

Requirements

Header: afxshellmanager.h

See Also

Reference

CShellManager Class

Hierarchy Chart