📄 duplex.frm
字号:
ImgAdmin1.Append strTopPages, lngTopPage, 1
ImgAdmin1.Append strBottomPages, lngBottomPage, 1
lngTopPage = lngTopPage + 1
lngBottomPage = lngBottomPage - 1
Next intIndex
'----------------------------------------------------------
' Since the interleaving is done, delete the 2 workfiles.
'----------------------------------------------------------
Call DeleteFile(strTopPages)
Call DeleteFile(strBottomPages)
End Sub
Private Sub cmdCancel_Click()
'**************************************************************
' PRIVATE SUB cmdCancel_Click: Unload the form.
'**************************************************************
Unload Me
End Sub
Private Sub cmdOK_Click()
'**************************************************************
' PRIVATE SUB cmdOK_Click: Save the OCR zone dimensions and
' unload the form.
'**************************************************************
'** Integers
Dim intIndex As Integer
'** Variants
Dim vntWorkingString As Variant
Unload Me
End Sub
Private Sub cmdRestart_Click()
'**************************************************************
' PRIVATE SUB cmdRestart_Click: Restart the process.
'**************************************************************
'----------------------------------------------------------
' Ask if you really want to restart.
'----------------------------------------------------------
MsgBox DELETE_FILES_AND_RESTART, vbYesNo, vbDefaultButton2 + vbQuestion
'----------------------------------------------------------
' Delete the 2 workfiles and the Interleaved file.
'----------------------------------------------------------
Call DeleteFile(mstrTopPages)
Call DeleteFile(mstrBottomPages)
Call DeleteFile(mstrInterleavedPages)
'----------------------------------------------------------
' Reset the form caption and display a blank image (8.5" x
' 11" at 100 DPI).
'----------------------------------------------------------
Me.Caption = "Duplex Scanning"
ImgEdit1.DisplayBlankImage 850, 1100, 100, 100
'----------------------------------------------------------
' Enable the Scan Top Pages button and disable others
' (Scan Bottom, Restart, OK).
'----------------------------------------------------------
cmdScanPages(0).Enabled = True 'Scan Top enabled.
cmdScanPages(1).Enabled = False 'Scan Bottom disabled.
cmdRestart.Enabled = False 'Restart disabled.
cmdOK.Enabled = False 'OK disabled.
End Sub
Private Sub cmdScanPages_Click(Index As Integer)
'**************************************************************
' PRIVATE SUB cmdScanPages_Click: Scan the top or bottom
' pages, depending on the Index passed in (Top = 0, Bottom = 1).
'**************************************************************
'** Strings
Dim strFileName As String
'----------------------------------------------------------
' When the Scan Top button is clicked (Index = 0), use a
' date/time stamp to assign the names of three files:
' WorkA will contain the top pages, WorkB will contain the
' bottom pages, and the one with no suffix will contain
' all of the pages (appropriately interleaved).
'----------------------------------------------------------
If Index = 0 Then
mstrDateTime = Format$(Now, "yymmddhhnnss")
mstrTopPages = gstrWindowsTempDirectory & "\Img" & mstrDateTime & "WorkA.tif"
mstrBottomPages = gstrWindowsTempDirectory & "\Img" & mstrDateTime & "WorkB.tif"
mstrInterleavedPages = gstrWindowsTempDirectory & "\Img" & mstrDateTime & ".tif"
End If
'----------------------------------------------------------
' Set the scan settings and scan the image.
'----------------------------------------------------------
ImgScan1.ShowSetupBeforeScan = True
ImgScan1.ScanTo = DisplayAndFile
ImgScan1.MultiPage = True
ImgScan1.FileType = 1 'TIFF
If Index = 0 Then
ImgScan1.Image = mstrTopPages
Else
ImgScan1.Image = mstrBottomPages
End If
ImgScan1.StartScan
ImgScan1.DestImageControl = "ImgEdit1"
'----------------------------------------------------------
' If a scan file was never created (the user
' cancelled out of the scan), exit the subroutine.
'----------------------------------------------------------
strFileName = Dir(ImgScan1.Image)
If strFileName = "" Then
Exit Sub
End If
'----------------------------------------------------------
' Store the fully qualified path name and page number and
' display the image using "Best Fit".
'----------------------------------------------------------
mstrFullPathFileName = ImgScan1.Image 'Store file/path name.
mlngPage = 1 'Store page number.
Call DisplayFile
'----------------------------------------------------------
' If Scan Bottom was clicked, interleave the pages from
' the two workfiles. Then display the resulting file
' using "Best Fit".
'----------------------------------------------------------
If Index = 1 Then 'Scan Bottom
Call InterleavePages(mstrTopPages, mstrBottomPages, mstrInterleavedPages)
mstrFullPathFileName = mstrInterleavedPages 'Store file/path name.
mlngPage = 1 'Store page number.
Call DisplayFile
End If
'----------------------------------------------------------
' If Scan Top was completed, disable the Scan Top and OK
' buttons, and enable the Scan Bottom and Restart buttons.
' If Scan Bottom was completed, disable the Scan Top and
' Scan Bottom buttons, and enable the Restart and OK
' buttons.
'----------------------------------------------------------
If Index = 0 Then 'Scan Top
cmdScanPages(0).Enabled = False 'Scan Top disabled.
cmdScanPages(1).Enabled = True 'Scan Bottom enabled.
cmdRestart.Enabled = True 'Restart enabled.
cmdOK.Enabled = False 'OK disabled.
ElseIf Index = 1 Then 'Scan Bottom
cmdScanPages(0).Enabled = False 'Scan Top disabled.
cmdScanPages(1).Enabled = False 'Scan Bottom disabled.
cmdRestart.Enabled = True 'Restart enabled.
cmdOK.Enabled = True 'OK enabled.
End If
End Sub
Private Sub Form_Load()
'**************************************************************
' PRIVATE SUB Form_Load: Load the form, disabling the Page
' menu items and enabling/disabling command buttons.
'**************************************************************
'** Integers
Dim intIndex As Integer
Dim intNumBits As Integer
'** Longs
Dim lngDC As Long
Dim lngIndex As Long
'----------------------------------------------------------
' Set the mouse pointer to an hourglass.
'----------------------------------------------------------
Screen.MousePointer = vbHourglass
'----------------------------------------------------------
' Find out how many colors the video driver supports. If
' it supports high color or true color, set the
' ImgEdit.ImagePalette for 24-bit RGB.
'----------------------------------------------------------
lngDC = hdc
lngIndex = 12 '12 = BITSPERPIXEL
intNumBits = GetDeviceCaps(lngDC, lngIndex)
If intNumBits > 8 Then
ImgEdit1.ImagePalette = wiPaletteRGB24
End If
'----------------------------------------------------------
' Since an image isn't displayed yet, disable the Page menu
' items.
'----------------------------------------------------------
For intIndex = 0 To 3
mnuPageDirectionItem(intIndex).Enabled = False
Next intIndex
'----------------------------------------------------------
' Since pages haven't been scanned yet, enable the Scan Top
' Pages button and disable the Scan Bottom, Restart, and
' OK buttons.
'----------------------------------------------------------
cmdScanPages(0).Enabled = True 'Scan Top enabled.
cmdScanPages(1).Enabled = False 'Scan Bottom disabled.
cmdRestart.Enabled = False 'Restart disabled.
cmdOK.Enabled = False 'OK disabled.
'----------------------------------------------------------
' Set the mouse pointer back to the default.
'----------------------------------------------------------
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Unload(Cancel As Integer)
'**************************************************************
' PRIVATE SUB Form_Unload: Unload the form.
'**************************************************************
Unload Me
End Sub
Private Sub mnuPageDirectionItem_Click(Index As Integer)
'**************************************************************
' PRIVATE SUB mnuPageDirectionItem_Click: Handles Previous,
' Next, First, and Last on the Page menu.
'**************************************************************
On Error Resume Next
'----------------------------------------------------------
' Set the new page number.
'----------------------------------------------------------
Select Case Index
Case 0 'Previous
ImgEdit1.Page = ImgEdit1.Page - 1
Case 1 'Next
ImgEdit1.Page = ImgEdit1.Page + 1
Case 2 'First
ImgEdit1.Page = 1
Case 3 'Last
ImgEdit1.Page = ImgEdit1.PageCount
End Select
mlngPage = ImgEdit1.Page
'----------------------------------------------------------
' If the first page, disable Previous and First menu items.
'----------------------------------------------------------
If ImgEdit1.Page = 1 Then
mnuPageDirectionItem(0).Enabled = False 'Previous
mnuPageDirectionItem(2).Enabled = False 'First
Else
mnuPageDirectionItem(0).Enabled = True 'Previous
mnuPageDirectionItem(2).Enabled = True 'First
End If
'----------------------------------------------------------
' If the last page, disable Next and Last menu items.
'----------------------------------------------------------
If ImgEdit1.Page = ImgEdit1.PageCount Then
mnuPageDirectionItem(1).Enabled = False 'Next
mnuPageDirectionItem(3).Enabled = False 'Last
Else
mnuPageDirectionItem(1).Enabled = True 'Next
mnuPageDirectionItem(3).Enabled = True 'Last
End If
'----------------------------------------------------------
' Display the page.
'----------------------------------------------------------
ImgEdit1.Display
'----------------------------------------------------------
' If an error occurred, declare a message box and exit
' the subroutine.
'----------------------------------------------------------
If ImgEdit1.StatusCode <> 0 Then
MsgBox Err.Description & " (ImgEdit error " & _
Hex(ImgEdit1.StatusCode) & ")", vbCritical
Exit Sub
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -