VintaSoft Twain ActiveX Discussions
Questions, comments and suggestions concerning VintaSoft Twain ActiveX.
Board index < VintaSoft Twain < VintaSoft Twain ActiveX Discussions
' Einheit festlegen
VSTwain1.Device_UnitOfMeasure = UNITOFMEASURE_Millimeters
' Scanbereich festlegen
VSTwain1.Device_SetImageLayout 0, 0, 50, 110
Thank you for your answers. ' disable application UI
scanImagesButton.Enabled = False
' try to use TWAIN device manager 2.x
VSTwain1.DeviceManager_IsTwain2Compatible = twain2CheckBox.Value
' if TWAIN device manager 2.x is not available
If Not VSTwain1.DeviceManager_IsAvailable Then
' try to use TWAIN device manager 1.x
VSTwain1.DeviceManager_IsTwain2Compatible = Not twain2CheckBox.Value
' if TWAIN device manager 1.x is not available
If Not VSTwain1.DeviceManager_IsAvailable Then
MsgBox "TWAIN device manager is not available."
' enable application UI
scanImagesButton.Enabled = True
Exit Sub
End If
End If
VSTwain1.Register "User", "Email", "Serial"
' open the device manager
If Not VSTwain1.DeviceManager_Open() Then
MsgBox VSTwain1.errorString
' enable application UI
scanImagesButton.Enabled = True
Exit Sub
End If
' if no devices are found in the system
If VSTwain1.DeviceManager_DeviceCount = 0 Then
MsgBox "Devices are not found."
' enable application UI
scanImagesButton.Enabled = True
Exit Sub
End If
' if device is NOT selected
If Not VSTwain1.DeviceManager_ShowDefaultDeviceSelectionDialog() Then
MsgBox "Device is not selected."
' enable application UI
scanImagesButton.Enabled = True
Exit Sub
End If
' select the device selected by user
VSTwain1.DeviceManager_SelectedDeviceIndex = VSTwain1.DeviceManager_DefaultDeviceIndex
If VSTwain1.Error Then
MsgBox VSTwain1.errorString
' enable application UI
scanImagesButton.Enabled = True
Exit Sub
End If
' open the device
VSTwain1.Device_Open
If VSTwain1.Error Then
MsgBox VSTwain1.errorString
' enable application UI
scanImagesButton.Enabled = True
Exit Sub
End If
VSTwain1.Device_GetSupportedUnitsOfMeasure
VSTwain1.Device_PageSize = 0
' set scan settings
VSTwain1.Device_ShowUI = False ' showUiCheckBox.Value
VSTwain1.Device_ShowIndicators = showIndicatorsCheckBox.Value
VSTwain1.Device_DisableAfterAcquire = Not VSTwain1.Device_ShowUI
VSTwain1.Device_TransferMode = TRANSFERMODE_Memory
' Scanbereich auslesen
Dim nLeft As Single, nTop As Single, nRight As Single, nBottom As Single
VSTwain1.Device_GetImageLayout nLeft, nTop, nRight, nBottom
nLeft = 0
nTop = 0
nRight = 210
nBottom = 297
' Scanbereich festlegen
VSTwain1.Device_SetImageLayout nLeft, nTop, nRight, nBottom
VSTwain1.Device_ImagePixelType = PIXELTYPE_Gray
VSTwain1.Device_ImageBitDepth = 16
' acquire image(s) from the device
Dim acquireModalState1 As ACQUIREMODALSTATE
Do
acquireModalState1 = VSTwain1.Device_AcquireImageModal
Select Case acquireModalState1
Case VSTwainLibCtl.ACQUIREMODALSTATE_ImageAcquired
' set a bitmap in the picture box
Set Image1.Picture = VSTwain1.AcquiredImages_GetImage(0)
imageCount = imageCount + 1
totalImageCount = totalImageCount + 1
' dispose an acquired image
VSTwain1.AcquiredImages_Clear
Case VSTwainLibCtl.ACQUIREMODALSTATE_ScanCanceled
MsgBox "Scan is canceled."
Case VSTwainLibCtl.ACQUIREMODALSTATE_ScanFailed
MsgBox "Scan is failed: " + VSTwain1.errorString
End Select
Loop While acquireModalState1 <> VSTwainLibCtl.ACQUIREMODALSTATE_None
' close the device
VSTwain1.Device_Close
' close the device manager
VSTwain1.DeviceManager_Close
' enable application UI
scanImagesButton.Enabled = True
The help is unfortunately not very helpful either, as it is written for .Net only and some functions (e.g. AddHandler) do not work in VB6.