diff --git a/sane/scanner.cpp b/sane/scanner.cpp index c1db35b..6860cd9 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -356,7 +356,7 @@ namespace callback static HMODULE hui = NULL; int (*choose_scanner)(const std::vector& devs) = NULL; // blocked. return selected DEVQUE::id or -1 if user cancelled char* (*apply_current_config)(const char* dev_name, SANE_Handle device, LPSANEAPI api) = NULL; // 閹煎瓨姊婚弫銈囨媼閹屾У闁汇劌瀚紞瀣礈瀹ュ甯抽柨? - int (*show_setting_ui)(SANE_Handle device, HWND parent, LPSANEAPI api, const char* devname, bool with_scan, std::function callback) = NULL; + int (*show_setting_ui)(SANE_Handle device, HWND parent, LPSANEAPI api, const char* devname, bool with_scan, std::function callback, std::function* notify) = NULL; int (*show_progress_ui)(HWND parent, std::function callback, std::function* notify) = NULL; int (*show_messagebox_ui)(HWND parent, int event, void* msg, int flag) = NULL; int (*close_ui)(int) = NULL; @@ -3488,6 +3488,8 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo is_show_ui_ = with_scan; is_show_setting_ = true; events_.clear(); + ui_notify = std::function(); + if (callback::show_setting_ui) { if (with_scan) @@ -3529,7 +3531,8 @@ 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_, local_trans::u2a(scanner_name_.c_str(), CP_UTF8).c_str(),with_scan, ui); + + int res = callback::show_setting_ui(handle_, parent, &sane_api_, local_trans::u2a(scanner_name_.c_str(), CP_UTF8).c_str(),with_scan, ui, &ui_notify); //if (res == ui_result::UI_RESULT_CLOSE_NORMAL) //{ // int ev = SANE_EVENT_UI_CLOSE_NORMAL; @@ -3580,7 +3583,8 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator)) { is_bIndicator = bIndicator; - ui_notify = std::function(); + if (is_bIndicator) + ui_notify = std::function(); auto ui_process = [this](ui_result res) { int uev = SANE_EVENT_SCAN_FINISHED; @@ -3660,10 +3664,14 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) { is_in_working_thread_ = true; img_ind_ = 0; + if (prog) prog->notify_working(); else if (callback::show_progress_ui && is_bIndicator && ui_notify) ui_notify(ev_code, data, *len); + else if (callback::show_setting_ui && ui_notify) + ui_notify(ev_code, data, *len); + on_ui_event(ev_code, (void*)ev_code); log_info(L"Scanning ...\r\n", 1); }