Paradox Community
Search:

 Welcome |  What is Paradox |  Paradox Folk |  Paradox Solutions |
 Interactive Paradox |  Paradox Programming |  Internet/Intranet Development |
 Support Options |  Classified Ads |  Wish List |  Submissions 


Paradox Programming Articles  |  Beyond Help Articles  |  Tips & Tricks Articles  


TWAIN Support in ObjectPAL®
Function Reference
© 2001 Paul Cronk

Function Reference

isTwainAvailable Twain

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 is made 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
                            the source
Returns     :   Logical
This method requires Paradox 10 SP2 to function properly. In Paradox 10 SP1, this method 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 the
                            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.


close Twain

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).


enumSourceNames Twain

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.


getSource Twain

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.


getDefaultSource Twain

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 the current session data source to that of the system.


getSourceCount Twain

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.


isAssigned Twain

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.


open Twain

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.


setSource Twain

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 SP2 - 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.


showSelectSourceDlg Twain

Method showSelectSourceDlg() LongInt

Parameters  :   none
Returns     :   Logical
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: Sample Projects
Previous: TWAIN Support in ObjectPAL Part 3


Discussion of this article


 Feedback |  Paradox Day |  Who Uses Paradox |  I Use Paradox |  Downloads 


 The information provided on this Web site is not in any way sponsored or endorsed by Corel Corporation.
 Paradox is a registered trademark of Corel Corporation.


 Modified: 15 May 2003
 Terms of Use / Legal Disclaimer


 Copyright © 2001- 2003 Paradox Community. All rights reserved. 
 Company and product names are trademarks or registered trademarks of their respective companies. 
 Authors hold the copyrights to their own works. Please contact the author of any article for details.