TechTricks
Technical answers from the trenches 
 
 
 
 

     
   
TWAIN Support in ObjectPAL, Part 3: TWAIN Function Reference
 
   
by Paul Cronk 
 Posted: 1 July 2001
 
   
 
 Applies to: Paradox 10
 
   
 
Audience: Developers
 
       
   

Note: This is Part 3 of 4. You can also:

Function Reference

isTwainAvailableTwain
proc isTwainAvailable() Logical

Parameters   :   none
Returns      :   Logical

This function returns TRUE if TWAIN support is available, and FALSE if TWAIN support is unavailable at the time of the function call.

IsTwainAvailable() will check the existence of the TWAIN interface plug-in (pxtwn32.dll). If this is found, then a connection to the source manager (twain_32.dll) is attempted. If the connection was established successfully, a further check to ensure that there is at least one source available for acquiring before returning TRUE to the caller.

acquire (to a UIObject type)Twain
Method acquire(const ui uiObject, const bShowUI Logical) Logical

Parameters   :   ui      UIObject to acquire to
                 bShowUI show the user interface of the source
Returns      :   Logical

This function acquires an image into the passed UI object. The passed UI object must be a graphic object, or a graphic field object that is in edit mode. If either of these two conditions are not met, the function fails.

If the acquisition dialog is cancelled, the function still returns TRUE.

acquire (to a graphic type)Twain
Method acquire( const gAcquired Graphic,
                const bShowUI Logical ) Logical

Parameters   :   gAcquired   graphic object to acquire to
                 bShowUI     show the user interface of source
Returns      :   Logical

This function does not work in Paradox 10 SP1. This function states an error about the usage of an unassigned variable. For completeness, however, the summary is listed below.

This function acquires an image into the passed graphic type. If the acquisition dialog is cancelled, the function still returns TRUE. To determine if dialog was cancelled, verify that the graphic type is assigned. If the graphic type is unassigned, then the dialog was cancelled.

acquire (to a file)Twain
Method acquire( const strFileName String,
                const bShowUI Logical ) Logical

Parameters   :   strFileName   name of the file to acquire to.
                 bShowUI       show the user interface of source
Returns      :   Logical

This function acquires an image into the passed filename. If the filename is not preceded with an absolute path, the working directory is assumed. The file can be prefixed with an alias, to store the file at the location of the passed alias.

This method can acquire 32bit images to disk.

Specifying an extension to the filename (such as .jpg, or .gif) will not convert the file. The file will be stored as a bitmap regardless.

If the acquisition dialog is cancelled, the function still returns TRUE. To determine if dialog was cancelled, verify existence of the file on disk. If the file is not to be found, then the dialog was cancelled.

closeTwain
Method close() Logical

Parameters   :   none
Returns      :   Logical

This function returns TRUE when the session is closed. It will return FALSE, if the variable is in a state where it cannot be aborted (such as acquiring an image).

enumSourceNamesTwain
Method enumSourceNames( var dyn DynArray[] String ) Logical

Parameters   :   dyn      dynamic array to hold results
Returns      :   Logical

This function enumerates the sources that exist on the current machine, and places them into the passed dynamic array. These same names can be used to set the source for the session.

getSourceTwain
Method getSource() String

Parameters   :   none
Returns      :   String    current data source name

This function returns the source name for the session. If the source name for the session has not been set, then the default source for the machine is used.

getDefaultSourceTwain
Method getDefaultSource() String

Parameters   :   none
Returns      :   String   system default data source

This function returns the system default TWAIN data source. This data source is the selected entry in the system Select Source dialog. This function is useful for resetting/setting or comparing against the current session data source to that of the system.

getSourceCountTwain
Method getSourceCount() LongInt

Parameters   :   none
Returns      :   LongInt   returns the number of data sources

This function returns the number of TWAIN-compliant data sources that exist on the machine. This function should never return 0. If there are no data sources existing on the machine, then the function isTwainAvailable() would return FALSE, and open() would not establish a session.

isAssignedTwain
Method isAssigned() Logical

Parameters   :   none
Returns      :   Logical

This function returns TRUE if the twain session has been opened, and FALSE if not. Generally, developers should code around the open() call to deal with errors or problems establishing the session.

openTwain
Method open() Logical

Parameters   :   none
Returns      :   Logical

This function returns TRUE if a TWAIN session could be established. An application can have multiple TWAIN sessions occurring at the same time. However, one and only one can be communicating with the TWAIN manager at any time.

setSourceTwain
method setSource( const strSourceName String ) Logical

Parameters   :   strSourceName    source name to set
Returns      :   Logical

This function sets the source name for the session. If the source name could not be found, then the function returns FALSE.

Note: As of Paradox 10 SP1 - if the function fails to set the passed source name, coding an errorShow() to display the error will have no effect. No error dialog will be displayed.

showSelectSourceDlgTwain
Method showSelectSourceDlg() LongInt

Parameters   :   none
Returns      :   none

This function displays the Select Source dialog from the source manager. This is the only supported way of changing the default data source for the system. However, for most TWAIN enabled applications, it is best to store the default source for the application, instead of relying on the system data source. By storing the default source for the application, the administrator gains more control over what devices may render images, and what devices cannot.

Next Part: Part 4: Samples, Advanced Techniques, and Appendices

Previous: Part 2: TWAIN Support Overview

 

       

Top

Feedback About Paradox Delphi Assorted Web Stuff
 
 
Copyright © 2000-2004, techtricks.com; All Rights Reserved.
Acknowledgements, Disclaimers, Terms and Conditions.
Article last updated on 05 June 2003

 

Other Sites: Paradox, Delphi, Perl, Web Stuff, and More


 

[- End -]