From a6c8b4498363db99d0de8f15e7bc8a9cfc1a7f81 Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 11 Apr 2005 20:25:39 +0000 Subject: Added Common::DirSelect(). Also added '--archive' switch to w32dlib-config. --- src/common.cpp | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'src/common.cpp') 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 +#include #include "w32dlib/common.h" namespace W32DLib @@ -157,6 +158,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() -- cgit v1.2.3