DTWAIN_SelectSource2

Top  Previous  Next

The DTWAIN_SelectSource2 function allows the user to select the TWAIN Source and position the TWAIN Select Source dialog.

 

DTWAIN_SOURCE  DTWAIN_SelectSource2 (        

HWND

hWndParent,

LPCTSTR

szTitle,

LONG

xpos,

LONG

ypos,

LONG

flags );

 

Parameters

hWndParent

Points to the window that will be the parent of the Twain Select Source dialog, or NULL if no parent window.

 

szTitle

Optional title, or NULL.

 

xpos, ypos

Position of the Select Source dialog with respect to the parent window.

 

flags

Optional window placement flags.

 

 

Return Values

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

 

Character specific version

ANSI version:

DTWAIN_SelectSource2A

Unicode version:

DTWAIN_SelectSource2W

 

Comments

The DTWAIN_SelectSource2 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_SelectSource2 returns NULL.  The DTWAIN_SOURCE return value is used for any other DTWAIN function that requires a Source handle.

 

The difference between DTWAIN_SelectSource2 and DTWAIN_SelectSource is that DTWAIN_SelectSource2 allows the application to position the Select Source dialog on the screen and place a title on the window.  The hWndParent sets the dialog's parent window to hWndParent.  If no parent window is desired, hWndParent must be NULL or 0.  If hWndParent is NULL, the parent window is the entire screen.

 

Another difference is that DTWAIN_SelectSource2 will allow the various controls within the dialog to use a custom language setting.  Depending on the resources loaded (see DTWAIN_LoadLanguageResource and DTWAIN_LoadCustomStringResource), the various controls and buttons will display the text in the language selected.

 

The xpos and ypos arguments place the window at position (xpos, pos) with respect to the parent window (if no parent window, xpos and ypos are relative to the entire screen).

 

The szTitle argument is a null-terminated string that represents the title to display on the window.  If szTitle is NULL, the title is "Select Source".

 

The flags parameter determine whether the dialog will be centered and whether the list of Source names displayed will be sorted.  A list of available flag options are as follows (multiple options can be selected by adding the values together).

 

DTWAIN_DLG_CENTER

 

Centers the Select Source dialog on the parent window hWndParent.  The xpos and ypos arguments are ignored.

 

DTWAIN_DLG_SORTNAMES

Sorts and displays the Source names in the dialog.  Normally, the names are displayed in order of their time of installation.

 

DTWAIN_DLG_HORIZONTALSCROLL

Add horizontal scroll bar to list box that displays the Source Names.  Use this option if the Source Name(s) will not fit horizontally within the list box.

 

As an example, to place the Twain dialog on the center of the screen, the following would be used:

DTWAIN_SelectSource2( NULL,NULL 0, 0, DTWAIN_DLG_CENTER );

 

To place the dialog at (20,20) of a particular window, the following would be used:

DTWAIN_SelectSource2( hWnd, NULL, 20, 20, 0 );

 

To center the dialog on the screen, have the title "My Twain Dialog", and have sorted Source names:

DTWAIN_SelectSource2( NULL, "My Twain Dialog", 0, 0,  DTWAIN_DLG_SORTNAMES + DTWAIN_DLG_CENTER );

 

If more customization is desired beyond what 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 from your interface, 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 change the language used for the various buttons and text, a call to DTWAIN_LoadLanguageResource can be used, or a call to DTWAIN_LoadCustomStringResource can be used.  If DTWAIN_LoadCustomStringResource is used, the following DTWAIN constants define the various components of the dialog:

 

Resource Name

Description

IDS_SELECT_SOURCE_TEXT

Dialog Title

IDS_SELECT_TEXT

"Select" button text

IDS_CANCEL_TEXT

"Cancel" button text

IDS_SOURCES_TEXT

Text above the Sources list box.



                 

 

TWAIN State Transitions

Remains in State 3.

 

Prerequisite Calls

DTWAIN_SysInitialize

 

Optional Prerequisite Calls

None.

 

See Also

Source Selection Functions