summaryrefslogtreecommitdiff
path: root/src/common.cpp
diff options
context:
space:
mode:
authorIan C <ianc@noddybox.co.uk>2005-04-11 20:25:39 +0000
committerIan C <ianc@noddybox.co.uk>2005-04-11 20:25:39 +0000
commita6c8b4498363db99d0de8f15e7bc8a9cfc1a7f81 (patch)
tree3641cf009bd21d947059c48bd2402ce90e0e37d7 /src/common.cpp
parentba60e6f1f7ec109a1214aba3e6c8f2f5b78fc230 (diff)
Added Common::DirSelect(). Also added '--archive' switch to w32dlib-config.
Diffstat (limited to 'src/common.cpp')
-rw-r--r--src/common.cpp46
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;