DTWAIN_SelectSource

Top  Previous  Next

The DTWAIN_SelectSource function allows the user to select the TWAIN Source.

 

DTWAIN_SOURCE  DTWAIN_SelectSource( );

 

Parameters

None.

 

Return Values

If successful, the return value is a non-zero DTWAIN_SOURCE handle to the selected Source.  Otherwise NULL is returned.

 

Comments

The DTWAIN_SelectSource function displays the TWAIN 'Select Source' dialog box and returns a handle to the Source that is selected by the user.   If the user chooses 'Cancel' from the dialog, DTWAIN_SelectSource returns NULL.  If there is an error in opening the Source (by default, the Source will be attempted to be opened as well as selected -- please see DTWAIN_OpenSourceOnSelect for more information), the return value is NULL.

 

To determine if a NULL return value from DTWAIN_SelectSource is due to the user cancelling the dialog or if there is another error, call DTWAIN_GetLastError and check if the value is non-zero (which means an error occurred).  If DTWAIN_GetLastError returned 0, this means that the user canceled the dialog, which is perfectly valid for the user to do.

 

The DTWAIN_SOURCE return value is used for any other DTWAIN function that requires a Source handle.

 

To position the TWAIN dialog and customize the title, use DTWAIN_SelectSource2.  If more customization is desired beyond what DTWAIN_SelectSource and DTWAIN_SelectSource2 provides, call DTWAIN_EnumSources, get all of the product names, and then present all of the product names found in your own custom interface to the user.  When the user chooses one of the Sources, your application would call DTWAIN_SelectSourceByName to actually select the Source.  See the DTWAIN demo program DTWDEMO.EXE for a code sample of how to accomplish this.

 

To select the default Source, use DTWAIN_SelectDefaultSource.

 

 

TWAIN State Transitions

Remains in State 3.

 

Prerequisite Calls

DTWAIN_SysInitialize

 

Optional Prerequisite Calls

None.

 

See Also

Source Selection Functions