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;