From d3c9c55e795699c9dcd6ba9cd860a40e5fa41613 Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Wed, 26 Apr 2023 18:07:59 +0800 Subject: [PATCH] =?UTF-8?q?ui=20=E6=89=AB=E6=8F=8F=E7=AA=97=E5=8F=A3?= =?UTF-8?q?=E6=98=AF=E4=B8=BB=E5=8A=A8=E5=8F=91=E9=80=81=E5=87=BA=E5=8E=BB?= =?UTF-8?q?=E7=9A=84=EF=BC=8C=E6=9A=82=E6=97=B6=E8=BF=99=E4=B9=88=E5=BC=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sane/scanner.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 93d2838..76bec83 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -697,6 +697,19 @@ void scanner::apply_config(void) } void scanner::on_ui_event(int uev, void* sender) { + if (uev == SANE_EVENT_UI_SCAN_COMMAND) //UI主动通知 + { + int(__stdcall * h)(int, void*) = scanner_ev_handler_; + if (h) + { + //wchar_t info[128] = { 0 }; + //(info, _countof(info) - 1, L"[CRAZY]%d scanner events stored but APP has no action, we try to trigger it ONCE ...\r\n", ev_cnt_); + //ev_cnt_--; + h(SANE_EVENT_UI_SCAN_COMMAND, evh_param_); + return; + } + } + bool indicator = sender == indicator_.get(); if (uev == SANE_EVENT_SCAN_FINISHED || uev == SANE_EVENT_UI_CLOSE_NORMAL || uev == SANE_EVENT_UI_CLOSE_CANCEL) { @@ -752,6 +765,8 @@ void scanner::on_ui_event(int uev, void* sender) ev_cnt_++; } + + if (ev_cnt_ == events_.count() && (ev_cnt_ >= 5 || (ev_cnt_ > 1 && !is_scanning_))) { @@ -2460,9 +2475,11 @@ COM_API_IMPLEMENT(scanner, int, get_scanned_images(DWORD milliseconds)) else Sleep(elapse); + count = images_.count(); + //int ev = get_event(); // - //count = images_.count(); + //if (ev == SANE_EVENT_SCAN_FINISHED) //{ // ui_hide(); @@ -2930,7 +2947,7 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo // break; // } //}; - int res = callback::show_setting_ui(handle_, parent, &sane_api_, true); + int res = callback::show_setting_ui(handle_, parent, &sane_api_, with_scan); if (res == ui_result::UI_RESULT_CLOSE_NORMAL) { int ev = SANE_EVENT_UI_CLOSE_NORMAL;