修复设置界面启动扫描时,进度界面显示问题

This commit is contained in:
gb 2022-07-28 09:57:26 +08:00
parent 9a70b24d00
commit 7b5a581049
3 changed files with 10 additions and 7 deletions

View File

@ -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

View File

@ -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);

View File

@ -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;
}