diff options
Diffstat (limited to 'src/common.cpp')
| -rw-r--r-- | src/common.cpp | 46 | 
1 files changed, 46 insertions, 0 deletions
| diff --git a/src/common.cpp b/src/common.cpp index 383a773..9f5296c 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -19,6 +19,7 @@  //  -------------------------------------------------------------------------  //  #include <cstring> +#include <shlobj.h>  #include "w32dlib/common.h"  namespace W32DLib @@ -159,6 +160,51 @@ bool Common::SaveFile(HWND parent,  // ------------------------------------------------------------  // +bool Common::SelectDir(HWND parent, const char *title, std::string& path) +{ +    char name[1024]; +    LPITEMIDLIST sel=NULL; +    BROWSEINFO bi={0}; + +    strcpy(name,path.c_str()); + +    bi.hwndOwner=parent; +    bi.pidlRoot=NULL; +    bi.pszDisplayName=name; +    bi.lpszTitle=title; +    bi.ulFlags=0; +    bi.lpfn=BrowseCallback; +    bi.lParam=(LPARAM)name; + +    sel=SHBrowseForFolder(&bi); + +    if (SHGetPathFromIDList(sel,name)) +    { +	path=name; +	return true; +    } +    else +    { +    	return false; +    } +} + + +// ------------------------------------------------------------ +// +int CALLBACK Common::BrowseCallback(HWND w, UINT u, LPARAM p1, LPARAM p2) +{ +    if (u==BFFM_INITIALIZED) +    { +	PostMessage(w,BFFM_SETSELECTION,TRUE,p2); +    } + +    return 0; +} + + +// ------------------------------------------------------------ +//  std::string Common::GetOSError()  {      std::string res; | 
