From 9c7ab0df1ff7151eb905faae8c894b5a2d75a1dc Mon Sep 17 00:00:00 2001 From: lltcggie Date: Sun, 20 Mar 2016 14:53:53 +0900 Subject: [PATCH] =?UTF-8?q?GUI=E3=81=AE=E8=87=AA=E5=8B=95=E9=96=8B?= =?UTF-8?q?=E5=A7=8B=E8=A8=AD=E5=AE=9A=E3=81=AE=E6=8C=99=E5=8B=95=E3=81=8C?= =?UTF-8?q?=E6=AD=A3=E3=81=97=E3=81=8F=E3=81=AA=E3=81=8B=E3=81=A3=E3=81=9F?= =?UTF-8?q?=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- waifu2x-caffe-gui/Source.cpp | 55 ++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/waifu2x-caffe-gui/Source.cpp b/waifu2x-caffe-gui/Source.cpp index 7bcd30b..a39abaf 100644 --- a/waifu2x-caffe-gui/Source.cpp +++ b/waifu2x-caffe-gui/Source.cpp @@ -1997,36 +1997,40 @@ class DialogEvent // ドロップされたファイル数を取得 UINT FileNum = DragQueryFile((HDROP)wParam, 0xFFFFFFFF, szTmp, _countof(szTmp)); - if (FileNum == 1) + if (FileNum > 0) { - DragQueryFile((HDROP)wParam, 0, szTmp, _countof(szTmp)); - szTmp[_countof(szTmp) - 1] = TEXT('\0'); - - OnSetInputFilePath(szTmp); - } - else if (FileNum > 1) - { - input_str_multi.clear(); + if (FileNum == 1) + { + DragQueryFile((HDROP)wParam, 0, szTmp, _countof(szTmp)); + szTmp[_countof(szTmp) - 1] = TEXT('\0'); - for (UINT i = 0; i < FileNum; i++) + OnSetInputFilePath(szTmp); + } + else if (FileNum > 1) { - TCHAR szTmp[AR_PATH_MAX]; + input_str.clear(); + input_str_multi.clear(); - if (DragQueryFile((HDROP)wParam, i, szTmp, _countof(szTmp)) < _countof(szTmp)) + for (UINT i = 0; i < FileNum; i++) { - szTmp[_countof(szTmp) - 1] = TEXT('\0'); + TCHAR szTmp[AR_PATH_MAX]; + + if (DragQueryFile((HDROP)wParam, i, szTmp, _countof(szTmp)) < _countof(szTmp)) + { + szTmp[_countof(szTmp) - 1] = TEXT('\0'); - input_str_multi.push_back(szTmp); + input_str_multi.push_back(szTmp); + } } - } - OnSetInputFilePath(); - } + OnSetInputFilePath(); + } - if (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) || - (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && input_str_multi.size() > 0)) - { - ::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0); + if (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) || + (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && (input_str_multi.size() > 0 || boost::filesystem::is_directory(szTmp)))) + { + ::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0); + } } return 0L; @@ -2130,13 +2134,14 @@ class DialogEvent { szFile[szFile.size() - 1] = TEXT('\0'); - input_str_multi.clear(); - const TCHAR * ptr = szFile.data(); const auto firstLen = _tcslen(ptr); if (firstLen > 0) { + input_str.clear(); + input_str_multi.clear(); + if(firstLen + 2 >= szFile.size() || ptr[firstLen + 1] == '\0') OnSetInputFilePath(ptr); else @@ -2167,8 +2172,8 @@ class DialogEvent OnSetInputFilePath(); } - if (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) || - (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && input_str_multi.size() > 0)) + if ( SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_ONE), BM_GETCHECK, 0, 0) || + (SendMessage(GetDlgItem(dh, IDC_RADIO_AUTO_START_MULTI), BM_GETCHECK, 0, 0) && (input_str_multi.size() > 0 || boost::filesystem::is_directory(szFile.data())))) { ::PostMessage(GetDlgItem(dh, IDC_BUTTON_EXEC), BM_CLICK, 0, 0); }