Is there an easy method for bringing up the standard dialog to pick a directory (tree view) that most programs, including explorer, use? I like the simplicity of GetOpenFileName and the OPENFILENAME struct.
This is a discussion on GetOpenFileName common dialog - What about the folder select dialog? within the Windows Programming forums, part of the Platform Specific Boards category; Is there an easy method for bringing up the standard dialog to pick a directory (tree view) that most programs, ...
Is there an easy method for bringing up the standard dialog to pick a directory (tree view) that most programs, including explorer, use? I like the simplicity of GetOpenFileName and the OPENFILENAME struct.
Look at SHBrowseForFolder function. Although thats doesn't have the same look as the standard file dialog, so maybe not what you want.
My function:
Hope it makes sense and helps you.Code:Error BrowseForFolder(CWnd* pParentWnd, const Strings::CStringEx& strTitle, bool /*bLastFolder*/, Strings::CStringEx& strFolder, bool bEdit) { BROWSEINFO bi; TCHAR Buffer[MAX_PATH]; ZeroMemory(Buffer, MAX_PATH); ZeroMemory(&bi, sizeof(bi)); bi.hwndOwner = pParentWnd ? pParentWnd->m_hWnd : NULL; bi.pszDisplayName = Buffer; bi.lpszTitle = strTitle.get(); bi.ulFlags = bEdit ? BIF_EDITBOX : 0 | BIF_NEWDIALOGSTYLE | BIF_RETURNONLYFSDIRS | BIF_SHAREABLE; LPCITEMIDLIST pFolder = SHBrowseForFolder(&bi); if (pFolder == NULL) return ERROR_CANCEL; if (! SHGetPathFromIDList(pFolder, Buffer) ) return ERROR_BAD_PATH; strFolder = Buffer; return (Error)ERROR_SUCCESS; }
For information on how to enable C++11 on your compiler, look here.
よく聞くがいい!私は天才だからね! ^_^
Thanks