From 7b5a581049750f6d26add7152a2e255b8c01d467 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Thu, 28 Jul 2022 09:57:26 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=AE=BE=E7=BD=AE=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=E5=90=AF=E5=8A=A8=E6=89=AB=E6=8F=8F=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E8=BF=9B=E5=BA=A6=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- device/win_usb/win_usb.cpp | 13 ++++++------- sane/scanner.cpp | 3 +++ twain/twain/huagaods.cpp | 1 + 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/device/win_usb/win_usb.cpp b/device/win_usb/win_usb.cpp index 1ca776e..0abc957 100644 --- a/device/win_usb/win_usb.cpp +++ b/device/win_usb/win_usb.cpp @@ -699,16 +699,15 @@ int usb_device::set_timeout(unsigned milliseconds) } int usb_device::transfer_bulk(unsigned endpoint, unsigned char* data, int* length, unsigned int timeout) { - typedef BOOL(WINAPI* file_io)(HANDLE, LPVOID, DWORD, LPDWORD, LPOVERLAPPED); int ret = LIBUSB_ERROR_NOT_SUPPORTED; HANDLE h = find_pipe(endpoint, USBSCAN_PIPE_BULK); - file_io fio = (endpoint & BULKIN_FLAG) ? ReadFile : (file_io)WriteFile; if (h) { ovl_cls *oc = ovl_mgr_.get_ovl(); DWORD io = 0; - BOOL result = fio(h, data, *length, oc->io_bytes(), oc->over_lapped()); + BOOL result = (endpoint & BULKIN_FLAG) ? ReadFile(h, data, *length, oc->io_bytes(), oc->over_lapped()) + : WriteFile(h, data, *length, oc->io_bytes(), oc->over_lapped()); if (result) { @@ -723,8 +722,8 @@ int usb_device::transfer_bulk(unsigned endpoint, unsigned char* data, int* lengt { if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0) { - GetOverlappedResult(h, oc->over_lapped(), &io, FALSE); - *length = io; + GetOverlappedResult(h, oc->over_lapped(), oc->io_bytes(), FALSE); + *length = *oc->io_bytes(); ret = LIBUSB_SUCCESS; } else @@ -808,8 +807,8 @@ int usb_device::transfer_interrupt(unsigned endpoint, unsigned char* data, int* { if (WaitForSingleObject(oc->over_lapped()->hEvent, timeout) == WAIT_OBJECT_0) { - GetOverlappedResult(h, oc->over_lapped(), &io, FALSE); - *length = io; + GetOverlappedResult(h, oc->over_lapped(), oc->io_bytes(), FALSE); + *length = *oc->io_bytes(); ret = LIBUSB_SUCCESS; } else diff --git a/sane/scanner.cpp b/sane/scanner.cpp index c49a3d5..d1f71c6 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -2005,6 +2005,9 @@ COM_API_IMPLEMENT(scanner, bool, ui_show_setting(HWND parent, bool with_scan, bo } COM_API_IMPLEMENT(scanner, bool, ui_show_progress(HWND parent)) { + if(setting_.get() && IsWindowVisible(setting_->hwnd())) + parent = setting_->hwnd(); + indicator_.reset(new dlg_indicator(parent)); indicator_->set_ui_event_notify(&scanner::ui_callback, this); indicator_->show(true); diff --git a/twain/twain/huagaods.cpp b/twain/twain/huagaods.cpp index 3c34a20..d618be8 100644 --- a/twain/twain/huagaods.cpp +++ b/twain/twain/huagaods.cpp @@ -725,6 +725,7 @@ Result huagao_ds::eventProcess(const Identity&, Event& event) notifyCloseOk(); break; case SANE_EVENT_UI_SCAN_COMMAND: + scanner_->ui_show_progress(NULL); scanner_->start(); break; }