CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Threaded View

  1. #1
    Join Date
    Feb 2010
    Posts
    7

    Scanning with TWAIN

    Hello

    I am making an application to scan with TWAIN. I can get to state 4 OK, and scan with the UI. But I need to hide the UI. When I do this the scanner does nothing. I believe it needs some capabilities set (like height and width). So I try to get the physical height and width so I can set them. Herein lies the problem. I get 18874402 back for the physical height and width. (neither can I get the units). I get RC=SUCCESS. I don't think it could be a signed/unsigned issue because what boundary is at 18 million +/- with whatever units? I tried some other code I found but that returns 0. I can't figure out what I am doing wrong. Here's the code:

    Code:
        Private Function GetOneValue(ByVal twCapability As twsCapability) As String
    
            Dim rc As twRC
            Dim strTemp As String
            Dim twOneValue As TW_ONEVALUE
    
    
            rc = DS_Capability(mtwApp, mtwSource, twDG.Control, twDAT.Capability, twMSG.Get, twCapability)
            If rc = twRC.Success Then
                strTemp = vbNullString
                Select Case twCapability.ConType
                    Case twContainerTyoe.One
                        twOneValue = New TW_ONEVALUE
                        Marshal.PtrToStructure(twCapability.Handle, twOneValue)
                        strTemp = CType(twOneValue.Item, String)
                    Case Else
                        MsgBox("Error, one value expected; " & twCapability.ConType & " returned.")
                End Select
                Marshal.FreeHGlobal(twCapability.Handle)
                Return strTemp
            Else
                ErrorStatus()
                Return vbNullString
            End If
    
        End Function
    And here's how I call it:

    Code:
                twCapability = New twsCapability
                With twCapability
                    .Cap = twCap.IPhysicalWidth
                    .ConType = twContainerTyoe.One   'TWON_DONTCARE16
                    '.Handle = Nothing
                End With
                strWidth = GetOneValue(twCapability)
    If I can get it to work I will post the class here for others to use. Any help is appreciated, thanks for looking.
    Last edited by HanneSThEGreaT; February 19th, 2010 at 02:25 AM. Reason: [CODE tags!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured