diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 9ec8f9a..d46ad25 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -552,6 +552,29 @@ scanner::scanner(SCANNERID id) : handle_(NULL), id_(id), ex_id_(EXTENSION_ID_BAS { wait_fetch_ = mem_limit * 1000; // second to millisecond } + + re_enter_msg_ = GetPrivateProfileIntW(L"twain-app", L"ignore-msg", 0, (cfg_path_ + L"debug.cfg").c_str()); + re_enter_msg_wp_ = GetPrivateProfileIntW(L"twain-app", L"ignore-msg-wp", 0, (cfg_path_ + L"debug.cfg").c_str()); + if (re_enter_msg_ == 0) + { + wchar_t path[MAX_PATH] = { 0 }, * name = NULL; + GetModuleFileNameW(NULL, path, _countof(path) - 1); + name = wcsrchr(path, L'\\'); + if (name++ == NULL) + name = path; + if (wcsicmp(name, L"proScanner.exe") == 0) + { + re_enter_msg_ = WM_TIMER; + re_enter_msg_wp_ = 1; + } + } + if(re_enter_msg_) + { + wchar_t info[128] = { 0 }; + swprintf_s(info, _countof(info) - 1, L"Ignore message(0x%x) when get images\r\n", re_enter_msg_); + log_info(info, 1); + } + err_ = open(); } scanner::~scanner() @@ -2840,8 +2863,25 @@ COM_API_IMPLEMENT(scanner, int, get_scanned_images(DWORD milliseconds)) MSG msg = { 0 }; if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { - TranslateMessage(&msg); - DispatchMessageW(&msg); + bool block_msg = false; + + if (re_enter_msg_ && re_enter_msg_ == msg.message) + { + if (re_enter_msg_wp_) + { + block_msg = re_enter_msg_wp_ == msg.wParam; + } + else + { + block_msg = true; + } + } + + if (!block_msg) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } } else Sleep(elapse); diff --git a/sane/scanner.h b/sane/scanner.h index c928c59..ccf6040 100644 --- a/sane/scanner.h +++ b/sane/scanner.h @@ -57,6 +57,9 @@ class scanner : public ISaneInvoker, virtual public refer int double_handle_ = DOUBLE_FEED_NEED_UI; // bool is_bIndicator; bool is_show_setting_; + UINT re_enter_msg_ = 0; // 针对讯飞启明扫描完成后TIMER消息重入导致界面卡死问题,在取图流程中忽略该消息。也可以通过外部配置 + UINT re_enter_msg_wp_ = 0; + unsigned int img_ind_; std::wstring scanner_name_; std::wstring tmp_path_;