RbBFBlokpObj _ÿ(NameStrn sjgEZTwain ContInt paswStrnbClsInt bNtrInt CompStrnMethGrupõnameStrn Constructor CompStrnsorcGrup”öEncoInt srclStrnSub Constructor() srclStrn#Const thisModule = " - Constructor" srclStrn#If TargetWin32 srclStrnCSoft Declare Function TWAIN_IsAvailable Lib "EZTW32.dll" As Integer srclStrnCSoft Declare Function TWAIN_EasyVersion Lib "EZTW32.dll" As Integer srclStrnDim ret As Integer srclStrnDIf System.IsFunctionAvailable("TWAIN_IsAvailable","EZTW32.dll") ThensrclStrnIf TWAIN_IsAvailable = 1 Then srclStrnSelf.Available = True srclStrnret = TWAIN_EasyVersion srclStrn)EZTwainVersion = Format(ret / 100,"0.00") srclStrnElsesrclStrn@reportError "TWAIN Source Manager cannot be loaded" + thisModulesrclStrnEnd If srclStrnElsesrclStrn/reportError "Unable to access dll" + thisModule srclStrnEnd If srclStrn#Else srclStrn5reportError "Available for Windows only" + thisModule srclStrn#EndIf srclStrnsrclStrnEnd Sub EndGInt öEncoInt AlasStrnflagInt parmStrnrsltStrnEndGInt õMethGrup€÷nameStrn AcquireToFile CompStrnsorcGrupàøEncoInt srclStrn8Function AcquireToFile(f As Folderitem = Nil) As BooleansrclStrnDim retVal As Boolean srclStrn$Const thisModule = "- AcquireToFile"srclStrn#If TargetWin32 srclStrnIf Self.Available Then srclStrnqSoft Declare Function TWAIN_AcquireToFilename Lib "EZTW32.dll"(hwndApp As Integer, pszFile As CString) As Integer srclStrnDim i As IntegersrclStrnsrclStrnIf f <> Nil ThensrclStrn fItem = f srclStrnElseif fItem Is Nil ThensrclStrn3fItem = TemporaryFolder.Child("sjgeztwaintemp.bmp") srclStrnEnd If srclStrnIf fItem <> Nil ThensrclStrn1i = TWAIN_AcquireToFilename(0,fItem.AbsolutePath) srclStrn If i = 0 Then srclStrnIf fItem.Exists ThensrclStrnpic = fItem.OpenAsPicture srclStrnIf pic <> Nil Then srclStrn retVal = True srclStrnEnd If srclStrnElsesrclStrn+reportError "File not created" + thisModule srclStrnEnd If srclStrnElsesrclStrn Select Case i srclStrnCase -1 srclStrnLreportError "Acquire failed OR user cancelled File Save dialog" + thisModulesrclStrnCase -2 srclStrnSreportError "file open error (invalid path or name, or access denied)" + thisModule srclStrnCase -3 srclStrnRreportError "(weird) unable to lock DIB - probably an invalid handle" + thisModule srclStrnCase -4 srclStrnRreportError "writing BMP data failed, possibly output device is full" + thisModule srclStrn End Select srclStrnEnd If srclStrnElsesrclStrn)reportError "Nil FolderItem" + thisModule srclStrnEnd If srclStrnIf retVal = False Then srclStrn pic = Nil srclStrnEnd If srclStrnEnd If srclStrn#EndIf srclStrn Return retVal srclStrnsrclStrn End FunctionEndGInt øEncoInt AlasStrnflagInt parmStrnf As Folderitem = Nil rsltStrnBoolean EndGInt ÷MethGrup@ùnameStrnAcquireToClipboard CompStrnsorcGrup´úEncoInt srclStrn(Function AcquireToClipboard() As BooleansrclStrnDim retVal As Boolean srclStrn)Const thisModule = "- AcquireToClipboard" srclStrn#If TargetWin32 srclStrnIf Self.Available Then srclStrntSoft Declare Function TWAIN_AcquireToClipboard Lib "EZTW32.dll"(hwndApp As Integer, wPixTypes As Integer) As IntegersrclStrnDim i As IntegersrclStrnsrclStrn!i = TWAIN_AcquireToClipboard(0,0) srclStrnDim clp As New ClipboardsrclStrnIf clp.PictureAvailable ThensrclStrnpic = clp.Picture srclStrnIf pic <> Nil Then srclStrn retVal = True srclStrnElsesrclStrn3reportError "Nil picture on clipboard" + thisModule srclStrnEnd If srclStrnElsesrclStrn pic = Nil srclStrn2reportError "No picture on clipboard" + thisModule srclStrnEnd If srclStrn clp.Close srclStrnEnd If srclStrn#EndIf srclStrn Return retVal srclStrn End FunctionEndGInt úEncoInt AlasStrnflagInt parmStrnrsltStrnBoolean EndGInt ùMethGrup0ûnameStrn SelectSourceCompStrnsorcGrup¬üEncoInt srclStrn"Function SelectSource() As Boolean srclStrnDim retVal As Boolean srclStrn#If TargetWin32 srclStrn$Const thisModule = " - SelectSource"srclStrnIf Self.Available Then srclStrnJIf system.IsFunctionAvailable("TWAIN_SelectImageSource","EZTW32.dll") Then srclStrnWSoft Declare Function TWAIN_SelectImageSource Lib "EZTW32.dll"(x As Integer) As Integer srclStrn&If TWAIN_SelectImageSource(0) = 1 Then srclStrn retVal = True srclStrnEnd If srclStrn9reportError "TWAIN_SelectImageSource failed" + thisModule srclStrnEnd If srclStrnEnd If srclStrn#EndIf srclStrn Return retVal srclStrn End FunctionEndGInt üEncoInt AlasStrnflagInt parmStrnrsltStrnBoolean EndGInt ûMethGrup8ýnameStrn reportError CompStrnsorcGrup¬þEncoInt srclStrnSub reportError(txt As String) srclStrndim d as new Date srclStrn0self.lastError = txt + EndOfLine + d.SQLDateTimesrclStrnEnd Sub EndGInt þEncoInt AlasStrnflagInt !parmStrn txt As String rsltStrnEndGInt ýNoteGrup¬ÿnameStrnAbout CompStrnsorcGrupdEncoInt ntlnStrnAbout ntlnStrn'This class was written by Steve Garman ntlnStrn!http://rb.sgarman.net/sjgeztwain/ ntlnStrnntlnStrn:It uses the Public Domain Windows dll EZTW32.dll by Dosadi ntlnStrn1available from http://www.dosadi.com/eztwain1.htm ntlnStrn in REALbasic ntlnStrnntlnStrn>This class requires EZTW32.dll to be either in the same folder ntlnStrn2as the app executable or to be in the Windows path ntlnStrnntlnStrn:%windir%/system32 is a good choice if looking for a folder ntlnStrn2that can be reasonably expected to be in the path. EndGInt flagInt EndGInt ÿNoteGrupœnameStrnWarning CompStrnsorcGrupTEncoInt ntlnStrnWarning ntlnStrn)There are many limitations to this class. ntlnStrnntlnStrn?One of them is that it may lock your application up if the user ntlnStrn7asks it to acquire when their TWAIN device is unplugged ntlnStrnntlnStrnBThis depends on the driver for your particular scanner/camera etc. EndGInt flagInt EndGInt NoteGrup¤nameStrnUsage CompStrnsorcGrup\EncoInt ntlnStrnUsage ntlnStrnL EZTW32.dll must be available in the Path or in the same folder as the .exentlnStrn (see About note) ntlnStrnntlnStrnSelectSource Method ntlnStrnO Only needs to be called if the user wishes to change the default TWAIN source ntlnStrn% Displays the standard Select dialog ntlnStrn, (Works by calling TWAIN_SelectImageSource)ntlnStrnntlnStrnAll Acquire functions ntlnStrn- Call the currently selected source's dialog ntlnStrnE Attempt to populate the class's public .pic property with a picture ntlnStrn* Return True on success, False on falure. ntlnStrnL Offer the reason for failure as a string in the public .lastError propertyntlnStrnntlnStrn8AcquireNative Method (not available before 2006 version)ntlnStrn? Populates the .pic picture directly with no intervening steps ntlnStrn( (Works by calling TWAIN_AcquireNative)ntlnStrnntlnStrnAcquireToClipboard Method ntlnStrne Captures the image to the system clipboard so it can be pasted into external applications like Pain ntlnStrn( Also populates .pic from the clipboardntlnStrn- (Works by calling TWAIN_AcquireToClipboard) ntlnStrnntlnStrnAcquireToFile MethodntlnStrn[ Takes an optional parameter which is a FolderItem pointing to the bmp file to be created. ntlnStrn# Captures the image to a .bmp file ntlnStrnP Offers a public property .fItem as a FolderItem pointing to the file created.sntlnStrn/ Also populates .pic using fItem.OpenAsPicture ntlnStrn, (Works by calling TWAIN_AcquireToFilename)EndGInt flagInt EndGInt PropGrup<EncoInt declStrnAvailable As BooleanflagInt EndGInt PropGrup@EncoInt declStrnEZTwainVersion As StringflagInt EndGInt PropGrup<EncoInt declStrnfItem As FolderItem flagInt EndGInt PropGrup8EncoInt declStrnpic As Picture flagInt EndGInt PropGrup< EncoInt declStrnlastError As String flagInt EndGInt  PropGrupt EncoInt declStrnclassVersion As String flagInt sorcGrup@ EncoInt srclStrnclassVersion As String srclStrnEndGInt  CPrsGrup@ EncoInt srclStrnSet srclStrnsrclStrnEnd Set EndGInt  CPrgGrupl EncoInt srclStrnGet srclStrn,Return "sjgEZTwain for RB2005 version 1.0.1"srclStrnEnd Get EndGInt  EndGInt  VwBhGrup8VwPrGrup0NameStrnNameVsblInt PrGpStrnID EndGInt VwPrGrupLNameStrnIndex VsblInt PrGpStrnID PValStrn -2147483648 EndGInt VwPrGrup4NameStrnSuper VsblInt PrGpStrnID EndGInt VwPrGrupDNameStrnLeftVsblInt PrGpStrnPositionPValStrn0 EndGInt VwPrGrupDNameStrnTop VsblInt PrGpStrnPositionPValStrn0 EndGInt VwPrGrup@NameStrn Available PrGpStrnBehaviorPValStrn0 EndGInt VwPrGrup4NameStrnEZTwainVersion PrGpStrnBehaviorEndGInt VwPrGrup8NameStrnpic PrGpStrnBehaviorPValStrn0 EndGInt VwPrGrup0NameStrn lastError PrGpStrnBehaviorEndGInt VwPrGrup0NameStrn classVersionPrGpStrnBehaviorEndGInt EndGInt PadnPadn********************************************************************************************************************************************************************************************************************************************************************************************EOF!