MCPcopy Create free account
hub / github.com/Predelnik/DSpellCheck / browse_for_directory

Function browse_for_directory

src/common/winapi.cpp:72–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

70}
71
72std::optional<std::wstring> browse_for_directory(HWND parent_wnd, const wchar_t *initial_path) {
73 // Thanks to http://vcfaq.mvps.org/sdk/20.htm
74 BROWSEINFO bi;
75 memset(&bi, 0, sizeof(bi));
76 std::vector<wchar_t> path;
77
78 LPITEMIDLIST pidl_root = nullptr;
79 SHGetFolderLocation(parent_wnd, 0, nullptr, NULL, &pidl_root);
80
81 auto title = rc_str(IDS_PICK_A_DIRECTORY);
82 bi.pidlRoot = pidl_root;
83 bi.lpszTitle = title.c_str();
84 bi.pszDisplayName = path.data();
85 bi.ulFlags = BIF_RETURNONLYFSDIRS;
86 bi.lpfn = browse_callback_proc;
87 bi.lParam = reinterpret_cast<LPARAM>(initial_path);
88 LPITEMIDLIST pidl = SHBrowseForFolder(&bi);
89 std::optional<std::wstring> ret;
90 if (pidl != nullptr) {
91 // get the name of the folder
92 std::vector<wchar_t> sz_path(MAX_PATH);
93 if (SHGetPathFromIDList(pidl, sz_path.data()))
94 ret = sz_path.data();
95 CoTaskMemFree(pidl);
96 // free memory used
97
98 CoUninitialize();
99 }
100 return ret;
101}
102
103HWND create_tooltip(int tool_id, HWND h_dlg, const wchar_t *psz_text) {
104 if (tool_id == 0 || h_dlg == nullptr || psz_text == nullptr) {

Callers 2

run_dlg_procMethod · 0.85
run_dlg_procMethod · 0.85

Calls 3

rc_strFunction · 0.85
c_strMethod · 0.80
dataMethod · 0.80

Tested by

no test coverage detected