SelectSource Method

Summary
Displays the TWAIN dialog box to be used to select a TWAIN source for acquiring images.
Syntax
C#
VB
C++
public DialogResult SelectSource( 
   string sourceName 
) 
Public Function SelectSource( _ 
   ByVal sourceName As String _ 
) As DialogResult 
public: 
DialogResult SelectSource(  
   String^ sourceName 
)  

Parameters

sourceName
String contains source name to be selected

Return Value

One of the DialogResult values. If an error occurs, an exception is thrown.

Remarks

This method checks if the currently selected twain data source is TWAIN 2.x compliant or not, if not then it will load TWAIN 1.x data source manager (Twain_32.DLL) from your system and in this case the used twain version will be TwainVersion1, but if the selected data source is TWAIN 2.x compliant then TWAIN 2.x data source manager (TWAINDSM.DLL) will be loaded from your system and this case the used twain version will be TwainVersion2. This checking will be done ONLY if the SetVersion method was NOT called by the user. You can get the currently selected Twain version by calling GetVersion method. TWAIN 2.x data source manager (TWAINDSM.DLL) is always preferable if the selected data source is TWAIN 2.x compliant, so if for example you have two TWAIN drivers installed on your machine, one of them is TWAIN 2.x compliant while the other is not and you where using the TWAIN 1.x data source (driver) then you called this method and selected the other TWAIN 2.x compliant data source (driver) then LEADTOOLS will internally try to load TWAINDSM.DLL instead of Twain_32.dll in order to use TWAIN 2.x data source manager since your newly selected device is TWAIN 2.x compliant and here you might notice that the data sources listed inside the manufacturer's select source dialog are different depending on the selected TWAIN version. For more information, refer to Managing the TWAIN Source.

Example
C#
VB
using Leadtools; 
using Leadtools.Twain; 
 
public void SelectSourceExample(IntPtr parent) 
{ 
   TwainSession session = new TwainSession(); 
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
 
   if (session.SelectSource(string.Empty) != DialogResult.OK) 
      MessageBox.Show("Error Selecting Source"); 
 
   session.Shutdown(); 
} 
Imports Leadtools 
Imports Leadtools.Twain 
 
Public Sub SelectSourceExample(ByVal parent As IntPtr) 
   Dim session As TwainSession = New TwainSession() 
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None) 
 
   If session.SelectSource(String.Empty) <> DialogResult.OK Then 
      MessageBox.Show("Error Selecting Source") 
   End If 
 
   session.Shutdown() 
End Sub 
Requirements

Target Platforms

Help Version 21.0.2021.6.30
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Twain Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.