From 6c68dc201ceebbe79f120fe217d3e85e2a135abc Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sat, 7 May 2016 07:35:28 +0900 Subject: [PATCH] =?UTF-8?q?=E5=85=A5=E5=8A=9B=E5=8F=82=E7=85=A7=E3=83=9C?= =?UTF-8?q?=E3=82=BF=E3=83=B3=E3=81=A7=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB?= =?UTF-8?q?=E3=81=A8=E3=83=95=E3=82=A9=E3=83=AB=E3=83=80=E3=82=92=E5=90=8C?= =?UTF-8?q?=E6=99=82=E3=81=AB=E9=81=B8=E6=8A=9E=E3=81=A7=E3=81=8D=E3=82=8B?= =?UTF-8?q?=E3=82=88=E3=81=86=E3=81=AB=E3=81=AA=E3=81=A3=E3=81=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe-gui/MainDialog.cpp | 64 +++++++++++++++++++++++++++++--- 1 file changed, 59 insertions(+), 5 deletions(-) diff --git a/waifu2x-caffe-gui/MainDialog.cpp b/waifu2x-caffe-gui/MainDialog.cpp index 224f48c..d433faf 100644 --- a/waifu2x-caffe-gui/MainDialog.cpp +++ b/waifu2x-caffe-gui/MainDialog.cpp @@ -936,6 +936,33 @@ void DialogEvent::SaveIni(const bool isSyncMember) WritePrivateProfileString(TEXT("Setting"), TEXT("LastOutputDirFix"), tOutputDirFix.c_str(), getTString(SettingFilePath).c_str()); } +struct stFindParam +{ + const TCHAR *WindowName; + HWND hWnd; +}; + +static BOOL CALLBACK EnumChildWindowsProc(HWND hWnd, LPARAM lParam) +{ + stFindParam *ptr = (stFindParam *)lParam; + + TCHAR buf[100]; + + if (GetWindowTextLength(hWnd) > _countof(buf) - 1) + return TRUE; + + GetWindowText(hWnd, buf, _countof(buf)); + buf[_countof(buf) - 1] = TEXT('\0'); + + if (_tcscmp(ptr->WindowName, buf) == 0) + { + ptr->hWnd = hWnd; + return FALSE; + } + + return TRUE; +} + // 入力パスを選択する UINT_PTR DialogEvent::OFNHookProcIn(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM lParam) { @@ -980,14 +1007,41 @@ UINT_PTR DialogEvent::OFNHookProcIn(HWND hdlg, UINT uiMsg, WPARAM wParam, LPARAM { TCHAR szPath[AR_PATH_MAX] = TEXT(""); HWND hParent = GetParent(hdlg); - if (CommDlg_OpenSave_GetFilePath(hParent, szPath, _countof(szPath)) > 0) + + stFindParam param; + param.WindowName = TEXT("FolderView"); + param.hWnd = NULL; + + EnumChildWindows(hParent, EnumChildWindowsProc, (LPARAM)¶m); + + if (param.hWnd) { - szPath[_countof(szPath) - 1] = TEXT('\0'); + std::vector< tstring > results; + int index = -1; + while (-1 != (index = ListView_GetNextItem(param.hWnd, index, LVNI_ALL | LVNI_SELECTED))) + { + std::vector< _TCHAR > result(AR_PATH_MAX, TEXT('\0')); + ListView_GetItemText(param.hWnd, index, 0, &result[0], result.size()); + results.push_back(result.data()); + } - boost::filesystem::path p(szPath); - const auto filename = getTString(p.filename()); + if (results.size() > 1) + { + TCHAR str[10000] = TEXT(""); - CommDlg_OpenSave_SetControlText(hParent, edt1, filename.c_str()); + for (const auto &p : results) + { + _tcscat_s(str, TEXT("\"")); + _tcscat_s(str, p.c_str()); + _tcscat_s(str, TEXT("\" ")); + } + + CommDlg_OpenSave_SetControlText(hParent, edt1, str); + } + else if(results.size() == 1) + CommDlg_OpenSave_SetControlText(hParent, edt1, results[0].c_str()); + else + CommDlg_OpenSave_SetControlText(hParent, edt1, TEXT("")); } } break;