From 8a70b2f6ed1c51d86d9e4def25e444fd9072b43b Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Wed, 3 May 2023 17:09:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=96=B0=E7=89=88twain=20?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E7=95=8C=E9=9D=A2=E7=82=B9=E5=87=BB=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E4=B8=8D=E8=83=BD=E6=89=AB=E6=8F=8F=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E7=82=B9=E5=87=BB=E8=AE=BE=E7=BD=AE=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E6=98=BE=E7=A4=BA=E8=BF=9B=E5=BA=A6=E6=8C=87=E7=A4=BA?= =?UTF-8?q?=E5=99=A8=E5=B4=A9=E6=BA=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- device/scanner.vcxproj.user | 5 +++- sane/s2t_api.h | 2 +- sane/scanner.cpp | 54 +++++++++++++++++++++---------------- sane/scanner.h | 3 ++- twain/twain.vcxproj | 10 +++---- twain/twain.vcxproj.user | 6 ++++- twain/twain/huagaods.cpp | 7 ++--- 7 files changed, 52 insertions(+), 35 deletions(-) diff --git a/device/scanner.vcxproj.user b/device/scanner.vcxproj.user index 88a5509..52fecfc 100644 --- a/device/scanner.vcxproj.user +++ b/device/scanner.vcxproj.user @@ -1,4 +1,7 @@  - + + C:\Program Files\HuaGoScan\HuaGoScan.exe + WindowsLocalDebugger + \ No newline at end of file diff --git a/sane/s2t_api.h b/sane/s2t_api.h index d1eff00..d24fd78 100644 --- a/sane/s2t_api.h +++ b/sane/s2t_api.h @@ -282,7 +282,7 @@ struct __declspec(novtable) ISaneInvoker : public IRef // ui ... COM_API_DECLARE(bool, ui_show_main(HWND parent)); COM_API_DECLARE(bool, ui_show_setting(HWND parent, bool with_scan, bool indicator = true)); - COM_API_DECLARE(bool, ui_show_progress(HWND parent)); + COM_API_DECLARE(bool, ui_show_progress(HWND parent, bool bIndicator)); COM_API_DECLARE(void, ui_hide(void)); COM_API_DECLARE(bool, ui_is_ok(void)); diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 837e5b7..9917e50 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -386,7 +386,7 @@ scanner::scanner(SCANNERID id) : handle_(NULL), id_(id), ex_id_(EXTENSION_ID_BAS , dpi_(200), tmp_path_(L""), img_ind_(0) , scanner_name_(L""), cfg_(NULL), is_ui_wait_img_(false), is_scanning_(false) , scanner_ev_handler_(NULL), evh_param_(NULL), app_wnd_(NULL), user_cancel_(false) - , max_img_mem_(1 * 1024), twain_set_(false), ev_cnt_(0) + , max_img_mem_(1 * 1024), twain_set_(false), ev_cnt_(0), is_bIndicator(false) { sane_api_.sane_cancel_api = inner_sane_cancel; sane_api_.sane_close_api = inner_sane_close; @@ -2410,8 +2410,8 @@ COM_API_IMPLEMENT(scanner, int, start(void)) if (ret == SANE_STATUS_GOOD) { - if (indicator_.get() && !IsWindowVisible(indicator_->hwnd())) - indicator_->show(true); + /*if (indicator_.get() && !IsWindowVisible(indicator_->hwnd())) + indicator_->show(true);*/ unsigned int l = sizeof(img_fmt_); SANE_CompressionType cmprsn = img_fmt_.compress.compression; @@ -2427,8 +2427,8 @@ COM_API_IMPLEMENT(scanner, int, start(void)) { std::wstring msg(local_trans::a2u(hg_scanner_err_description(ret), CP_UTF8)); - if (indicator_.get()) - indicator_->show(false); + //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); @@ -2959,6 +2959,11 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo //start(); on_ui_event(SANE_EVENT_UI_SCAN_COMMAND, NULL); } + else if (res == UI_RESULT_CLOSE_CANCEL) + { + int ev = SANE_EVENT_UI_CLOSE_CANCEL; + on_ui_event(ev, (void*)ev); + } //on_ui_event(ev, NULL); } else if (cfg_) @@ -2989,9 +2994,10 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo return true; } -COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent)) +COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent, bool bIndicator)) { - if (callback::show_progress_ui) + is_bIndicator = bIndicator; + if (callback::show_progress_ui && bIndicator) { auto ui_process = [this](ui_result res) { @@ -3023,14 +3029,14 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent)) } else { - if (setting_.get() && IsWindowVisible(setting_->hwnd())) + /*if (setting_.get() && IsWindowVisible(setting_->hwnd())) parent = setting_->hwnd(); else if (!IsWindow(parent)) parent = callback::find_main_wnd(); indicator_.reset(new dlg_indicator(parent)); indicator_->set_ui_event_notify(&scanner::ui_callback, this); - indicator_->show(true); + indicator_->show(true);*/ } return true; @@ -3054,12 +3060,16 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) { if (ev_code == SANE_EVENT_WORKING) { - if (indicator_.get()) - indicator_->notify_working(); - else + //if (indicator_.get()) + // indicator_->notify_working(); + //else on_ui_event(ev_code, (void*)ev_code); + + if (callback::show_progress_ui && is_bIndicator) + ui_notify(ev_code, data, 0); + //else on_ui_event(ev_code, (void*)ev_code); - ui_notify(ev_code, data, 0); + log_info(L"Scanning ...\r\n", 0); } @@ -3093,8 +3103,8 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) { img->release(); } - if (indicator_.get()) - indicator_->notify_data_arrived(true); + //if (indicator_.get()) + // indicator_->notify_data_arrived(true); { wchar_t msg[128] = { 0 }; @@ -3104,21 +3114,19 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) } else if (ev_code == SANE_EVENT_USB_DATA_RECEIVED) { - if (indicator_.get()) - indicator_->notify_data_arrived(false); + //if (indicator_.get()) + // indicator_->notify_data_arrived(false); } else if (ev_code == SANE_EVENT_SCAN_FINISHED) { err_ = *len; - if (indicator_.get()) - indicator_->notify_scan_over((char*)data, *len != SCANNER_ERR_OK); - else if (callback::show_progress_ui) - { + //if (indicator_.get()) + // indicator_->notify_scan_over((char*)data, *len != SCANNER_ERR_OK); + if (callback::show_progress_ui && is_bIndicator) ui_notify(ev_code, data, 0); - } else { - if (*len) + //if (*len) { std::wstring msg(local_trans::a2u((char*)data, CP_UTF8)); if(!IsWindow(app_wnd_)) diff --git a/sane/scanner.h b/sane/scanner.h index e261adb..11f82f1 100644 --- a/sane/scanner.h +++ b/sane/scanner.h @@ -38,6 +38,7 @@ class scanner : public ISaneInvoker, virtual public refer int ex_id_; int prev_start_result_; int dpi_; + bool is_bIndicator; unsigned int img_ind_; std::wstring scanner_name_; std::wstring tmp_path_; @@ -315,7 +316,7 @@ public: // ui ... COM_API_OVERRIDE(bool, ui_show_main(HWND parent)); COM_API_OVERRIDE(bool, ui_show_setting(HWND parent, bool with_scan, bool indicator = true)); - COM_API_OVERRIDE(bool, ui_show_progress(HWND parent)); + COM_API_OVERRIDE(bool, ui_show_progress(HWND parent, bool bIndicator)); COM_API_OVERRIDE(void, ui_hide(void)); COM_API_OVERRIDE(bool, ui_is_ok(void)); diff --git a/twain/twain.vcxproj b/twain/twain.vcxproj index 566b172..c953bc9 100644 --- a/twain/twain.vcxproj +++ b/twain/twain.vcxproj @@ -78,11 +78,11 @@ $(SolutionDir)..\..\release\win\$(PlatformTarget)\OEM\huagao\ $(SolutionDir)..\..\tmp\$(PlatformTarget)\huagao\$(Configuration)\$(ProjectName)\ $(LibraryPath) - huagaotwain400.ds + huagaotwain200.ds $(LibraryPath) - huagaotwain400.ds + huagaotwain200.ds true $(SolutionDir)..\..\sdk\include\;$(SolutionDir)..\..\sdk\include\twain\;$(IncludePath) $(SolutionDir)..\..\release\win\$(PlatformTarget)\OEM\huagao\ @@ -126,9 +126,9 @@ copy "$(TargetPath)" C:\Windows\twain_32\HuagoTwain\$(TargetName) /y move /Y "$(TargetPath)" "$(OutputPath)$(TargetName)" mkdir "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" -move /Y "$(OutputPath)$(TargetName).lib" "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" -move /Y "$(OutputPath)$(TargetName).exp" "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" -move /Y "$(OutputPath)$(TargetName).pdb" "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" +copy /Y "$(OutputPath)$(TargetName).lib" "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" +copy /Y "$(OutputPath)$(TargetName).exp" "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" +copy /Y "$(OutputPath)$(TargetName).pdb" "$(ProjectDir)..\..\sdk\lib\win\$(PlatformTarget)\OEM\huagao" diff --git a/twain/twain.vcxproj.user b/twain/twain.vcxproj.user index 88a5509..7d5a374 100644 --- a/twain/twain.vcxproj.user +++ b/twain/twain.vcxproj.user @@ -1,4 +1,8 @@  - + + D:\work\code\twain-samples-master\TWAIN-Samples\Twain_App_sample01\visual_studio_mfc\Release\TWAIN_App_mfc32.exe + WindowsLocalDebugger + C:\Windows\twain_32\HuaGoTwain + \ No newline at end of file diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index ee5b467..598d10a 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -1173,8 +1173,9 @@ Result huagao_ds::userInterfaceEnable(const Identity&, UserInterface& ui) { if (!ui.showUi()) { - if (m_bIndicator && !scanner_->ui_show_progress((HWND)ui.parent().raw())) - return seqError(); + scanner_->ui_show_progress((HWND)ui.parent().raw(), m_bIndicator); + //if (m_bIndicator && !) + // return seqError(); xfer_ready_failed_ = false; scanner_->twain_set_transfer((twain_xfer)m_capXferMech); @@ -3467,7 +3468,7 @@ int huagao_ds::handle_scanner_event(int ev, bool from_event_proc) break; case SANE_EVENT_UI_SCAN_COMMAND: if (m_bIndicator) - scanner_->ui_show_progress(NULL); + scanner_->ui_show_progress(NULL, m_bIndicator); else scanner_->ui_hide(); scanner_status_ = SCANNER_STATUS_SCAN_1;