close

REF:

Using MFC CFolderPickerDialog
https://www.codeproject.com/Tips/993640/Using-MFC-CFolderPickerDialog

 

CFolderPickerDialog Class

https://docs.microsoft.com/zh-tw/cpp/mfc/reference/cfolderpickerdialog-class?view=msvc-160

-

-

image

// Example code
CFolderPickerDialog m_dlg;
CString m_Folder;
 
m_dlg.m_ofn.lpstrTitle = _T("Put your title here");
m_dlg.m_ofn.lpstrInitialDir = _T("C:\\");
if (m_dlg.DoModal() == IDOK) {
       m_Folder = m_dlg.GetPathName();   // Use this to get the selected folder name 
                                         // after the dialog has closed
 
       // May need to add a '\' for usage in GUI and for later file saving, 
       // as there is no '\' on the returned name
       m_Folder += _T("\\");
       UpdateData(FALSE);   // To show updated folder in GUI
 
       // Debug
       TRACE("\n%S", m_Folder);
}
// End of example

 

-

-

 

explicit CFolderPickerDialog(
    LPCTSTR lpszFolder = NULL,
    DWORD dwFlags = 0,
    CWnd* pParentWnd = NULL,
    DWORD dwSize = 0);
Parameters
lpszFolder
Initial folder.

dwFlags
A combination of one or more flags that allow you to customize the dialog box.

pParentWnd
A pointer to the dialog box object's parent or owner window.

dwSize
The size of the OPENFILENAME structure.

 

 

DEMO:
image

 

image

 

arrow
arrow
    全站熱搜

    天才R 發表在 痞客邦 留言(0) 人氣()