Source User Interface

Top  Previous  Next

When the application desires to acquire images from the image device, the Source's user interface (UI) is usually shown.  Some UI's can be very simple, while others may have a myriad of controls, buttons, preview scanning areas, etc.  The UI is usually displayed during TWAIN State 5.

 

When the Source displays the UI, the UI is usually implemented as a modal or modeless dialog box, or a multiple set of modal / modeless dialogs.

 

Source UI as a modal dialog:

If the Source is implemented as a modal dialog box, the application cannot perform any other actions until the UI is closed (except of course for interacting with the Source UI and starting the image acquisition).  The Source is automatically closed by DTWAIN after an acquisition is done (remember that an acquisition may consist of retrieving multiple pages).

 

Source UI as a modeless dialog (or a set of modeless windows):

If the Source UI is implemented as a modeless dialog, the user can perform any application action while the Source UI is opened.  The Source UI can remain open until the user decides to close it.  The Source UI should only be closed by the user, and not be closed by the application unless the application is terminating.  However, this is only a good guideline to follow (TWAIN has stated that this should be the way an application handle a modeless UI).  DTWAIN allows you to override this behavior for modeless dialog boxes by calling DTWAIN_CloseSource, DTWAIN_EndTwainSession, DTWAIN_SysDestroy, or DTWAIN_SetMaxAcquisitions.  These functions can be called to close a Source, a TWAIN session, or close the entire DTWAIN DLL mechanism, respectively.  Care must be taken that these functions are not called while an image is being acquired, i.e. the scanner is not 'in motion' when closing the Source.  The DTWAIN Source State functions help out in this regard.