home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / twains1a / form1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-10-07  |  4.3 KB  |  124 lines

  1. VERSION 5.00
  2. Begin VB.Form Form1 
  3.    Caption         =   "EZTWAIN in Visual Basic"
  4.    ClientHeight    =   3195
  5.    ClientLeft      =   60
  6.    ClientTop       =   345
  7.    ClientWidth     =   4680
  8.    LinkTopic       =   "Form1"
  9.    ScaleHeight     =   3195
  10.    ScaleWidth      =   4680
  11.    StartUpPosition =   2  'CenterScreen
  12.    Begin VB.CommandButton Command4 
  13.       Caption         =   "??? Version ???"
  14.       Height          =   255
  15.       Left            =   2760
  16.       TabIndex        =   4
  17.       Top             =   480
  18.       Width           =   1695
  19.    End
  20.    Begin VB.CommandButton Command3 
  21.       Caption         =   "Scan to Clipboard"
  22.       Height          =   255
  23.       Left            =   2760
  24.       TabIndex        =   3
  25.       Top             =   120
  26.       Width           =   1695
  27.    End
  28.    Begin VB.PictureBox Picture1 
  29.       AutoSize        =   -1  'True
  30.       Height          =   1815
  31.       Left            =   0
  32.       ScaleHeight     =   1755
  33.       ScaleWidth      =   3195
  34.       TabIndex        =   2
  35.       Top             =   960
  36.       Width           =   3255
  37.    End
  38.    Begin VB.CommandButton Command2 
  39.       Caption         =   "Select Scanner"
  40.       Height          =   255
  41.       Left            =   120
  42.       TabIndex        =   1
  43.       Top             =   120
  44.       Width           =   2415
  45.    End
  46.    Begin VB.CommandButton Command1 
  47.       Caption         =   "Scan Image"
  48.       Height          =   255
  49.       Left            =   120
  50.       TabIndex        =   0
  51.       Top             =   480
  52.       Width           =   2415
  53.    End
  54. Attribute VB_Name = "Form1"
  55. Attribute VB_GlobalNameSpace = False
  56. Attribute VB_Creatable = False
  57. Attribute VB_PredeclaredId = True
  58. Attribute VB_Exposed = False
  59. Private Sub Command1_Click()
  60. 'You need this Error Trap incase a
  61. 'problem occurs
  62. On Error GoTo BadScan
  63. 'Before you get past this point, it may be a
  64. 'good idea to call a function here, to remove a
  65. 'temporary file that amy have been left over
  66. 'from a prevoius session.
  67. 'Be nice and change the cursor to an Hour Glass,
  68. 'Some scanners take too long to load into view.
  69. Screen.MousePointer = 11
  70. 'This code will place the scanned image
  71. 'at "c:\"  I recommend that you use a special
  72. 'coding to find the Windows directory
  73. 'and place the file there. You have a better
  74. 'chance of having enough drive space to
  75. 'store it.
  76. s% = TWAIN_AcquireToFilename(Me.hWnd, "c:\temp.bmp")
  77. If s% = 0 Then
  78.    'If s% = 0 then everything was a success so far!
  79.    'Here, we load the image into the picture box.
  80.    'It is a good idea to have a sub or function that
  81.    'will test the image to make sure it is valid. I would load the image
  82.    'into an invisible image box with an error trap. If the image loads
  83.    'without error, I clear the box and load it into the
  84.    'picture box. (The Image control uses less memory)
  85.    Picture1.Picture = LoadPicture("c:\temp.bmp")
  86.    'We now can delete the temporary BMP file.
  87.    Kill "c:\temp.bmp"
  88.    'If s% did not = 0 then
  89.    'the user cancled the scan, or some other factor
  90.    'such as not enough drive space, etc...
  91.    'We go to our ERROR TRAP below and fix things.
  92.   GoTo BadScan
  93. End If
  94. Screen.MousePointer = 0
  95. 'Everything WORKED SO exit the sub!
  96. Exit Sub
  97. BadScan:
  98. 'Let the user know that the scanning
  99. 'process was not complete.
  100. MsgBox "Scan has been aborted", vbInformation, ""
  101. 'IMPORTANT
  102. 'Just incase, we should delete the temporary image.
  103. 'This is a good place to call a function to do that.
  104. 'Remember to use special coding to verify
  105. 'a file's existance.
  106. Screen.MousePointer = 0
  107. End Sub
  108. Private Sub Command2_Click()
  109. 'A user may have more than one
  110. 'scanning device. The code below will
  111. 'allow the user to select one.
  112.  TWAIN_SelectImageSource (Me.hWnd)
  113. End Sub
  114. Private Sub Command3_Click()
  115. 'Clear the clipboard, most
  116. 'scanned images are huge
  117. Clipboard.Clear
  118. 'This code explains itself...
  119.     If TWAIN_AcquireToClipboard(Me.hWnd, nPixTypes) = 0 Then MsgBox "No image was acquired or transfer to the clipboard failed.", vbInformation, ""
  120. End Sub
  121. Private Sub Command4_Click()
  122.     MsgBox ("VB Sample Application for EZTWAIN" + vbCrLf + vbCrLf + "eztwain dll reports version" + Str(TWAIN_EasyVersion() / 100) + vbCrLf + "TWAIN Services: " + IIf(TWAIN_IsAvailable() = 0, "Not Available", "") + "Available")
  123. End Sub
  124.