1 #pragma once 2 3 #include <string> 4 #include <vector> 5 #include <thread> 6 7 namespace W32Util 8 { 9 std::string BrowseForFolder(HWND parent, const char *title); 10 std::string BrowseForFolder(HWND parent, const wchar_t *title); 11 bool BrowseForFileName (bool _bLoad, HWND _hParent, const wchar_t*_pTitle, 12 const wchar_t *_pInitialFolder,const wchar_t *_pFilter,const wchar_t*_pExtension, 13 std::string& _strFileName); 14 std::vector<std::string> BrowseForFileNameMultiSelect(bool _bLoad, HWND _hParent, const wchar_t*_pTitle, 15 const wchar_t*_pInitialFolder,const wchar_t*_pFilter,const wchar_t*_pExtension); 16 17 std::string UserDocumentsPath(); 18 19 struct AsyncBrowseDialog { 20 public: 21 enum Type { 22 OPEN, 23 SAVE, 24 DIR, 25 }; 26 27 // For a directory. 28 AsyncBrowseDialog(HWND parent, UINT completeMsg, std::wstring title); 29 // For a file (OPEN or SAVE.) 30 AsyncBrowseDialog(Type type, HWND parent, UINT completeMsg, std::wstring title, std::wstring initialFolder, std::wstring filter, std::wstring extension); 31 32 ~AsyncBrowseDialog(); 33 34 bool GetResult(std::string &filename); GetTypeAsyncBrowseDialog35 Type GetType() { 36 return type_; 37 } 38 39 private: 40 void Execute(); 41 42 std::thread *thread_; 43 Type type_; 44 HWND parent_; 45 UINT completeMsg_; 46 std::wstring title_; 47 std::wstring initialFolder_; 48 std::wstring filter_; 49 std::wstring extension_; 50 bool complete_; 51 bool result_; 52 std::string filename_; 53 }; 54 } 55