Skip to content

Commit

Permalink
GUIの自動開始設定の挙動が正しくなかったのを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
lltcggie committed Mar 20, 2016
1 parent 6494205 commit 9c7ab0d
Showing 1 changed file with 30 additions and 25 deletions.
55 changes: 30 additions & 25 deletions waifu2x-caffe-gui/Source.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 9c7ab0d

Please sign in to comment.