home *** CD-ROM | disk | FTP | other *** search
/ Planet Source Code Jumbo …e CD Visual Basic 1 to 7 / 1_2002.ISO / Data / Zips / CODE_UPLOAD143101302001.psc / Main.frm (.txt) next >
Encoding:
Visual Basic Form  |  2001-01-30  |  3.5 KB  |  106 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMain 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Scan"
  5.    ClientHeight    =   6768
  6.    ClientLeft      =   60
  7.    ClientTop       =   348
  8.    ClientWidth     =   11424
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   6768
  13.    ScaleWidth      =   11424
  14.    StartUpPosition =   3  'Windows Default
  15.    WindowState     =   2  'Maximized
  16.    Begin VB.PictureBox Picture1 
  17.       Height          =   5892
  18.       Left            =   120
  19.       ScaleHeight     =   5844
  20.       ScaleWidth      =   11244
  21.       TabIndex        =   2
  22.       Top             =   840
  23.       Width           =   11292
  24.       Begin VB.HScrollBar HScroll 
  25.          Height          =   252
  26.          Left            =   0
  27.          TabIndex        =   4
  28.          Top             =   5640
  29.          Width           =   11052
  30.       End
  31.       Begin VB.VScrollBar VScroll 
  32.          Height          =   5652
  33.          LargeChange     =   5
  34.          Left            =   11040
  35.          TabIndex        =   3
  36.          Top             =   0
  37.          Width           =   252
  38.       End
  39.       Begin VB.PictureBox picScan 
  40.          Appearance      =   0  'Flat
  41.          BackColor       =   &H80000000&
  42.          BorderStyle     =   0  'None
  43.          ForeColor       =   &H80000008&
  44.          Height          =   1212
  45.          Left            =   0
  46.          ScaleHeight     =   1212
  47.          ScaleWidth      =   1692
  48.          TabIndex        =   5
  49.          Top             =   0
  50.          Width           =   1692
  51.       End
  52.    End
  53.    Begin VB.CommandButton cmdScan 
  54.       Caption         =   "Scan!"
  55.       Height          =   612
  56.       Left            =   5760
  57.       TabIndex        =   1
  58.       Top             =   120
  59.       Width           =   5532
  60.    End
  61.    Begin VB.CommandButton cmdSelect 
  62.       Caption         =   "Select TWAIN Source"
  63.       Height          =   612
  64.       Left            =   120
  65.       TabIndex        =   0
  66.       Top             =   120
  67.       Width           =   5532
  68.    End
  69. Attribute VB_Name = "frmMain"
  70. Attribute VB_GlobalNameSpace = False
  71. Attribute VB_Creatable = False
  72. Attribute VB_PredeclaredId = True
  73. Attribute VB_Exposed = False
  74. 'The TWAIN32d.dll should be in the System directory
  75. Private Declare Function TWAIN_AcquireToFilename Lib "TWAIN32d.DLL" (ByVal hwndApp As Long, ByVal bmpFileName As String) As Integer
  76. Private Declare Function TWAIN_IsAvailable Lib "TWAIN32d.DLL" () As Long
  77. Private Declare Function TWAIN_SelectImageSource Lib "TWAIN32d.DLL" (ByVal hwndApp As Long) As Long
  78. Dim ScrollAreaScan As CScrollArea
  79. Private Sub cmdScan_Click()
  80. Dim Ret As Long, PictureFile As String
  81. PictureFile = App.Path & "\temp.bmp"
  82. 'PicturFile is the temporary file "temp.bmp"
  83. 'In "temp.bmp" the image will stored until the end of the action
  84. Ret = TWAIN_AcquireToFilename(Me.hwnd, PictureFile)
  85. If Ret = 0 Then
  86. 'If the scan is successful
  87. picScan.Picture = LoadPicture(PictureFile)
  88. 'Load the temporary picture file
  89. ScrollAreaScan.ReSizeArea
  90. 'Resize the picture control
  91. Kill PictureFile
  92. 'Delete the temporary picture file
  93. MsgBox "Scan not successful!", vbCritical, "Scanning"
  94. End If
  95. End Sub
  96. Private Sub cmdSelect_Click()
  97. TWAIN_SelectImageSource (Me.hwnd)
  98. End Sub
  99. Private Sub Form_Load()
  100. Set ScrollAreaScan = New CScrollArea
  101. Set ScrollAreaScan.VBar = VScroll
  102. Set ScrollAreaScan.HBar = HScroll
  103. Set ScrollAreaScan.InnerPicture = picScan
  104. Set ScrollAreaScan.FramePicture = Picture1
  105. End Sub
  106.