diff --git a/pc/code_twain/sln/hgjson/DlgOptJson.cpp b/pc/code_twain/sln/hgjson/DlgOptJson.cpp index 31cdfd3..0af4ae8 100644 --- a/pc/code_twain/sln/hgjson/DlgOptJson.cpp +++ b/pc/code_twain/sln/hgjson/DlgOptJson.cpp @@ -435,11 +435,32 @@ void CDlgOptJson::from_ui(SANEOPT& sop) val = get_item_text(IDC_EDIT_DEFAULT); else val = get_item_text(IDC_COMBO_DEFAULT); - sop.def_val = std::string((const char*)val.c_str(), val.length() * 2 + 2); + if (sop.type == L"bool") + { + bool v = val == L"true"; + sop.def_val = std::string((char*)&v, sizeof(v)); + } + else if (sop.type == L"int") + { + int v = _wtoi(val.c_str()); + sop.def_val = std::string((char*)&v, sizeof(v)); + } + else if (sop.type == L"float") + { + double v = _wtof(val.c_str()); + sop.def_val = std::string((char*)&v, sizeof(v)); + } + else if (sop.type == L"string") + { + sop.def_val = std::string((const char*)val.c_str(), val.length() * 2 + 2); + } + else + sop.def_val = ""; sop.enable = is_button_check(IDC_CHECK_ENABLE); sop.range_type = get_item_text(IDC_COMBO_RANGE); sop.depend_oper = get_item_text(IDC_COMBO_DEPEND); + sop.depends.clear(); if (sop.depend_oper != L"none") { wchar_t buf[256] = { 0 }; @@ -1141,6 +1162,7 @@ void CDlgOptJson::OnBnClickedButtonModify() { if (::MessageBoxW(m_hWnd, (L"\u5DF2\u7ECF\u5B58\u5728\u540D\u4E3A\u201C" + v.title + L"\u201D\u7684\u914D\u7F6E\u9879\uFF01\uFF0C\u60F3\u4FEE\u6539Name\u5B57\u6BB5\u5417\uFF1F").c_str(), L"Error", MB_ICONSTOP | MB_YESNO) == IDYES) { + sop.range = std::move(v.range); v = std::move(sop); } return; @@ -1151,12 +1173,14 @@ void CDlgOptJson::OnBnClickedButtonModify() { if (v.name == sop.name) { + sop.range = std::move(v.range); v = std::move(sop); return; } } opts_.push_back(sop); + insert_to_tree(sop); } @@ -1386,17 +1410,22 @@ void CDlgOptJson::OnBnClickedButtonSet() { if (v.name == opt.name) { - v = std::move(opt); + from_ui(v); + v.range = opt.range; + v.def_val = opt.def_val; + to_ui(v); return; } } - std::vector r(std::move(opt.range)); + SANEOPT so; - from_ui(opt); - opt.range = std::move(r); + from_ui(so); + so.range = opt.range; + so.def_val = opt.def_val; opts_.push_back(opt); insert_to_tree(opt); + to_ui(opt); } } diff --git a/pc/code_twain/sln/sdk/lib/Debug/base_util.lib b/pc/code_twain/sln/sdk/lib/Debug/base_util.lib index e23d99d..8e5c14a 100644 Binary files a/pc/code_twain/sln/sdk/lib/Debug/base_util.lib and b/pc/code_twain/sln/sdk/lib/Debug/base_util.lib differ diff --git a/pc/code_twain/sln/sdk/lib/Release/base_util.lib b/pc/code_twain/sln/sdk/lib/Release/base_util.lib index 485e366..ddc0d58 100644 Binary files a/pc/code_twain/sln/sdk/lib/Release/base_util.lib and b/pc/code_twain/sln/sdk/lib/Release/base_util.lib differ diff --git a/pc/code_twain/sln/usb_tools/Debug/hgjson.exe b/pc/code_twain/sln/usb_tools/Debug/hgjson.exe index b1cc17d..d3d0731 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