TWAIN Working Group

Newsletter Signup
Donate
Help keep TWAIN free
  • About TWAIN
    • What’s New?
    • News
    • Events
    • Membership
    • Consider a Donation
    • Contact Us
  • Why TWAIN?
  • Developers
    • Driver Developer
    • Application Developer
    • TWAIN Features
    • Specification & Tools
    • Self Certification Process
  • Support Forums
  • Scanner End-User
  • Find Certified Drivers
    • Facebook
    • LinkedIn
    • Vimeo

Gurus HELP please with SelectSource()

Forums › TWAIN Classic › Gurus HELP please with SelectSource()

  • This topic has 1 reply, 1 voice, and was last updated 12 years, 5 months ago by nobutaka.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • August 11, 2008 at 11:58 am #22378 Reply
    nobutaka
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    Hello:

    I am trying to make an automated image acquisition, selecting one of many Twain drivers available. Let’s say I will search for the ‘FUJITSU’ string.

    I’ve configured ‘ShowUI = FALSE’

    I’ve modified this function.

    BOOL CTwain::SelectSource()
    {
    memset(&m_Source,0,sizeof(m_Source));
    if(!SourceSelected())
    {
    SelectDefaultSource();
    }
    if(CallTwainProc(&m_AppId,NULL,DG_CONTROL,DAT_IDENTITY,MSG_USERSELECT,&m_Source))
    {
    m_bSourceSelected = TRUE;
    }
    return m_bSourceSelected;
    }

    To this

    BOOL CTwain::SelectSource2()
    {
    // add your header file /////////////////////////////////////////
    TW_IDENTITY m_SourceList[256];
    UINT m_nSources;
    /////////////////////////////////////////////////////////////////


    memset(m_SourceList, 0, 256 * sizeof(TW_IDENTITY));
    m_nSources = 0;

    if (CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, m_SourceList))
    {
    m_nSources++;
    for (int i = 1 ; i < 256 ; i++)
    {
    char * pch;
    char * modeloScanner = "FUJITSU";

    pch = strtok(m_SourceList[i-1].ProductName,modeloScanner );



    if (pch != NULL )
    {
    OpenSource(&m_SourceList[i-1]);
    return TRUE;
    }

    if (CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, &m_SourceList))
    {
    m_nSources++;
    }
    if (m_returnCode == TWRC_ENDOFLIST)
    {
    return TRUE;
    }
    }
    }
    else
    {
    return FALSE;
    }
    return TRUE;
    }

    Problem is that even though I get out from SelectSource() when I reach the desired DS, it keeps doing the scan through another scanner.

    Anyone can help me?

    Thanks in advance

    August 11, 2008 at 12:19 pm #24609 Reply
    nobutaka
    Participant
    • Topics - 1
    • Replies - 1
    • Total Posts - 2

    I found my error.

    Post the fixed code for future references.

    BOOL CTwain::SelectSource2()
    {
    memset(&m_Source,0,sizeof(m_Source));
    // add your header file /////////////////////////////////////////
    TW_IDENTITY m_SourceList[256];
    UINT m_nSources;
    /////////////////////////////////////////////////////////////////


    memset(m_SourceList, 0, 256 * sizeof(TW_IDENTITY));
    m_nSources = 0;

    if (CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETFIRST, m_SourceList))
    {

    m_nSources++;
    for (int i = 1 ; i < 256 ; i++)
    {
    char * pch;
    char * modeloScanner = "FUJITSU";

    pch = strtok(m_SourceList[i-1].ProductName,modeloScanner );



    if (pch != NULL )
    {
    m_Source = m_SourceList[i-1];
    m_bSourceSelected = TRUE;
    return TRUE;
    }

    if (CallTwainProc(&m_AppId, NULL, DG_CONTROL, DAT_IDENTITY, MSG_GETNEXT, &m_SourceList))
    {
    m_nSources++;
    }
    if (m_returnCode == TWRC_ENDOFLIST)
    {
    return TRUE;
    }
    }
    }
    else
    {
    return FALSE;
    }
    return TRUE;
    }
  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: Gurus HELP please with SelectSource()
Your information:




Quick Links

Service Providers
TWAIN Support Forums
Membership
Contact Us
Privacy Policy

Newsletter Signup

TWAIN Working Group Family

TWAIN Working Group
TWAIN Direct®
TWAIN Resources
TWAIN Certified Drivers
PDF/raster

  • Facebook
  • GitHub
  • LinkedIn
  • Vimeo

Recent Topics

  • EPSON V600 TWAIN and WIA on Windows 10
  • When and how to use WaitForEvents command ?
  • Problem enumerating list of installed scanners in windows server 2012
  • Failed to create TWAIN progress! Error code is 1260.
  • To get the list of scanners from javascript client side (browser)
  • Quarterly Newsletter
  • TWAIN Working Group Membership
  • Logo Usage
  • TWAIN License
  • Contact Us
Privacy Policy • Privacy Tools • Copyright © 2021 TWAIN Working Group • by iHwy, LLC • Log in

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.