不显示指示框的错误信息提示

This commit is contained in:
13038267101 2023-05-04 10:36:55 +08:00
parent 8a70b2f6ed
commit ee54680fdc
1 changed files with 69 additions and 37 deletions

View File

@ -345,6 +345,7 @@ namespace callback
int (*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) = 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;
//std::function<void(ui_result)> ui_result_callback;
std::function<void(int/*event*/, void*/*msg*/, int/*flag*/)> notify;
@ -376,6 +377,7 @@ namespace callback
GET_API(apply_current_config);
GET_API(show_setting_ui);
GET_API(show_progress_ui);
GET_API(show_messagebox_ui);
}
}
}
@ -876,13 +878,21 @@ int scanner::open(void)
apply_config();
}
else
{
if (callback::show_messagebox_ui)
{
callback::show_messagebox_ui(app_wnd_, ret, (void*)hg_scanner_err_description(ret), 0);
}
else
{
std::wstring msg(local_trans::a2u(hg_scanner_err_description(ret), CP_UTF8));
HWND parent = callback::find_main_wnd();
if (!IsWindow(parent))
callback::bring_message_box_topmost(local_trans::lang_trans_between_hz936(CONST_STRING_OPEN_FAILED).c_str());
MessageBoxW(parent, msg.c_str(), local_trans::lang_trans_between_hz936(CONST_STRING_OPEN_FAILED).c_str(), MB_OK | MB_ICONERROR);
//if (indicator_.get())
// indicator_->show(false);
if (!IsWindow(app_wnd_))
callback::bring_message_box_topmost(local_trans::lang_trans_between_hz936(CONST_STRING_START_FAILED).c_str());
MessageBoxW(app_wnd_, msg.c_str(), local_trans::lang_trans_between_hz936(CONST_STRING_START_FAILED).c_str(), MB_OK | MB_ICONERROR);
}
}
return ret;
@ -2424,6 +2434,21 @@ COM_API_IMPLEMENT(scanner, int, start(void))
// indicator_->notify_scan_over(hg_scanner_err_description(ret), true);
//}
else
{
if (callback::show_progress_ui && is_bIndicator)
{
int ev = ret;
ui_notify(ev, (void *)hg_scanner_err_description(ret), 0);
}
else
{
if (callback::show_messagebox_ui)
{
callback::show_messagebox_ui(app_wnd_, ret, (void*)hg_scanner_err_description(ret), 0);
}
else
{
std::wstring msg(local_trans::a2u(hg_scanner_err_description(ret), CP_UTF8));
@ -2433,6 +2458,8 @@ COM_API_IMPLEMENT(scanner, int, start(void))
callback::bring_message_box_topmost(local_trans::lang_trans_between_hz936(CONST_STRING_START_FAILED).c_str());
MessageBoxW(app_wnd_, msg.c_str(), local_trans::lang_trans_between_hz936(CONST_STRING_START_FAILED).c_str(), MB_OK | MB_ICONERROR);
}
}
}
prev_start_result_ = ret;
is_scanning_ = ret == SANE_STATUS_GOOD;
@ -2997,8 +3024,6 @@ 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;
if (callback::show_progress_ui && bIndicator)
{
auto ui_process = [this](ui_result res)
{
int uev = SANE_EVENT_SCAN_FINISHED;
@ -3024,6 +3049,9 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator))
break;
}
};
if (callback::show_progress_ui && bIndicator)
{
callback::show_progress_ui(parent, ui_process,&ui_notify);
}
@ -3126,7 +3154,11 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len)
ui_notify(ev_code, data, 0);
else
{
//if (*len)
if (callback::show_messagebox_ui && *len)
{
callback::show_messagebox_ui(app_wnd_, ev_code, (void*)data, 0);
}
else if (*len) //错误弹出
{
std::wstring msg(local_trans::a2u((char*)data, CP_UTF8));
if(!IsWindow(app_wnd_))