From ee19dba608759e961eaa46fdc2642cbfd4b7fe14 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Wed, 13 Dec 2023 11:38:32 +0800 Subject: [PATCH] =?UTF-8?q?=E9=92=88=E5=AF=B9=E8=AE=AF=E9=A3=9E=E5=90=AF?= =?UTF-8?q?=E6=98=8E=E6=89=AB=E6=8F=8F=E5=AE=8C=E6=88=90=E5=90=8ETIMER?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=87=8D=E5=85=A5=E5=AF=BC=E8=87=B4=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=8D=A1=E6=AD=BB=E9=97=AE=E9=A2=98=EF=BC=8C=E5=9C=A8?= =?UTF-8?q?=E5=8F=96=E5=9B=BE=E6=B5=81=E7=A8=8B=E4=B8=AD=E5=BF=BD=E7=95=A5?= =?UTF-8?q?=E8=AF=A5=E6=B6=88=E6=81=AF=E3=80=82=E4=B9=9F=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E9=80=9A=E8=BF=87=E5=A4=96=E9=83=A8=E9=85=8D=E7=BD=AE:=20[twai?= =?UTF-8?q?n-app]ignore-msg=3D=20&&=20ignore-msg-wp=3D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++-- sane/scanner.h | 3 +++ 2 files changed, 45 insertions(+), 2 deletions(-) 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_;