Problem with Brother Scanners and Multiform application

Discussions about TWAIN & WIA scanning in GdPicture.NET using GdPictureImaging.
Post Reply
IPLD
Posts: 3
Joined: Thu Jun 16, 2011 2:34 pm

Problem with Brother Scanners and Multiform application

Post by IPLD » Thu Jun 16, 2011 2:59 pm

We have a big application in VB6 with Main form and childs forms. We have exactly the same code in our application than in your demo sample to select source, and get image with Twain.TwainAcquireToGdPictureImage(Me.hwnd). We use SDK V2.8.0.

Code: Select all

Private Sub Command2_Click()
 
 Dim nImageID As Long

   If Twain1.TwainOpenDefaultSource() Then
      InitScanConfig
      
      Twain1.TwainSetCurrentResolution (300)
      Twain1.TwainSetCurrentPixelType (TWPT_RGB) 'RGB
      Twain1.TwainSetCurrentBitDepth (8) ' 24 bpp
      
      nImageID = Twain1.TwainAcquireToGdPictureImage(Me.hwnd)
      If nImageID <> 0 Then
        If ChkRotat.Value = 1 Then Call Twain1.Rotate(Rotate90FlipNone)
        If ChkBord.Value = 1 Then Call Twain1.CropBorders
         Call DisplayNativeImage
         Call Twain1.CloseImage(nImageID)
      End If
      
      Call Twain1.TwainCloseSource
      If nImageID <> 0 Then MsgBox LoadResString(1060)
   Else
      MsgBox LoadResString(2400)
   End If

End Sub

Private Sub InitScanConfig()
 Twain1.TwainSetHideUI (ChkUI.Value)
 Twain1.TwainSetIndicators (False)
 If ChkAutoLum.Value = 1 Then
    Twain1.TwainSetAutoBrightness (True)
 Else
    Twain1.TwainSetAutoBrightness (False)
    Twain1.TwainSetCurrentBrightness (Slider1.Value)
 End If
 Twain1.TwainSetCurrentContrast (Slider2.Value)
 Twain1.TwainEnableDuplex (False)
End Sub

Private Sub DisplayNativeImage()
 Dim nViewRatio  As Double
  Picture1.Cls

  nViewRatio = Picture1.ScaleHeight / Twain1.GetHeight

  Call Twain1.DisplayImageOnHDC(Picture1.hdc, 1, 1, Twain1.GetWidth * nViewRatio, Twain1.GetHeight * nViewRatio, SmoothingModeAntiAlias)
  Picture1.Refresh
  DoEvents
End Sub
When we use our application with Canon, Plustek, HP, etc scanners, she work correctly. When we use it with different Brother Scanners (MFC 9840CDW or MFC 5460CN) the "Twain.TwainAcquireToGdPictureImage(Me.hwnd)" instruction send an "pile stack error" and the application stop. But with the same Brother scanner and pilot and with the sample demo of gdPicture, the application work correctly with these scanners.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Problem with Brother Scanners and Multiform application

Post by Loïc » Thu Jun 16, 2011 6:57 pm

Please follow these instruction to send us the good materials to investigate the problem: viewtopic.php?t=1486

IPLD
Posts: 3
Joined: Thu Jun 16, 2011 2:34 pm

Re: Problem with Brother Scanners and Multiform application

Post by IPLD » Tue Jun 21, 2011 8:23 am

We have follow all your preconisations.
- We use GDTwain V2.08.009
- Device reference : Brother MFC 9840CDW V1.0.2.0 date : 26/01/2007 (latest version)
- Windows XP Pro 2002 (SP3)
- We join twainlog.txt

Code: Select all


#GdTwain Log Start. Version: 645

RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
GetValidHwnd: Creating Proxy window.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
Start: OpenSourceManager.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
DSM library loaded: C:\WINDOWS\TWAIN_32.DLL
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
Entry point of the DSM found.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 1
-------------------
End: OpenSourceManager.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
Start: OpenDefaultSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 3
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
Start: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
End: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
End: OpenDefaultSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_FAILURE CC: TWCC_CAPUNSUPPORTED // TWmsg: 57c
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
Start: Set Duplex False.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
End Set Duplex.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
Start: AcquireNative.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
Source: TW-Brother MFC-9840CDW
Manufacturer: Brother Industries, Ltd.
-------------------
AcquireNative: Retrieving current device configuration - Start.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
AcquireNative: Retrieving current device configuration - End.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
Start: WaitForXfer.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_GETCURRENT ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
Start: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
::DS operation. DG: DG_CONTROL - DAT: DAT_CAPABILITY - MSG: MSG_SET ->RC: TWRC_SUCCESS // TWmsg: 57c
-------------------
End: SetXferMech.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
Start: EnableSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
-------------------
Start: CloseSource.
RC:   TWRC_SUCCESS
CC:   TWCC_SUCCESS
State: 4
Source: TW-Brother MFC-9840CDW
Manufacturer: Brother Industries, Ltd.
-------------------

IPLD
Posts: 3
Joined: Thu Jun 16, 2011 2:34 pm

Re: Problem with Brother Scanners and Multiform application

Post by IPLD » Wed Jun 22, 2011 8:32 am

With the instruction "Twain.TwainAcquireToGdPictureImage()" - instead of TwainAcquireToGdPictureImage(Me.hwnd) - we don't have the message "pile stack error" but the scan don't work and we have no response from application.

User avatar
Loïc
Site Admin
Posts: 5881
Joined: Tue Oct 17, 2006 10:48 pm
Location: France
Contact:

Re: Problem with Brother Scanners and Multiform application

Post by Loïc » Sat Jun 25, 2011 12:48 pm

Hi,

Unfortunately I can't do anything. The driver simply crash the application on the close command. I think the driver of your scanner is not suitable for your multiform applications. You scanner driver seems to be to old.

What I can suggest is to use "normal" form than handle the twain process.

Kind regards,

Loïc

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest