From: <man...@us...> - 2013-11-08 16:52:41
|
Revision: 3133 http://sourceforge.net/p/modplug/code/3133 Author: manxorist Date: 2013-11-08 16:52:32 +0000 (Fri, 08 Nov 2013) Log Message: ----------- [Fix] Make BrowseForFolder dialog work for unicode paths. Modified Paths: -------------- trunk/OpenMPT/mptrack/AutoSaver.cpp trunk/OpenMPT/mptrack/FileDialog.cpp trunk/OpenMPT/mptrack/FileDialog.h trunk/OpenMPT/mptrack/Moptions.cpp trunk/OpenMPT/mptrack/Vstplug.cpp Modified: trunk/OpenMPT/mptrack/AutoSaver.cpp =================================================================== --- trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/AutoSaver.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -402,13 +402,13 @@ void CAutoSaverGUI::OnBnClickedAutosaveBrowse() { - CHAR szPath[_MAX_PATH] = ""; + TCHAR szPath[_MAX_PATH] = TEXT(""); GetDlgItemText(IDC_AUTOSAVE_PATH, szPath, CountOf(szPath)); - BrowseForFolder dlg(szPath, "Select a folder to store autosaved files in..."); + BrowseForFolder dlg(mpt::PathString::FromCString(szPath), TEXT("Select a folder to store autosaved files in...")); if(dlg.Show()) { - SetDlgItemText(IDC_AUTOSAVE_PATH, dlg.GetDirectory().c_str()); + SetDlgItemText(IDC_AUTOSAVE_PATH, dlg.GetDirectory().ToCString()); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/FileDialog.cpp =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/FileDialog.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -112,7 +112,8 @@ if(uMsg == BFFM_INITIALIZED && lpData != NULL) { const BrowseForFolder *that = reinterpret_cast<BrowseForFolder *>(lpData); - SendMessage(hwnd, BFFM_SETSELECTION, TRUE, reinterpret_cast<LPARAM>(that->workingDirectory.c_str())); + std::wstring startPath = that->workingDirectory.AsNative(); + SendMessage(hwnd, BFFM_SETSELECTIONW, TRUE, reinterpret_cast<LPARAM>(startPath.c_str())); } return 0; } @@ -122,20 +123,20 @@ bool BrowseForFolder::Show() //-------------------------- { - TCHAR path[MAX_PATH]; + WCHAR path[MAX_PATH]; - BROWSEINFO bi; + BROWSEINFOW bi; MemsetZero(bi); bi.hwndOwner = theApp.m_pMainWnd->GetSafeHwnd(); - bi.lpszTitle = caption; + bi.lpszTitle = caption.c_str(); bi.pszDisplayName = path; bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_USENEWUI; bi.lpfn = BrowseCallbackProc; bi.lParam = reinterpret_cast<LPARAM>(this); - LPITEMIDLIST pid = SHBrowseForFolder(&bi); - if(pid != NULL && SHGetPathFromIDList(pid, path)) + LPITEMIDLIST pid = SHBrowseForFolderW(&bi); + if(pid != NULL && SHGetPathFromIDListW(pid, path)) { - workingDirectory = path; + workingDirectory = mpt::PathString::FromNative(path); return true; } return false; Modified: trunk/OpenMPT/mptrack/FileDialog.h =================================================================== --- trunk/OpenMPT/mptrack/FileDialog.h 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/FileDialog.h 2013-11-08 16:52:32 UTC (rev 3133) @@ -83,17 +83,17 @@ class BrowseForFolder { protected: - std::string workingDirectory; - const char *caption; + mpt::PathString workingDirectory; + std::wstring caption; public: - BrowseForFolder(const std::string &dir, const char *caption) : workingDirectory(dir), caption(caption) { } + BrowseForFolder(const mpt::PathString &dir, const CString &caption) : workingDirectory(dir), caption(mpt::String::FromCString(caption)) { } // Show the folder selection dialog. bool Show(); // Gets selected directory. - const std::string &GetDirectory() const { return workingDirectory; } + const mpt::PathString &GetDirectory() const { return workingDirectory; } protected: static int CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lParam, LPARAM lpData); Modified: trunk/OpenMPT/mptrack/Moptions.cpp =================================================================== --- trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/Moptions.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -659,13 +659,13 @@ void COptionsGeneral::BrowseForFolder(UINT nID) //--------------------------------------------- { - CHAR szPath[_MAX_PATH] = ""; + TCHAR szPath[MAX_PATH] = TEXT(""); GetDlgItemText(nID, szPath, CountOf(szPath)); - ::BrowseForFolder dlg(szPath, "Select a default folder..."); + ::BrowseForFolder dlg(mpt::PathString::FromCString(szPath), TEXT("Select a default folder...")); if(dlg.Show()) { - SetDlgItemText(nID, dlg.GetDirectory().c_str()); + SetDlgItemText(nID, dlg.GetDirectory().ToCString()); OnSettingsChanged(); } } Modified: trunk/OpenMPT/mptrack/Vstplug.cpp =================================================================== --- trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 16:44:04 UTC (rev 3132) +++ trunk/OpenMPT/mptrack/Vstplug.cpp 2013-11-08 16:52:32 UTC (rev 3133) @@ -1174,10 +1174,10 @@ } else { // Plugin wants a directory - BrowseForFolder dlg(fileSel->initialPath != nullptr ? fileSel->initialPath : "", fileSel->title); + BrowseForFolder dlg(mpt::PathString::FromLocale(fileSel->initialPath != nullptr ? fileSel->initialPath : ""), fileSel->title); if(dlg.Show()) { - const std::string &dir = dlg.GetDirectory(); + const std::string dir = dlg.GetDirectory().ToLocale(); if(CCONST('V', 'S', 'T', 'r') == effect->uniqueID && fileSel->returnPath != nullptr && fileSel->sizeReturnPath == 0) { // old versions of reViSiT (which still relied on the host's file selection code) seem to be dodgy. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |