Loading...

When cancel a scan application freeze

Support for GdTwain ActiveX and GdTwain Pro ActiveX/SDK.

When cancel a scan application freeze

Postby werner » Fri Sep 28, 2007 5:54 pm

hi i have a trouble when i cancel my scaning in my app and press again the scan button the application freeze and i dont know why? please i need to fix this.

this is my code

Code: Select all
 Private Sub FrmMantenimientoDTU_Load(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.InfoTab.SelectedTabPageIndex = 0
        Axtwain1.SetLicenseNumber("XXXXXX")
    End Sub

 Private Sub ScanImage(ByVal ScanMode As String)

        Dim nImageID As Integer
        Dim ImageName As String = ""
        Try
            If Axtwain1.TwainOpenDefaultSource() Then

                'Configura el Escaner
                Axtwain1.TwainSetHideUI(True)
                Axtwain1.TwainSetIndicators(True)
                Axtwain1.TwainSetAutoBrightness(True)
                Axtwain1.TwainSetCurrentContrast(0)
                Axtwain1.TwainEnableDuplex(False)

                'Configura la imagen
                Axtwain1.TwainSetCurrentResolution(150)
                Axtwain1.TwainSetCurrentPixelType(Gdtwain.TwainPixelType.TWPT_BW) 'RGB
                Axtwain1.TwainSetCurrentBitDepth(8) ' 24 bpp

                nImageID = Axtwain1.TwainAcquireToImageID(Me.Handle.ToInt32)
                If nImageID <> 0 Then
                    If System.IO.Directory.Exists(Funciones.App_Path & "Documents\DUT" & Me.TxtCorrelativo.Text) = False Then
                        System.IO.Directory.CreateDirectory(Funciones.App_Path & "Documents\DUT" & Me.TxtCorrelativo.Text)
                    End If
                    If ScanMode = "Agregar" Then
                        If Me.TreeDocs.FocusedNode.GetValue("ParentID").ToString.Trim = "-1" Then
                            ImageName = Replace(Funciones.App_Path & "\Documents\DUT" & Me.TxtCorrelativo.Text & "\" & Me.TreeDocs.FocusedNode.GetValue("CodigoDocumento").ToString.Trim & (Me.TreeDocs.FocusedNode.Nodes.Count + 1).ToString & ".gif", "\\", "\")
                        Else
                            ImageName = Replace(Funciones.App_Path & "\Documents\DUT" & Me.TxtCorrelativo.Text & "\" & Me.TreeDocs.FocusedNode.ParentNode.GetValue("CodigoDocumento").ToString.Trim & (Me.TreeDocs.FocusedNode.ParentNode.Nodes.Count + 1).ToString & ".gif", "\\", "\")
                        End If
                    Else
                        ImageName = Me.TreeDocs.FocusedNode.GetValue("Path").ToString.Trim
                        Me.Imagen.Image.Dispose()
                        Me.Imagen.Image = Nothing
                    End If
                    Call Axtwain1.SaveAsGif(ImageName)
                    Call Axtwain1.CloseImage(nImageID)
                    Me.Imagen.ImageLocation = ImageName
                    Me.Imagen.Show()
                    AgregarDoc(ImageName, ScanMode)
                    Me.TreeDocs.FocusedNode.SetValue("Path", ImageName)
                End If
                Axtwain1.TwainCloseSourceManager(Me.Handle.ToInt32)
            End If
        Catch ex As Exception
            FrmMessageBox.Mostrar(ex.Message, TituloError)
        End Try
    End Sub
werner
 
Posts: 10
Joined: Thu Sep 27, 2007 12:05 am

Postby Loïc » Fri Sep 28, 2007 7:07 pm

Hi,

What is the scanner model you are using ?

Are you using the last GdTwain 1.6 release ?


When you say
i cancel my scaning in my app and press again the scan button


How you cancel the scan ? By the scanner driver interface ? And what you mean by the the scan button ? the button into your application or a physical button above your scanner ?

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby werner » Fri Sep 28, 2007 8:35 pm

-Scanner HP OfficeJet 7400 series
-I user GDTwain 1.6
-I cancel the scanning by the scanner driver interface
werner
 
Posts: 10
Joined: Thu Sep 27, 2007 12:05 am

Postby Loïc » Fri Sep 28, 2007 10:01 pm

Hi,

Are you sure you are using the Twain Driver of the scanner and not the WIA driver ?


To see when the scan fail, could you write in your code before this line :

Code: Select all
nImageID = Axtwain1.TwainAcquireToImageID(Me.Handle.ToInt32)

This one:

Code: Select all
twain1.TwainSetDebugMode (True)



Now tell me which are the displayed messages by the component and precise me when you stop and start again the scan.

Regards,

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby werner » Fri Sep 28, 2007 10:17 pm

show a messagebox with this messages.

-Source already Opened
-Attempt to set capability without opened source (shows this error 3 times)
- before check hwnd
- after check hwnd
- wait for nativeXfer
- wait for Xfer
- Disable parent window in WFXF (show this error 2 times)

after this the app freeze.
werner
 
Posts: 10
Joined: Thu Sep 27, 2007 12:05 am

Postby Loïc » Fri Sep 28, 2007 11:53 pm

Werner, I need all the displayed messages (before you cancel & after) and I need to know exactly when they are displayed. Presise me too when you stop and restart the scan process between the displayed messages.

Please use this code:


Code: Select all
Private Sub ScanImage(ByVal ScanMode As String)

        Dim nImageID As Integer
        Dim ImageName As String = ""
        Try
       Axtwain1.TwainSetDebugMode (True)
msgbox 1         
If Axtwain1.TwainOpenDefaultSource() Then
msgbox 2
                'Configura el Escaner
                Axtwain1.TwainSetHideUI(True)
msgbox 3             
  Axtwain1.TwainSetIndicators(True)
msgbox 4
                Axtwain1.TwainSetAutoBrightness(True)
msgbox 5             
   Axtwain1.TwainSetCurrentContrast(0)
msgbox 6   
             Axtwain1.TwainEnableDuplex(False)
msgbox 7
                'Configura la imagen
                Axtwain1.TwainSetCurrentResolution(150)
msgbox 8                Axtwain1.TwainSetCurrentPixelType(Gdtwain.TwainPixelType.TWPT_BW) 'RGB
msgbox 9
                Axtwain1.TwainSetCurrentBitDepth(8) ' 24 bpp
msgbox 10
                nImageID = Axtwain1.TwainAcquireToImageID(Me.Handle.ToInt32)
msgbox 11               
If nImageID <> 0 Then
                    If System.IO.Directory.Exists(Funciones.App_Path & "Documents\DUT" & Me.TxtCorrelativo.Text) = False Then
                        System.IO.Directory.CreateDirectory(Funciones.App_Path & "Documents\DUT" & Me.TxtCorrelativo.Text)
                    End If
                    If ScanMode = "Agregar" Then
                        If Me.TreeDocs.FocusedNode.GetValue("ParentID").ToString.Trim = "-1" Then
                            ImageName = Replace(Funciones.App_Path & "\Documents\DUT" & Me.TxtCorrelativo.Text & "\" & Me.TreeDocs.FocusedNode.GetValue("CodigoDocumento").ToString.Trim & (Me.TreeDocs.FocusedNode.Nodes.Count + 1).ToString & ".gif", "\\", "\")
                        Else
                            ImageName = Replace(Funciones.App_Path & "\Documents\DUT" & Me.TxtCorrelativo.Text & "\" & Me.TreeDocs.FocusedNode.ParentNode.GetValue("CodigoDocumento").ToString.Trim & (Me.TreeDocs.FocusedNode.ParentNode.Nodes.Count + 1).ToString & ".gif", "\\", "\")
                        End If
                    Else
                        ImageName = Me.TreeDocs.FocusedNode.GetValue("Path").ToString.Trim
                        Me.Imagen.Image.Dispose()
                        Me.Imagen.Image = Nothing
                    End If
                    Call Axtwain1.SaveAsGif(ImageName)
                    Call Axtwain1.CloseImage(nImageID)
                    Me.Imagen.ImageLocation = ImageName
                    Me.Imagen.Show()
                    AgregarDoc(ImageName, ScanMode)
                    Me.TreeDocs.FocusedNode.SetValue("Path", ImageName)
                End If
                Axtwain1.TwainCloseSourceManager(Me.Handle.ToInt32)
            End If
        Catch ex As Exception
            FrmMessageBox.Mostrar(ex.Message, TituloError)
        End Try
    End Sub
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby werner » Sat Sep 29, 2007 12:21 am

when I press the fist time the scanner button

-before: check hwnd
-after: check hwnd
-before: wait for nativeXfer
-before: Set XferMech
-after: set XferMech
-before: Wait for Xfer
-before: Disable parent window in WFXF
-after: Disable parent window in WFXF
-before: Do One Transfer

when i press cancel button

-after: Do One Transfer
-after: Modal event Loop in WFXF
-before: re-enable parent window in WFXF
-after: re-enable parent window in WFXF
-after: wait for Xfer
-after: wait for nativeXfer
-Xfer: fail
-before: Abord all Xfer (1)
-after: Abord all Xfer (1)

when I press again the scanner button

-source already opened
-attemp to set capability without opened source
-attemp to set capability without opened source
-attemp to set capability without opened source
-attemp to set capability without opened source
-attemp to set capability without opened source
-attemp to set capability without opened source
-attemp to set capability without opened source
-before: check hwnd
-after: check hwnd
-before: wait for nativeXfer
-before: wait for Xfer
-before: disable parent window in WFXF
-after: disable parent window in WFXF

this is all events and then the app freeze.
werner
 
Posts: 10
Joined: Thu Sep 27, 2007 12:05 am

Postby Loïc » Sat Sep 29, 2007 1:51 pm

Ok thanks,

Now please update the c:\windows\system32\gdtwain.dll library with the last edition which can be downloaded from this link: http://www.gdpicture.com/ressources/ocx/gdtwain.dll

Download too this vb.net sample: http://www.gdpicture.com/noindex/werner.zip and run it.

Write me all the message box you can see and like into your previous post, presise me too when you stop and restart the scan process between the displayed messages.

Best regards,

Loïc Carrère
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby werner » Sat Sep 29, 2007 6:51 pm

first time I press the button

-start debug
-used source: HP officejet 7400 Twain , Twain State: 3
-step 1, Twain State: 4
-step 2
-step 3
-step 4
-step 5
-step 6
-step 7
-step 8
-step 9
-before: check hwnd
-after: check hwnd
-before: wait for nativeXfer
-before: set XferMech
-after: set XferMech
-before: wait for Xfer
-before: disable parent window in WFXF
-after: disable parent window in WFXF
-before: Do one transfer

when I press the cacel button

-Transfer cancelled by user
-after: Do one transfer
-before: Modal event loop in WFXF
-before: re-enable parent window WFXF
-after: re-enable parent window WFXF
-before: wait for xfer
-after: wait for xfer
-xfer: fail
-step 10 , nImageID: 0 Twain State: 3 GDTwain State: 33
-step 11, Twain state: 2

I press again the button

-start debug
-used source: HP officejet 7400 Twain , Twain State: 3
-step 1, Twain State: 4
-step 2
-step 3
-step 4
-step 5
-step 6
-step 7
-step 8
-step 9
-before: check hwnd
-after: check hwnd
-before: wait for nativeXfer
-before: set XferMech
-after: set XferMech
-before: wait for Xfer
-before: disable parent window in WFXF
-after: disable parent window in WFXF
-before: Do one transfer


thats all
werner
 
Posts: 10
Joined: Thu Sep 27, 2007 12:05 am

Postby Loïc » Sat Sep 29, 2007 7:08 pm

Ok.

Now if you replace the line
Code: Select all
Axtwain1.TwainSetDebugMode (True)

by
Code: Select all
Axtwain1.TwainSetDebugMode (False)


Is the code is working ?

Loïc
Loïc Carrère, support team.
www.orpalis.com
User avatar
Loïc
Site Admin
 
Posts: 4441
Joined: Tue Oct 17, 2006 10:48 pm
Location: France

Postby werner » Sat Sep 29, 2007 8:09 pm

yes now the app not freeze thanks for you help. Maybe you can help me with another post I put a few days ago.
werner
 
Posts: 10
Joined: Thu Sep 27, 2007 12:05 am


Return to GdTwain [Pro] ActiveX

Who is online

Users browsing this forum: No registered users and 1 guest