This project has moved. For the latest updates, please go here.

_twain_AcquireCompleted not firing

Mar 4, 2014 at 11:43 PM
Hi,

Am new to Sarafftwain. I using the Sarafftwain dll in vb.net sample form. _twain_AcquireCompleted is not firing after the image is scanned. Kindly guide me on this. Below is the code of the form :


Imports System.Collections.Generic
Imports System.ComponentModel
Imports System.Data
Imports System.Drawing
Imports System.Text
Imports System.Windows.Forms
Imports Saraff.Twain
Partial Public Class Form1
    Inherits Form
    Private _isEnable As Boolean = False
Private _twain As New Saraff.Twain.Twain32


Private Sub button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
    Me._twain.CloseDataSource()
    Me._twain.SelectSource()
End Sub

Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
    Try
        Me._twain.Acquire()
    Catch ex As TwainException
        MessageBox.Show(ex.Message, "SAMPLE1", MessageBoxButtons.OK, MessageBoxIcon.[Error])
    End Try
End Sub

Private Sub _twain_AcquireCompleted(ByVal sender As Object, ByVal e As EventArgs) Handles _twain.AcquireCompleted
    If Me.PictureBox1.Image IsNot Nothing Then
        Me.PictureBox1.Image.Dispose()
    End If
    Me.PictureBox1.Image = Me._twain.GetImage(0)
End Sub

Private Sub _twain_TwainStateChanged(ByVal sender As Object, ByVal e As Twain32.TwainStateEventArgs) Handles _twain.AcquireCompleted
    If (e.TwainState And Twain32.TwainStateFlag.DSEnabled) = 0 AndAlso Me._isEnable Then
        ' <<< scaning finished (or closed)
        Me._isEnable = False
    End If
    Me._isEnable = (e.TwainState And Twain32.TwainStateFlag.DSEnabled) <> 0
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Me._twain.OpenDSM()
End Sub
End Class
Coordinator
Mar 5, 2014 at 1:07 PM
Hello, KingVBNet.
See Saraff.Twain.Sample1.
Coordinator
Mar 18, 2014 at 11:36 AM
Hello.
Sample vb.net code can be downloaded here Saraff.Twain.NET Vb.net Samples
Marked as answer by SARAFF on 6/23/2014 at 12:36 PM