Home › Forums › TWAIN Classic › Gurus HELP please with SelectSource()
- This topic has 1 reply, 1 voice, and was last updated 15 years, 7 months ago by nobutaka.
Viewing 2 posts - 1 through 2 (of 2 total)
- AuthorPosts
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
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;
}- AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)