diff --git a/pc/code_twain/sln/hgjson/DlgRange.cpp b/pc/code_twain/sln/hgjson/DlgRange.cpp index a976fb7..72ba2c0 100644 --- a/pc/code_twain/sln/hgjson/DlgRange.cpp +++ b/pc/code_twain/sln/hgjson/DlgRange.cpp @@ -93,7 +93,7 @@ BOOL CDlgRange::OnInitDialog() } BEGIN_MESSAGE_MAP(CDlgRange, CDialogEx) - ON_BN_CLICKED(IDC_BUTTON1, &CDlgRange::OnBnClickedButton1) + ON_BN_CLICKED(IDC_BUTTON_ADD, &CDlgRange::OnBnClickedButton1) ON_BN_CLICKED(IDOK, &CDlgRange::OnBnClickedOk) ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CDlgRange::OnNMDblclkList1) ON_CBN_SELCHANGE(IDC_COMBO_FIELD, &CDlgRange::OnCbnSelchangeComboField) @@ -107,20 +107,32 @@ void CDlgRange::OnBnClickedButton1() { // TODO: 在此添加控件通知处理程序代码 std::wstring val(get_item_text(IDC_EDIT_VAL)); + int ind = -1; + if (val.empty()) + { + MessageBox(TEXT("NO Input!")); + return; + } for (int i = 0; i < list_.GetItemCount(); ++i) { wchar_t buf[25] = { 0 }; list_.GetItemText(i, 0, buf, _countof(buf) - 1); if (val == buf) { - list_.SetItemState(i, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); + list_.SetItemState(i, LVIS_FOCUSED | LVIS_SELECTED | LVIS_ACTIVATING, LVIS_FOCUSED | LVIS_SELECTED | LVIS_ACTIVATING); list_.SetSelectionMark(i); - return; + ind = i; + break; } } - list_.InsertItem(list_.GetItemCount(), val.c_str()); + if(ind == -1) + ind = list_.InsertItem(list_.GetItemCount(), val.c_str()); + + list_.SetItemState(ind, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); + list_.SetSelectionMark(ind); + list_.EnsureVisible(ind, FALSE); } diff --git a/pc/code_twain/sln/hgjson/hgjson.rc b/pc/code_twain/sln/hgjson/hgjson.rc index 8b4b9ed..6a00bf7 100644 Binary files a/pc/code_twain/sln/hgjson/hgjson.rc and b/pc/code_twain/sln/hgjson/hgjson.rc differ diff --git a/pc/code_twain/sln/hgjson/hgjsonDlg.cpp b/pc/code_twain/sln/hgjson/hgjsonDlg.cpp index 6f26202..d064bb0 100644 --- a/pc/code_twain/sln/hgjson/hgjsonDlg.cpp +++ b/pc/code_twain/sln/hgjson/hgjsonDlg.cpp @@ -124,17 +124,17 @@ namespace coding std::wstring name_from_depend_exp(const std::wstring& depend_exp) { std::wstring name(L""); - size_t pos = depend_exp.find(L"="); + size_t pos = depend_exp.find(L"!"); if (pos == std::wstring::npos) { - pos = depend_exp.find(L"!"); + pos = depend_exp.find(L"<"); if (pos == std::wstring::npos) { pos = depend_exp.find(L">"); if (pos == std::wstring::npos) { - pos = depend_exp.find(L"<"); + pos = depend_exp.find(L"="); } } } diff --git a/pc/code_twain/sln/usb_tools/Debug/hgjson.exe b/pc/code_twain/sln/usb_tools/Debug/hgjson.exe index b7d3753..0128b72 100644 Binary files a/pc/code_twain/sln/usb_tools/Debug/hgjson.exe and b/pc/code_twain/sln/usb_tools/Debug/hgjson.exe differ