diff --git a/device/win_usb/win_usb.cpp b/device/win_usb/win_usb.cpp index f3af35d..567bf25 100644 --- a/device/win_usb/win_usb.cpp +++ b/device/win_usb/win_usb.cpp @@ -719,14 +719,14 @@ int usb_device::transfer_control(uint8_t type, uint8_t req, uint16_t val, uint16 } else { - //io = GetLastError(); - //if (io == ERROR_ACCESS_DENIED) - // ret = LIBUSB_ERROR_ACCESS; - //else if (io == ERROR_SEM_TIMEOUT) - // ret = LIBUSB_ERROR_TIMEOUT; - //else - // ret = LIBUSB_ERROR_PIPE; - ret = 0; + io = GetLastError(); + if (io == ERROR_ACCESS_DENIED) + ret = LIBUSB_ERROR_ACCESS; + else if (io == ERROR_SEM_TIMEOUT) + ret = LIBUSB_ERROR_TIMEOUT; + else + ret = LIBUSB_ERROR_PIPE; + // ret = 0; } oc->release(); } diff --git a/sane/DlgPage.cpp b/sane/DlgPage.cpp index 6d688cb..2aac5f6 100644 --- a/sane/DlgPage.cpp +++ b/sane/DlgPage.cpp @@ -7,7 +7,7 @@ #include "DlgArea.h" #include "DlgGamma.h" #include "gb_json.h" - +#include "../../code_device/hgsane/sane_hg_mdw.h" // for // #pragma comment(linker,"\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"") @@ -1080,6 +1080,7 @@ void dlg_page::control_action(HWND wnd) if (val) { SANE_Int after = 0; + std::string to_v(hg_sane_middleware::option_value_2_string(type, val)); SANE_Status statu = sane_.sane_control_option_api(dev_, id - dlg_page::dyn_id_base, SANE_ACTION_SET_VALUE, val, &after); gb::sane_config_schm* cfg = get_config(); done_ = false; @@ -1106,7 +1107,24 @@ void dlg_page::control_action(HWND wnd) if (len) cfg->config_changed(id - dlg_page::dyn_id_base, (char*)val, len); } - set_ctrl_value(wnd, type, val, false, !(after || statu)); + if (statu == SANE_STATUS_INVAL) + { + std::wstring attr(L"\u6B64\u8BBE\u5907\u4E0D\u652F\u6301\u5C06 \u201C" + local_trans::a2u(sane_.sane_get_option_descriptor_api(dev_, id - dlg_page::dyn_id_base)->title, CP_UTF8) + L"\u201D \u8BBE\u7F6E\u4E3A\uFF1A"), + attr_v(local_trans::a2u(to_v.c_str(), CP_UTF8)); + MessageBoxW(hwnd(), (attr + attr_v).c_str(), L"\u53C2\u6570\u9519\u8BEF", MB_OK); + set_ctrl_value(wnd, type, val, true); + } + else + { + std::string tov(hg_sane_middleware::option_value_2_string(type, val)); + if (tov != to_v) + { + std::wstring attr(L"\u539F\u53C2\u6570 \u201C" + local_trans::a2u(to_v.c_str(), CP_UTF8) + L"\u201D \u4E0D\u7CBE\u786E\u6216\u8BBE\u5907\u4E0D\u652F\u6301\uFF0C\u5DF2\u8C03\u6574\u4E3A\uFF1A"), + attr_v(local_trans::a2u(tov.c_str(), CP_UTF8)); + MessageBoxW(hwnd(), (attr + attr_v).c_str(), L"\u53C2\u6570\u8C03\u6574", MB_OK); + } + set_ctrl_value(wnd, type, val, false, !(after || statu)); + } done_ = true; if (id == dlg_page::dyn_id_base + id_dpi_) { @@ -1118,7 +1136,7 @@ void dlg_page::control_action(HWND wnd) else if (id == dlg_page::dyn_id_base + id_paper_) paper_ = local_trans::a2u((char*)val, CP_UTF8); - if (after || statu) + if (after || (statu && statu != SANE_STATUS_INVAL)) PostMessage(parent_, WM_REFRESH_OPTION, id - dlg_page::dyn_id_base, 0); free_ctrl_value(val); } diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 4544745..7cb40ee 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -348,8 +348,8 @@ scanner::scanner(SCANNERID id) : handle_(NULL), id_(id), ex_id_(EXTENSION_ID_BAS int mem_limit = GetPrivateProfileIntW(L"mem", L"max_img", 0, (cfg_path_ + L"debug.cfg").c_str()); if (mem_limit > 0) { - // this value is used for driver usb image queue, here should multiple 5 - max_img_mem_ = 5 * mem_limit; + // this value is same as driver memory limit ... + max_img_mem_ = mem_limit; } err_ = open(); }