RbBFBlokProjPSIVStrn2005.04 ACnmStrnAChpStrnACsvStrnVer1Strn1 Ver2Strn0 Ver3Strn0 RelsStrn0 NnRlStrn0 RegnStrnSVerStrnLVerStrnIVerStrnaiviInt DVewInt gprTpInt DLanInt CLanInt DEncInt BflgInt IconGrupEndGInt MacCStrnBMacStrnMy Application (Classic)BCarStrnMy Application BCMOStrnMy Application BSizInt @BMSzInt BSzSStrn4096BMSSStrn2048MDIcStrnBWinStrnMy Application.exe BMDIInt BL86Strn MyApplication PadnPadn********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************BlokpObj NameStrnApp ContInt paswStrnbClsInt SuprStrn Application bNtrInt bApOInt CompStrnPDefGrup$nameStrnMenuBar PValInt s%EndGInt VwBhGrupEndGInt CnstGrupEncoInt nameStrnkFileQuitShortcut typeInt defnStrnflagInt CInsGrup0pltfInt langInt defnStrnCmd+Q EndGInt EndGInt CnstGrupEncoInt nameStrn kFileQuit typeInt defnStrnQuitflagInt CInsGrup0pltfInt langInt defnStrnE&xit EndGInt CInsGrup0pltfInt langInt defnStrnE&xit EndGInt EndGInt CnstGrupEncoInt nameStrn kEditClear typeInt defnStrn&Delete flagInt CInsGrup0pltfInt langInt defnStrn&Delete EndGInt CInsGrup0pltfInt langInt defnStrn&Delete EndGInt EndGInt PadnPadnd****************************************************************************************************BlokpVewg@NameStrnWindow1 ContInt paswStrnbClsInt SuprStrnWindow bNtrInt CompStrnPDefGrup0nameStrnMenuBar PValStrn 1931845631 EndGInt PDefGrup(nameStrn MacProcID PValInt EndGInt PDefGrup4nameStrn BalloonHelp EncoInt PValStrnEndGInt PDefGrup0nameStrnMinimizeButton PValStrnTrueEndGInt PDefGrup0nameStrnMaximizeButton PValStrnTrueEndGInt PDefGrup0nameStrn LiveResize PValStrnFalse EndGInt PDefGrup,nameStrn Resizeable PValStrnTrueEndGInt PDefGrup,nameStrn CloseButton PValStrnTrueEndGInt PDefGrup0nameStrnMenuBarVisible PValStrnTrueEndGInt PDefGrup0nameStrn FullScreen PValStrnFalse EndGInt PDefGrup(nameStrnVisible PValStrnTrueEndGInt PDefGrup@nameStrnTitle EncoInt PValStrn TwainTest2006 EndGInt PDefGrup$nameStrnBackdropPValStrnEndGInt PDefGrup(nameStrn BackColor PValInt EndGInt PDefGrup0nameStrn HasBackColorPValStrnFalse EndGInt PDefGrup0nameStrn Composite PValStrnFalse EndGInt PDefGrup$nameStrnFrame PValInt EndGInt PDefGrup(nameStrn MaxHeight PValInt }EndGInt PDefGrup$nameStrnMaxWidthPValInt }EndGInt PDefGrup(nameStrn MinHeight PValInt @EndGInt PDefGrup$nameStrnMinWidthPValInt @EndGInt PDefGrup$nameStrnHeight PValInt ,EndGInt PDefGrup$nameStrnWidth PValInt EndGInt PDefGrup(nameStrn Placement PValInt EndGInt VwBhGrup lVwPrGrup0NameStrnNameVsblInt PrGpStrnID EndGInt VwPrGrup8NameStrn Interfaces VsblInt PrGpStrnID EndGInt VwPrGrup4NameStrnSuper VsblInt PrGpStrnID EndGInt VwPrGrupLNameStrn Placement VsblInt PrGpStrnPositionPValStrn0 EndGInt VwPrGrupHNameStrnWidth VsblInt PrGpStrnPositionPValStrn300 EndGInt VwPrGrupHNameStrnHeight VsblInt PrGpStrnPositionPValStrn300 EndGInt VwPrGrupHNameStrnMinWidthVsblInt PrGpStrnPositionPValStrn64 EndGInt VwPrGrupLNameStrn MinHeight VsblInt PrGpStrnPositionPValStrn64 EndGInt VwPrGrupL NameStrnMaxWidthVsblInt PrGpStrnPositionPValStrn32000 EndGInt  VwPrGrupP NameStrn MaxHeight VsblInt PrGpStrnPositionPValStrn32000 EndGInt  VwPrGrupL NameStrnFrame VsblInt PrGpStrn Appearance PValStrn0 EndGInt  VwPrGrupT NameStrn Composite VsblInt PrGpStrn Appearance PValStrnFalse EndGInt  VwPrGrupT NameStrn HasBackColorVsblInt PrGpStrn Appearance PValStrnFalse EndGInt  VwPrGrupTNameStrn BackColor VsblInt PrGpStrn Appearance PValStrn&hFFFFFFEndGInt VwPrGrup<NameStrnBackdropVsblInt PrGpStrn Appearance EndGInt VwPrGrupPNameStrnTitle VsblInt PrGpStrn Appearance PValStrnUntitledEndGInt VwPrGrupLNameStrnVisible VsblInt PrGpStrn Appearance PValStrnTrueEndGInt VwPrGrupTNameStrn FullScreen VsblInt PrGpStrn Appearance PValStrnFalse EndGInt VwPrGrupTNameStrnMenuBarVisible VsblInt PrGpStrn Appearance PValStrnTrueEndGInt VwPrGrupPNameStrn CloseButton VsblInt PrGpStrn Appearance PValStrnTrueEndGInt VwPrGrupTNameStrn Resizeable VsblInt PrGpStrn Appearance PValStrnFalse EndGInt VwPrGrupTNameStrn LiveResize VsblInt PrGpStrn Appearance PValStrnFalse EndGInt VwPrGrupXNameStrnMaximizeButton VsblInt PrGpStrn Appearance PValStrnFalse EndGInt VwPrGrupTNameStrnMinimizeButton VsblInt PrGpStrn Appearance PValStrnTrueEndGInt VwPrGrup@NameStrn BalloonHelp VsblInt PrGpStrn Appearance EndGInt VwPrGrupPNameStrn MacProcID VsblInt PrGpStrn Appearance PValStrn0 EndGInt VwPrGrup<NameStrnMenuBar VsblInt PrGpStrn Appearance EndGInt EndGInt CBhvGrupSuprStrn PushButton HInsGrupnameStrnAction CompStrnsorcGrupEncoInt srclStrn Sub Action()srclStrnDim f As FolderItem srclStrnDim tw As New sjgEZTwainsrclStrnsrclStrnIf clipButton.Value ThensrclStrnIf tw.AcquireToClipboard Then srclStrn!MsgBox "Picture now on Clipboard" srclStrnElsesrclStrnMsgBox tw.lastError srclStrnEnd If srclStrnsrclStrnElse // fileButton.Value srclStrn(f = TemporaryFolder.child("sjgtest.bmp")srclStrnIf tw.AcquireToFile(f) Then srclStrnCanvas1.Backdrop = tw.pic srclStrnf.LaunchsrclStrnElsesrclStrnMsgBox tw.lastError srclStrnEnd If srclStrnsrclStrnEnd If srclStrnEnd Sub EndGInt EndGInt EndGInt CBhvGrupSuprStrnCanvas EndGInt CBhvGrup SuprStrn PushButton HInsGrupT!nameStrnAction CompStrnsorcGrup"EncoInt srclStrn Sub Action()srclStrnDim f As FolderItem srclStrnDim tw As New sjgEZTwainsrclStrnsrclStrnIf tw.SelectSource Then srclStrnMsgBox tw.classVersion srclStrnElsesrclStrnMsgBox tw.lastErrorsrclStrnEnd If srclStrnEnd Sub EndGInt "EndGInt !EndGInt  CBhvGrup#SuprStrnGroupBoxEndGInt #CBhvGrup$SuprStrn RadioButton EndGInt $CBhvGrup%SuprStrn RadioButton EndGInt %CtrlGrup&cclsStrnGroupBoxnameStrnGroupBoxPDefGrup8'nameStrn InitialParent EncoInt PValStrnEndGInt 'PDefGrup((nameStrn Underline PValStrnEndGInt (PDefGrup$)nameStrnItalic PValStrnEndGInt )PDefGrup *nameStrnBoldPValStrnEndGInt *PDefGrup$+nameStrnTextSizePValInt EndGInt +PDefGrup8,nameStrnTextFontEncoInt PValStrnSystem EndGInt ,PDefGrup0-nameStrnAutoDeactivate PValStrnTrueEndGInt -PDefGrup0.nameStrnHelpTag EncoInt PValStrnEndGInt .PDefGrup(/nameStrnVisible PValStrnTrueEndGInt /PDefGrup(0nameStrnEnabled PValStrnTrueEndGInt 0PDefGrup81nameStrnCaption EncoInt PValStrnAcquire EndGInt 1PDefGrup,2nameStrn TabPanelIndex PValInt EndGInt 2PDefGrup,3nameStrn LockBottom PValStrnTrueEndGInt 3PDefGrup,4nameStrn LockRight PValStrnTrueEndGInt 4PDefGrup$5nameStrnLockTop PValStrnEndGInt 5PDefGrup,6nameStrnLockLeftPValStrnFalse EndGInt 6PDefGrup$7nameStrnHeight PValInt PEndGInt 7PDefGrup$8nameStrnWidth PValInt qEndGInt 8PDefGrup 9nameStrnTop PValInt EndGInt 9PDefGrup :nameStrnLeftPValInt EndGInt :PDefGrup8;nameStrn ControlOrderEncoInt PValStrn0 EndGInt ;PDefGrup8nameStrnNameEncoInt PValStrn GroupBox1 EndGInt >CBixInt EndGInt &CtrlGrup?cclsStrn RadioButton nameStrn RadioButton PDefGrupD@nameStrn InitialParent EncoInt PValStrn GroupBox1 EndGInt @PDefGrup,AnameStrnValue PValStrnFalse EndGInt APDefGrup(BnameStrn Underline PValStrnEndGInt BPDefGrup$CnameStrnItalic PValStrnEndGInt CPDefGrup DnameStrnBoldPValStrnEndGInt DPDefGrup$EnameStrnTextSizePValInt EndGInt EPDefGrup8FnameStrnTextFontEncoInt PValStrnSystem EndGInt FPDefGrup0GnameStrnAutoDeactivate PValStrnTrueEndGInt GPDefGrup0HnameStrnHelpTag EncoInt PValStrnEndGInt HPDefGrup(InameStrnVisible PValStrnTrueEndGInt IPDefGrup(JnameStrnEnabled PValStrnTrueEndGInt JPDefGrup<KnameStrnCaption EncoInt PValStrn To ClipboardEndGInt KPDefGrup,LnameStrn TabPanelIndex PValInt EndGInt LPDefGrup0MnameStrn LockBottom PValStrnFalse EndGInt MPDefGrup(NnameStrn LockRight PValStrnEndGInt NPDefGrup$OnameStrnLockTop PValStrnEndGInt OPDefGrup,PnameStrnLockLeftPValStrnFalse EndGInt PPDefGrup$QnameStrnHeight PValInt EndGInt QPDefGrup$RnameStrnWidth PValInt SEndGInt RPDefGrup SnameStrnTop PValInt EndGInt SPDefGrup TnameStrnLeftPValInt EndGInt TPDefGrup(UnameStrn ControlOrderPValInt EndGInt UPDefGrup<VnameStrnSuper EncoInt PValStrn RadioButton EndGInt VPDefGrup$WnameStrnIndex PValInt EndGInt WPDefGrup8XnameStrnNameEncoInt PValStrn clipButton EndGInt XCBixInt EndGInt ?CtrlGrupYcclsStrn RadioButton nameStrn RadioButton PDefGrupDZnameStrn InitialParent EncoInt PValStrn GroupBox1 EndGInt ZPDefGrup([nameStrnValue PValStrnTrueEndGInt [PDefGrup(\nameStrn Underline PValStrnEndGInt \PDefGrup$]nameStrnItalic PValStrnEndGInt ]PDefGrup ^nameStrnBoldPValStrnEndGInt ^PDefGrup$_nameStrnTextSizePValInt EndGInt _PDefGrup8`nameStrnTextFontEncoInt PValStrnSystem EndGInt `PDefGrup0anameStrnAutoDeactivate PValStrnTrueEndGInt aPDefGrup0bnameStrnHelpTag EncoInt PValStrnEndGInt bPDefGrup(cnameStrnVisible PValStrnTrueEndGInt cPDefGrup(dnameStrnEnabled PValStrnTrueEndGInt dPDefGrup8enameStrnCaption EncoInt PValStrnTo File EndGInt ePDefGrup,fnameStrn TabPanelIndex PValInt EndGInt fPDefGrup0gnameStrn LockBottom PValStrnFalse EndGInt gPDefGrup(hnameStrn LockRight PValStrnEndGInt hPDefGrup$inameStrnLockTop PValStrnEndGInt iPDefGrup,jnameStrnLockLeftPValStrnFalse EndGInt jPDefGrup$knameStrnHeight PValInt EndGInt kPDefGrup$lnameStrnWidth PValInt 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 CompStrnsorcGrupEncoInt 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 MethGrup0nameStrn SelectSourceCompStrnsorcGrupEncoInt 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 MethGrup8nameStrn reportError CompStrnsorcGrupEncoInt 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 NoteGrupnameStrnAbout 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 NoteGrupnameStrnWarning 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 NoteGrupnameStrnUsage 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 PropGruptEncoInt declStrnclassVersion As String flagInt sorcGrup@EncoInt srclStrnclassVersion As String srclStrnEndGInt CPrsGrup@EncoInt srclStrnSet srclStrnsrclStrnEnd Set EndGInt CPrgGruplEncoInt 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********************************************************************************************************************************************************************************************************************************************************************************************BlokpUIsWnStGrupOTabGrupContInt eSptInt EndGInt OTabGrupContInt gEndGInt OTabGrupContInt _EndGInt OTabGrupContInt gEndGInt LsLcStrnsjgEZTwain.UsagerEdtRect<EndGInt PadnPadn********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************EOF!