int CTwain::DropToState(int nS, HWND hwnd) { hwnd = DefWnd(hwnd); while (nState > nS) { switch (nState) { case TRANSFERRING: if (!EndXfer()) return FALSE; break; case TRANSFER_READY: if (!CancelXfers()) return FALSE; break; case SOURCE_ENABLED: if (!DisableSource()) return FALSE; break; case SOURCE_OPEN: if (!CloseSource()) return FALSE; break; case SOURCE_MANAGER_OPEN: if (!CloseSourceManager(hwnd)) return FALSE; break; case SOURCE_MANAGER_LOADED: if (!UnloadSourceManager()) return FALSE; break; default: ATLASSERT(FALSE); } // switch } // while return TRUE; }
/* Closes the Data Source */ void CTwain::CloseDS() { if(DSOpen()) { DisableSource(); CallTwainProc(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_CLOSEDS,(TW_MEMREF)&m_Source); m_bDSOpen = FALSE; } }
int CTwain::CloseSource(void) { rc = TWRC_SUCCESS; if (nState == SOURCE_ENABLED) { DisableSource(); } if (nState == SOURCE_OPEN) { DS(DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS, &SourceId); if (nState == SOURCE_OPEN && bTrace) ATLTRACE(_T("TWAIN:CloseSource failed.\n")); } return (nState < SOURCE_OPEN); } // CloseSource
/* Ends the current transfer. Returns TRUE if the more images are pending */ BOOL CTwain::EndTransfer() { TW_PENDINGXFERS twPend; if(CallTwainProc(&m_AppId,&m_Source,DG_CONTROL,DAT_PENDINGXFERS,MSG_ENDXFER,(TW_MEMREF)&twPend)) { if (twPend.Count == 0) { DisableSource(); _bHasNextPic = FALSE; } else _bHasNextPic = TRUE; TRACE("********** EndTransfer --> twPend.Count = %d ************\n", twPend.Count); return twPend.Count != 0; } return FALSE; }