From 7bc0e367c834435efd2ebeefcd6d5068dc663151 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Tue, 23 May 2023 11:20:16 +0800 Subject: [PATCH] check if APP invoked eventProcess --- twain/twain/huagaods.cpp | 9 +++++++-- twain/twain/huagaods.hpp | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index a86767f..11f7053 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -928,6 +928,7 @@ Result huagao_ds::eventProcess(const Identity&, Event& event) notifyCloseCancel(); notfify_close_ = false; } + has_event_called_ = true; event.setMessage(Msg::Null); @@ -1115,6 +1116,7 @@ Result huagao_ds::userInterfaceEnable(const Identity&, UserInterface& ui) notfify_close_ = false; bUiOnly_ = false; show_setting_ = false; + has_event_called_ = false; if (!ui.showUi()) { scanner_->ui_show_progress((HWND)ui.parent().raw(), m_bIndicator); @@ -3633,9 +3635,12 @@ int huagao_ds::handle_scanner_event(int ev, bool from_event_proc) break; case SANE_EVENT_UI_CLOSE_SETTING: scanner_->ui_hide(); - notfify_close_ = true; + if(has_event_called_) + notfify_close_ = true; + else + rc = notifyCloseCancel(); //if(main_thread_id_ == GetCurrentThreadId()) - //rc = notifyCloseCancel(); + // rc = notifyCloseCancel(); //else //{ // HANDLE thrd = OpenThread(THREAD_ALL_ACCESS, FALSE, main_thread_id_); diff --git a/twain/twain/huagaods.hpp b/twain/twain/huagaods.hpp index 0306c8c..702b19f 100644 --- a/twain/twain/huagaods.hpp +++ b/twain/twain/huagaods.hpp @@ -59,6 +59,7 @@ class huagao_ds : public Twpp::SourceFromThis { int count_; volatile bool is_getting_count_; volatile bool notfify_close_ = false; + volatile bool has_event_called_ = false; static std::string get_hidedlg_path(void); static void showmsg(const char* msg, int err); static int __stdcall on_scanner_event(int ev, void* param);