00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 #ifndef WINSTL_INCL_H_WINSTL
00060 # include "winstl.h"
00061 #endif
00062 #ifndef WINSTL_INCL_H_WINSTL_SHELL_ALLOCATOR
00063 # include "winstl_shell_allocator.h"
00064 #endif
00065 #ifndef STLSOFT_INCL_H_STLSOFT_STRING_ACCESS
00066 # include "stlsoft_string_access.h"
00067 #endif
00068 #ifndef WINSTL_INCL_H_WINSTL_STRING_ACCESS
00069 # include "winstl_string_access.h"
00070 #endif
00071
00072
00073
00074
00075
00076 #ifndef _WINSTL_NO_NAMESPACE
00077 # if defined(_STLSOFT_NO_NAMESPACE) || \
00078 defined(__STLSOFT_DOCUMENTATION_SKIP_SECTION)
00079
00080 namespace winstl
00081 {
00082 # else
00083
00084
00085 namespace stlsoft
00086 {
00087
00088 namespace winstl_project
00089 {
00090
00091 # endif
00092 #endif
00093
00094 #if !defined(__STLSOFT_COMPILER_IS_MWERKS)
00095 stlsoft_ns_using(c_str_ptr)
00096 #endif
00097
00098
00099
00100
00101
00102
00103
00104 #ifdef __STLSOFT_DOCUMENTATION_SKIP_SECTION
00111 template <ss_typename_param_k C>
00112 struct shell_browse_traits
00113 {
00115 typedef BROWSEINFO browseinfo_t;
00116
00118 static LPITEMIDLIST browseforfolder(browseinfo_t *bi);
00123 static BOOL getpathfromidlist(LPCITEMIDLIST pidl, ws_char_a_t *pszPath);
00124 };
00125
00126 #else
00127
00128
00129 template <ss_typename_param_k C>
00130 struct shell_browse_traits;
00131
00132 STLSOFT_TEMPLATE_SPECIALISATION
00133 struct shell_browse_traits<ws_char_a_t>
00134 {
00135 public:
00136 typedef BROWSEINFOA browseinfo_t;
00137
00138 static LPITEMIDLIST browseforfolder(browseinfo_t *bi)
00139 {
00140 return SHBrowseForFolderA(bi);
00141 }
00142
00143 static BOOL getpathfromidlist(LPCITEMIDLIST pidl, ws_char_a_t *pszPath)
00144 {
00145 return SHGetPathFromIDListA(pidl, pszPath);
00146 }
00147 };
00148
00149 STLSOFT_TEMPLATE_SPECIALISATION
00150 struct shell_browse_traits<ws_char_w_t>
00151 {
00152 public:
00153 typedef BROWSEINFOW browseinfo_t;
00154
00155 static LPITEMIDLIST browseforfolder(browseinfo_t *bi)
00156 {
00157 return SHBrowseForFolderW(bi);
00158 }
00159
00160 static BOOL getpathfromidlist(LPCITEMIDLIST pidl, ws_char_w_t *pszPath)
00161 {
00162 return SHGetPathFromIDListW(pidl, pszPath);
00163 }
00164 };
00165
00166 #endif
00167
00168
00169
00170
00171
00172
00180
00181 , ss_typename_param_k C
00182 >
00183 inline ws_bool_t shell_browse(const S &title, C *displayName, UINT flags, HWND hwndOwner, LPCITEMIDLIST pidlRoot)
00184 {
00185 typedef shell_browse_traits<C> traits_type;
00186 ss_typename_type_k traits_type::browseinfo_t browseinfo;
00187 LPITEMIDLIST lpiidl;
00188 ws_bool_t bRet = false;
00189
00190 browseinfo.hwndOwner = hwndOwner;
00191 browseinfo.pidlRoot = pidlRoot;
00192 browseinfo.pszDisplayName = displayName;
00193 browseinfo.lpszTitle = c_str_ptr(title);
00194 browseinfo.ulFlags = flags;
00195 browseinfo.lpfn = 0;
00196 browseinfo.lParam = 0;
00197
00198 lpiidl = traits_type::browseforfolder(&browseinfo);
00199
00200 if(lpiidl != 0)
00201 {
00202 if(traits_type::getpathfromidlist(lpiidl, displayName))
00203 {
00204 bRet = true;
00205 }
00206
00207 shell_allocator<ITEMIDLIST>().deallocate(lpiidl);
00208 }
00209
00210 if(!bRet)
00211 {
00212 displayName[0] = '\0';
00213 }
00214
00215 return bRet;
00216 }
00217
00224 template< ss_typename_param_k S
00225 , ss_typename_param_k C
00226 >
00227 inline ws_bool_t shell_browse(const S &title, C *displayName, UINT flags, HWND hwndOwner)
00228 {
00229 return shell_browse(title, displayName, flags, hwndOwner, static_cast<LPCITEMIDLIST>(0));
00230 }
00231
00238 template< ss_typename_param_k S
00239 , ss_typename_param_k C
00240 >
00241 inline ws_bool_t shell_browse(const S &title, C *displayName, UINT flags, LPCITEMIDLIST pidlRoot)
00242 {
00243 return shell_browse(title, displayName, flags, 0, pidlRoot);
00244 }
00245
00251 template< ss_typename_param_k S
00252 , ss_typename_param_k C
00253 >
00254 inline ws_bool_t shell_browse(const S &title, C *displayName, UINT flags)
00255 {
00256 return shell_browse(title, displayName, flags, 0, 0);
00257 }
00258
00263 template< ss_typename_param_k S
00264 , ss_typename_param_k C
00265 >
00266 inline ws_bool_t shell_browse(const S &title, C *displayName)
00267 {
00268 return shell_browse(title, displayName, 0, 0, 0);
00269 }
00270
00272
00273
00274 #ifdef STLSOFT_UNITTEST
00275
00276 namespace unittest
00277 {
00278 ss_bool_t test_winstl_shell_browse(unittest_reporter *r)
00279 {
00280 using stlsoft::unittest::unittest_initialiser;
00281
00282 ss_bool_t bSuccess = true;
00283
00284 unittest_initialiser init(r, "WinSTL", "shell_browse", __FILE__);
00285
00286 #if 0
00287 if(<<TODO>>)
00288 {
00289 r->report("<<TODO>> failed ", __LINE__);
00290 bSuccess = false;
00291 }
00292 #endif
00293
00294 return bSuccess;
00295 }
00296
00297 unittest_registrar unittest_winstl_shell_browse(test_winstl_shell_browse);
00298
00299 }
00300
00301 #endif
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313 #endif
00314
00315
00316
00317
00318
00319