Win32: Delete the old BrowseForFolder implementation

This commit is contained in:
Henrik Rydgård 2025-03-29 08:52:15 +01:00
parent c906cee1ed
commit c2cc5b345d
3 changed files with 1 additions and 63 deletions

View file

@ -1503,7 +1503,7 @@ UI::EventReturn GameSettingsScreen::OnMemoryStickOther(UI::EventParams &e) {
if (otherinstalled_) {
auto di = GetI18NCategory(I18NCat::DIALOG);
std::string initialPath = g_Config.memStickDirectory.ToCString();
std::string folder = W32Util::BrowseForFolder(MainWindow::GetHWND(), di->T("Choose PPSSPP save folder"), initialPath);
std::string folder = W32Util::BrowseForFolder2(MainWindow::GetHWND(), di->T("Choose PPSSPP save folder"), initialPath);
if (folder.size()) {
g_Config.memStickDirectory = Path(folder);
FILE *f = File::OpenCFile(PPSSPPpath / "installed.txt", "wb");

View file

@ -71,64 +71,6 @@ std::string BrowseForFolder2(HWND parent, std::string_view title, std::string_vi
return ConvertWStringToUTF8(selectedFolder);
}
static int CALLBACK BrowseFolderCallback(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData) {
if (uMsg == BFFM_INITIALIZED) {
LPCTSTR path = reinterpret_cast<LPCTSTR>(lpData);
::SendMessage(hwnd, BFFM_SETSELECTION, true, (LPARAM)path);
}
return 0;
}
std::string BrowseForFolder(HWND parent, const wchar_t *title, std::string_view initialPath) {
BROWSEINFO info{};
info.hwndOwner = parent;
info.lpszTitle = title;
info.ulFlags = BIF_EDITBOX | BIF_RETURNONLYFSDIRS | BIF_USENEWUI | BIF_NEWDIALOGSTYLE;
std::wstring initialPathW;
if (!initialPath.empty()) {
initialPathW = ConvertUTF8ToWString(initialPath);
info.lParam = reinterpret_cast<LPARAM>(initialPathW.c_str());
info.lpfn = BrowseFolderCallback;
}
//info.pszDisplayName
auto idList = SHBrowseForFolder(&info);
HMODULE shell32 = GetModuleHandle(L"shell32.dll");
typedef BOOL (WINAPI *SHGetPathFromIDListEx_f)(PCIDLIST_ABSOLUTE pidl, PWSTR pszPath, DWORD cchPath, GPFIDL_FLAGS uOpts);
SHGetPathFromIDListEx_f SHGetPathFromIDListEx_ = nullptr;
if (shell32)
SHGetPathFromIDListEx_ = (SHGetPathFromIDListEx_f)GetProcAddress(shell32, "SHGetPathFromIDListEx");
std::string result;
if (SHGetPathFromIDListEx_) {
std::wstring temp;
do {
// Assume it's failing if it goes on too long.
if (temp.size() > 32768 * 10) {
temp.clear();
break;
}
temp.resize(temp.size() + MAX_PATH);
} while (SHGetPathFromIDListEx_(idList, &temp[0], (DWORD)temp.size(), GPFIDL_DEFAULT) == 0);
result = ConvertWStringToUTF8(temp);
} else {
wchar_t temp[MAX_PATH]{};
SHGetPathFromIDList(idList, temp);
result = ConvertWStringToUTF8(temp);
}
CoTaskMemFree(idList);
return result;
}
std::string BrowseForFolder(HWND parent, std::string_view title, std::string_view initialPath) {
std::wstring titleString = ConvertUTF8ToWString(title);
return BrowseForFolder(parent, titleString.c_str(), initialPath);
}
bool BrowseForFileName(bool _bLoad, HWND _hParent, const wchar_t *_pTitle,
const wchar_t *_pInitialFolder, const wchar_t *_pFilter, const wchar_t *_pExtension,
std::string &_strFileName) {

View file

@ -9,10 +9,6 @@ class Path;
namespace W32Util {
// Can't make initialPath a string_view, need the null so might as well require it.
std::string BrowseForFolder(HWND parent, std::string_view title, std::string_view initialPath);
std::string BrowseForFolder(HWND parent, const wchar_t *title, std::string_view initialPath);
// Modern dialog
std::string BrowseForFolder2(HWND parent, std::string_view title, std::string_view initialPath);
bool BrowseForFileName(bool _bLoad, HWND _hParent, const wchar_t*_pTitle,