三方软件扫描时,不关闭设置界面,此时禁用设置界面使用

This commit is contained in:
yangjiaxuan 2023-11-29 14:41:06 +08:00
parent a4e5af59be
commit c5b71eb78f
1 changed files with 11 additions and 3 deletions

View File

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