fix bug
This commit is contained in:
parent
9dd97b57a0
commit
5e66a20a79
|
@ -435,11 +435,32 @@ void CDlgOptJson::from_ui(SANEOPT& sop)
|
||||||
val = get_item_text(IDC_EDIT_DEFAULT);
|
val = get_item_text(IDC_EDIT_DEFAULT);
|
||||||
else
|
else
|
||||||
val = get_item_text(IDC_COMBO_DEFAULT);
|
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.enable = is_button_check(IDC_CHECK_ENABLE);
|
||||||
sop.range_type = get_item_text(IDC_COMBO_RANGE);
|
sop.range_type = get_item_text(IDC_COMBO_RANGE);
|
||||||
sop.depend_oper = get_item_text(IDC_COMBO_DEPEND);
|
sop.depend_oper = get_item_text(IDC_COMBO_DEPEND);
|
||||||
|
sop.depends.clear();
|
||||||
if (sop.depend_oper != L"none")
|
if (sop.depend_oper != L"none")
|
||||||
{
|
{
|
||||||
wchar_t buf[256] = { 0 };
|
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)
|
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);
|
v = std::move(sop);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1151,12 +1173,14 @@ void CDlgOptJson::OnBnClickedButtonModify()
|
||||||
{
|
{
|
||||||
if (v.name == sop.name)
|
if (v.name == sop.name)
|
||||||
{
|
{
|
||||||
|
sop.range = std::move(v.range);
|
||||||
v = std::move(sop);
|
v = std::move(sop);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
opts_.push_back(sop);
|
opts_.push_back(sop);
|
||||||
|
insert_to_tree(sop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1386,17 +1410,22 @@ void CDlgOptJson::OnBnClickedButtonSet()
|
||||||
{
|
{
|
||||||
if (v.name == opt.name)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> r(std::move(opt.range));
|
SANEOPT so;
|
||||||
|
|
||||||
from_ui(opt);
|
from_ui(so);
|
||||||
opt.range = std::move(r);
|
so.range = opt.range;
|
||||||
|
so.def_val = opt.def_val;
|
||||||
opts_.push_back(opt);
|
opts_.push_back(opt);
|
||||||
insert_to_tree(opt);
|
insert_to_tree(opt);
|
||||||
|
to_ui(opt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue