Introduction

TWAIN is a standard for image input devices, such as scanners and digital cameras. Getting an image from a TWAIN device can be very simple. First, there is a standard facility for selecting the input device. It is similar to selecting a default printer, and you can skip this step if you know that the default is right. Then, each TWAIN device has its own user interface, which you invoke to acquire an image.

Some complexity is introduced only when acquiring multiple images or when bypassing the user interface. If you acquire multiple images, you must code a callback function or event procedure to handle each image. If you bypass the user interface, you must set some standard TWAIN parameters to provide the information that the TWAIN driver would normally get from the user interface. The tricky part is that some TWAIN drivers implement the standard more fully than others. If you do not know in advance how the TWAIN device will behave, it is a good idea to add logic to your program to test the success of setting the TWAIN parameters. LEADTOOLS provides properties, methods and events for all of this.

Please note that TWAIN support requires TWAIN.DLL for 16-bit or TWAIN_32.DLL for 32-bit. These files must be obtained from the TWAIN device manufacturer.

The basic LEADTOOLS TWAIN VCL features are available in all LEADTOOLS toolkits. The Fast Configuration capabilities are available only in the LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite toolkits. These capabilities are locked and must be unlocked using the key obtained from LEAD. For more information, refer to Unlocking Special LEAD Features. The Twain capabilities can be used to:

manage the TWAIN sources.

acquire pages from a specified source.

handle different TWAIN sources, like scanners, barcode readers, and digital cameras.

Executable demos are included in all LEADTOOLS products. The executable demos provide a quick and easy way to evaluate features and performance.

You can use the LEADTOOLS VCL in:

Delphi 4.0

Delphi 5.0

Delphi 6.0

Delphi 7.0

C++ Builder 4.0

C++ Builder 5.0

C++ Builder 6.0

Summary of All Supported Image File Formats

Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.


Example Programs

The executable files for these examples were compiled with Document/Medical capabilities of the toolkit. To get Document/Medical capabilities, you must buy a LEADTOOLS Document/Medical editions toolkit. To get TWAIN features, you must buy one of the toolkits which includes the TWAIN features. Otherwise, if you recompile the examples, the resulting executable files will not have the Document/Medical capabilities.

C++ Builder (5 and 6)

EXAMPLES\VCL\BUILDER\Twain contains a sample application that demonstrates most of the TWAIN features in the C++ Builder 5.0 environment. You can open the project in C++ Builder; then compile and run it.

Delphi

EXAMPLES\VCL\DELPHI\Twain contains a sample application that demonstrates most of the TWAIN features in the Delphi 5.0 environment. To run the sample application, you can run the EXE file in LEAD's BIN directory.


Version History

Current version: | 14.5
Last update: | October 19, 2005

Changes from Version 14 to Version 14.5

Version 14


Changes from Version 14 to Version 14.5

Version 14.5 of the LEADTOOLS TWAIN VCL has not changed from Version 14.


Version 14

Version 14 of LEADTOOLS TWAIN VCL has been completely rewritten since version 13.

The rest of this section contains the new properties, methods and events:

Acquire method

AcquireMulti method

AcquireSourceName property

AddCapabilityToFile method

AppName property

CloseTemplateFile method

CreateExtendedInfo method

CreateNumericContainerArray method

CreateNumericContainerEnum method

CreateNumericContainerOneValue method

CreateNumericContainerRange method

EnableAcquireMultiEvent Property

EnableAcquirePageEvent Property

EnableEnumCapabilityEvent Property

EnableFastConfigEvent Property

EnableMethodErrors property

EnableSaveCapabilityEvent Property

EnableSetPropertiesEvent Property

EndSession method

EnumCapabilities method

FamilyName property

FindFastConfig method

FreeContainer method

FreeExtendedImageInfoStructure method

FreePropQueryStructure method

FreeScanConfig method

GetCapability method

GetCapabilityFromFile method

GetExtendedImageInfo method

GetExtendedInfo method

GetNumericContainerBOOLValue method

GetNumericContainerFIX32Value method

GetNumericContainerFRAMEValue method

GetNumericContainerINTValue method

GetNumericContainerItemType method

GetNumericContainerSTRINGValue method

GetNumericContainerUINTValue method

GetNumericContainerValue method

GetNumOfCapsInFile method

GetProperties method

GetScanConfigs method

InitSession method

IsAvailable method

IsSupportLocked method

LockContainer method

ManName property

ManufacturerName property

OnAcquireMultiEvent Event

OnAcquirePageEvent Event

OnEnumCapabilityEvent Event

OnFastConfigEvent Event

OnSaveCapabilityEvent Event

OnSetPropertiesEvent Event

OpenTemplateFile method

ProdFamily property

QueryProperty method

SelectedFamilyName property

SelectedManufacturerName property

SelectedSourceName property

SelectSource method

SetCapability method

SetProperties method

ShowTemplateDlg method

SourceCount property

SourceName property

UnlockContainer method

UnlockSupport method

Version property


Copyright notice

Copyright Notices

©Copyright LEAD Technologies, Inc. 1991-2005. ALL RIGHTS RESERVED

Portions of the PCDLIB32.DLL, PCDLIB.DLL, LFFPX7.DLL, LFKODAK.DLL, EKFPIXJPEG140.DLL, PDC_SDK.DLL, PROFIRE.DLL, DC120V154_32.DLL, LFDCR14N.DLL, DCSPROBACK.DLL, DCSPRO3SLR.DLL, LFDCS14N.DLL, and LFKDC14N.DLL files contain material that is ©Copyright Eastman Kodak Company, 1996-2001. This software is based in part on the work of the Independent JPEG Group.

Portions of the LFCRW14N.DLL, LTCMP14.DLL, CDSDK.reg, CDSDK.dll, CDRAPCLS.dll, czs_ui.dll, deimg.dll, deImg010.dll, deImg110.dll, deImg153.dll, deimg301.dll, deimg401.dll, deImg404.dll, deimg602.dll, Deimg603.dll, DeImgd60.dll, pscAdimg.dll, pscCllct.dll, pscCStUI.dll, pscDcd.dll, pscDevUI.dll, pscDvlp.dll, Pscl2STI.dll, pscll.dll, pscParse.dll, pscSetup.dll, psdkdll.dll, psdkReg.dll, psParse.dll. file contain material that is © Canon, Inc. 2002

Portions of the LFFPX7.DLL and LFKODAK.DLL files contain material that is ©Copyright Hewlett Packard, 1996.

Portions of the OCR/ICR/OMR Features and the help file for the OCR/ICR/OMR Features are ©Copyright Scansoft, Inc. 1995-2003. ALL RIGHTS RESERVED

Portions of the Barcode Modules contain material that is ©Copyright Axtel Inc., 1999.

Portions of the LEADTOOLS PDF Plug in and the LEADTOOLS Vector Imaging Pro are ©Copyright 1996, 2000 Artifex Software Inc. All rights reserved.

File filters for decoding MrSID ® and DjVu ® formats are provided under a license from Lizardtech, Inc.

The "FlashPix" format uses Microsoft's OLE structured storage.

Portions of the DICOM help files in Medical Imaging product line are reprinted with permission from the National Electrical Manufacturers Association ©Copyright 1998 by the National Electrical Manufacturers Association. All rights including translation into other languages, reserved under the Universal Copyright Convention, the Berne Convention or the Protection of Literacy and Artistic Works, and the International and Pan American Copyright Conventions.

Portions of LEADTOOLS Data Security Add On contain software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/), including cryptographic software written by Eric Young (eay@cryptsoft.com) and by Tim Hudson (tjh@cryptsoft.com). Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. Copyright Tim Hudson 1995-1998 (tjh@cryptsoft.com) All rights reserved.

Portions of LEADTOOLS Data Security Add On contain software based on the MD5 Message Digest Algorithm developed by RSA Data Security, Inc.. Copyright (c) 1991-92 RSA Data Security, Inc. All Rights Reserved.

Portions hereof licensed under US patent 5,327,254 and foreign counterparts.

Portions of the LEADTOOLS ICC Profiles material is © Copyright 2004, International Color Consortium.

Trademarks

LEAD® and LEADTOOLS® are registered trademarks of LEAD Technologies, Inc.
Microsoft, Windows, Windows NT, Visual Basic, Visual FoxPro, and Microsoft Access are either trademarks or registered trademarks of the Microsoft Corporation.
OS/2® is a registered trademark of International Business Machines Corporation.

TextBridge®OCR is a registered trademark of Scansoft, Inc.

ISIS® is a registered trademark of Pixel Translations, Inc.

ScanAhead™ is a trademark of Pixel Translations, Inc.

FlashPix™ is a trademark of Eastman Kodak Company.

All other brand or product names used in this online help are trademarks of their respective holders.

Address and Contact Information

LEAD Technologies, Inc.
Suite 400
1201 Greenwood Cliff
Charlotte, NC 28204

(704) 332-5532
FAX: (704) 372-8161
E-mail: support@leadtools.com
Technical support: (704) 372-9681 or support@leadtools.com
Home page: http://www.leadtools.com


Programming with LEADTOOLS TWAIN Functions

Programming with LEADTOOLS TWAIN VCL

Before scanning images using a TWAIN source, a TWAIN source must first be installed. To determine whether a TWAIN source is installed, call the IsAvailable method.

Once the TWAIN driver is installed and configured to the system, the user is ready to begin programming with LEADTOOLS TWAIN VCL. LEADTOOLS provides methods for:

Selecting and managing the available TWAIN source installed on the system.

Acquiring images from a selected TWAIN source.

Handling different TWAIN sources, like scanners, barcode readers, and digital cameras.

Getting Started

To begin using the available features in the LEADTOOLS TWAIN toolkit, the user should initialize a TWAIN session. For more information, refer to Initializing a TWAIN Session.

The user can now, select a specific TWAIN source from the sources installed on the system, or use the default TWAIN source. This must be done after the user has initialized a TWAIN session. For more information, refer to Managing the TWAIN Source.

Setting and Getting Capabilities Values

Each TWAIN source has a set of supported capabilities. The user may set these capabilities to some desired value before acquiring the image(s) or the user may elect to use the TWAIN source's default values for the capabilities. LEADTOOLS provides methods for working with capabilities in the following ways:

Enumerating the capabilities supported by the source and getting their values.

Setting or resetting defined values by the TWAIN source of a certain capability.

Getting capabilities values supported by the TWAIN source.

For more information, refer to Getting and Setting Capabilities.

Acquiring Images or Image Data

After the desired TWAIN source capabilities have been set, the user can start acquiring raster images and/or image data. Image data is related to the data acquired from a barcode, if the selected TWAIN source is the barcode reader.

For more information, refer to How to Acquire from the TWAIN Source.

Save Settings to Files

The user can save the capability settings, used when acquiring images, in a template file. These capability settings can then obtained from the template file and used to acquire images from the same TWAIN source later, instead of getting and setting the TWAIN capabilities each time. For more information, refer to Handling Template Files.

Freeing the TWAIN Session

When the handle to the TWAIN session is no longer needed, it should be freed. For more information, refer to Freeing the TWAIN Session.


Unlocking Special LEAD Features

The TWAIN features supported in this toolkit are not locked. However, LEAD offers a variety of features, such as Document support, Medical support, Vector support, etc., which are only available in certain toolkits and are locked. To use these features you must:

Purchase a toolkit that supports the desired feature(s).

Print the applicable runtime agreement from the help file. For information on the runtime agreements, go to Topic Selection and click on the LEAD Licensing button.

Complete the Transmittal document and fax it and the runtime agreement to LEAD's Licensing Department at 704 – 372 – 3789. (To view the transmittal document you must have Adobe® Acrobat® installed.)

If prepaid licenses are desired, include the order form with payment information. You can fax this along with the Transmittal form and the runtime agreement. (To view the order form you must have Adobe® Acrobat® installed.)

Once we have received the signed agreement, we will send instructions for eliminating the license dialogs and the key(s) necessary for unlocking the appropriate features.

When you have received the instructions and the key(s) call the UnlockSupport method with the appropriate key.

For example, if you have purchased the LEADTOOLS Document Imaging toolkit:

Print the Document Imaging Agreement (or the Document Imaging with OCR Agreement if you have also purchased the LEADTOOLS OCR Module).

Complete the Transmittal document and fax it and the Document Imaging Agreement (or the Document Imaging with OCR Agreement) to LEAD's Licensing Department.

If you want prepaid licenses, print a copy of the order form, fill it out and send the order form and payment information to LEAD.

Once we have received the signed Document Imaging Agreement (or Document Imaging with OCR Agreement), we will send the instructions for eliminating the license dialogs and any necessary keys.

When you receive the instructions and the key(s), call UnlockSupport method(L_SUPPORT_DOCUMENT, "Document Key") to unlock the Document features. Please note that "Document Key" represents the actual key you will receive from LEAD. Also note that if you also purchased the LEADTOOLS OCR Module, the OCR features will have to be unlocked separately, using the appropriate key.

For information on products and the features available in each product, or for information on licensing, refer to Topic Selection.

To determine if a certain feature is locked, call the IsSupportLocked method.


Managing the TWAIN Source

Once the user has initialized the TWAIN session, the TWAIN source to use for acquiring images should be selected. To determine whether a TWAIN source is available on your system, use the IsAvailable method. If there are TWAIN sources available, you can determine the number of TWAIN sources available on the system using the SourceCount property.

To determine the TWAIN sources available on the system LEADTOOLS provides the SourceName property. This property contains the name of the TWAIN source.

To select the TWAIN source to use for acquiring images, call the SelectSource method. Once a source is selected, the SelectedSourceName property will contain the name of that selected source.

If the source is to be selected without displaying a user interface, you can set the source name using the AcquireSourceName property.

LEADTOOLS provides several properties for getting information about TWAIN source product names and manufacturers names.

The product name of the currently selected TWAIN source can be found in the SelectedFamilyName property. The names of all the TWAIN products available on the system can be found in the FamilyName property.

The manufacturer's name of the currently selected TWAIN source can be found in the SelectedManufacturerName property. The names of the manufacturers of all the TWAIN products available on the system can be found in the ManufacturerName property.

Each TWAIN source has certain capabilities. The user may wish to alter these capability settings before acquiring images from the TWAIN source. For more information on this, refer to Getting and Setting Capabilities.


Initializing a TWAIN Session

Before initializing a TWAIN session, the user should set the values of the following optional, application specific properties:

ManName property

ProdFamily property

Version property

AppName property

To begin using the LEADTOOLS TWAIN toolkit, the user must initialize a TWAIN session. This is done by calling the InitSession method. Each call to the InitSession method will create an internal TWAIN session handle, which is a communication handle between LEADTOOLS TWAIN and a TWAIN driver installed on the system. The InitSession method must be called before calling other LEADTOOLS TWAIN properties, methods or events.

To make the toolkit generate system error events, in addition to error return codes, set the EnableMethodErrors property to TRUE.

After initializing the TWAIN session, the user can now select the TWAIN source he or she wants to use for acquiring images. For more information on this, refer to Managing the TWAIN Source.


Fast TWAIN (Scan Configurations)

The performance of a TWAIN scanner can vary based on its scan configuration. The TWAIN driver of your TWAIN scanner comes with one or more "default" scan configurations. In addition, the user may create one or more user-defined scan configurations. LEAD provides several methods to determine the best and fastest scan configuration available, thereby letting you use the best and fastest scan configuration for scanning images.

To determine the best and fastest scan configuration for your TWAIN scanner, call FindFastConfig method. This method will test either an array of user-defined scan configurations, or all the default scan configurations present for the TWAIN driver of the current TWAIN scanner, based on the values of the pInFastConfigs and the nInFastConfigsCount parameters. For each scan configuration that is tested, the FindFastConfig method calls the OnFastConfigEvent Event if the EnableFastConfigEvent property was set to TRUE. This Event receives the information for the scan configuration being tested. This lets you interact with the scan configuration information as needed.

Since the list of default scan configurations present for a specific TWAIN driver can be rather numerous, you can narrow the list you wish to test using the GetScanConfigs method. This method gets default scan configurations based on the transfer mode, bits per pixel and number of buffers. Therefore, you can get a list of scan configurations for a specific transfer mode, pass this list of scan configurations to the FindFastConfig method, and decrease the number of default scan configurations that must be tested.

Both the FindFastConfig and the GetScanConfigs methods allocate storage for an array of FASTCONFIG structures that contains scan configurations. This storage must be freed by calling FreeScanConfig method, when the array is no longer needed.

Once the best scan configuration has been determined, the scan configuration information can be passed to the AcquireMulti method so the images will be acquired as fast as possible.


Freeing the TWAIN Session

When the TWAIN session is no longer needed, the user must free the internal handle by calling the EndSession method. At this point the internal TWAIN handle becomes invalid. Before acquiring any more images from a TWAIN source, the user must initialize a new internal TWAIN handle by calling the InitSession method.


Getting and Setting Capabilities

Each TWAIN source may support a number of capabilities. These capabilities dictate the behavior of the TWAIN source. Before acquiring images from the selected TWAIN source, the user may wish to examine and change the capability settings for that source.

The LEADTOOLS TWAIN toolkit provides the user low-level and high-level functionality for getting and setting the capabilities.

LEADTOOLS provides both low-level and high-level methods for getting and setting capabilities. The low-level methods get and set capabilities individually. The high-level methods let the user get and set a specific group of capabilities, be getting and setting properties in a structure.

Low-Level:

To get information about the capabilities supported by the selected TWAIN source, set EnableEnumCapabilityEvent property to TRUE and call the EnumCapabilities method. For each capability enumerated by EnumCapabilities, this method will generate the OnEnumCapabilityEvent Event. Within this event the user can process the capability information.

To get information on a specific capability (current, default, or all possible values) call the GetCapability method. This method gets information about the capability specified in a TW_CAPABILITY structure. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site www.twain.org.

To set a specific capability to a new value or to reset the value of a capability to the default value, call SetCapability method.

High-Level:

GetProperties and SetProperties methods allow the user to get and set a number of capabilities through the LTWAINPROPERTIES structure. If this structure does not have the capability needed to negotiate, user may use the low-level methods to do so.

To get each property set through an event, set EnableSetPropertiesEvent to TRUE and handle the OnSetPropertiesEvent Event.

The QueryProperty method lets the user get the available values for a specific capability from the selected source, to free the ppltProperty parameter was allocated by calling the QueryProperty method call FreePropQueryStructure method.

When working with TW_CAPABILITY structures it may be necessary to create a container associated with that structure. For more information on containers, refer to How to Work with the Containers.


Handling Template Files

Template files are used to store capability information for a specific TWAIN source. That way, the next time that TWAIN source is used, the corresponding template file can provide information on the capabilities used previously.

LEADTOOLS provides the following methods for working with template files:

ShowTemplateDlg displays the scanning dialog provided by the manufacturer of the TWAIN source without actually acquiring the images. Instead it gets the values of all supported capabilities, which will be saved to the specified template file. You can get the capabilities to be save in an event by setting the EnableSaveCapabilityEvent property, and handling the event OnSaveCapabilityEvent event.

OpenTemplateFile opens a template file for either reading or writing. When a template file is open for reading, the user can get capability information stored within the file. When a template file is opened for writing, capability information can be saved to that file.

AddCapabilityToFile adds a certain capability to the file when the file is opened with write access.

GetNumOfCapsInFile gets the number of capabilities stored in a template file.

GetCapabilityFromFile gets the capability information by passing its index to the method.

CloseTemplateFile closes the file and saves its contents if the file was opened with write access.

When a user acquires one or more images using the Acquire method, the capability settings used for the TWAIN source can be saved in a template file. The next time the user wishes to use that TWAIN source he or she can open the template file saved previously, for read access, using OpenTemplateFile. The GetNumOfCapsInFile method will provide the number of capabilities stored in the template file. This information allows the user to loop through the stored capabilities using the GetCapabilityFromFile method. As each capability is obtained, the user can set the capabilities for the TWAIN source using the SetCapability method.


How to Acquire from the TWAIN Source

After the user has initialized a TWAIN session, selected a TWAIN source, and set the desired capabilities of the TWAIN source, he or she is ready to acquire images or image data from that source. LEADTOOLS provides the following for acquiring images and image data from a TWAIN source:

The Acquire method acquires one or more images from a TWAIN source. If the user has set EnableAcquirePageEvent to TRUE, the OnAcquirePageEvent Event will receive each image acquired from the source. This allows the user to process each image as desired. Within the OnAcquirePageEvent Event the user can call the GetExtendedImageInfo method to get extended image information that is included if the TWAIN source is a barcode reader or a digital camera.

To create extended image information using an image information array, use the CreateExtendedInfo method.

To get specific image information call the GetExtendedInfo method.

Use the FreeExtendedImageInfoStructure method to free the TW_EXTIMAGEINFO structure that the GetExtendedImageInfo method retrieves.

For more information about TW_EXTIMAGEINFO, refer to the TWAIN 1.9 specification from the site www.twain.org.

The AcquireMulti method acquires one or more images from a TWAIN source and saves the image(s) to one or more files. If the file format used does not support multi-page files, then the images will be saved to a series of files named by appending the image number to a base file name. If the file format used does support multi-page files, then the image(s) will be saved to one or more files based on the bMultiPageFile parameter. If this parameter is set to FALSE, then images will be saved to a series of files named by appending the image number to a base file name. If this parameter is set to TRUE, the image(s) will be saved to one multi-page file named using only the base file name.

If you set the EnableAcquireMultiEvent property to TRUE, the OnAcquireMultiEvent Event will be called twice for each page scanned using the AcquireMulti method. It is called the first time when the Twain source begins scanning the page. It is called the second time when the Twain source has finished scanning the page.

The methods listed above can acquire images in the following transfer modes:

Transfer Mode | Meaning
Native | Gets the bitmaps being scanned into the memory as a whole.
Memory Buffered | Gets images from the source as strips of data. These strips can be merged to get the whole image.
File | Gets the images from the source to a disk file.


How to Work with the Containers

When getting or setting capability information, it may be necessary to create a container for the associated TW_CAPABILITY structure. The structure of these containers depends on the type of information in the container. LEADTOOLS supports the following types of containers:

TW_ARRAY

TW_ENUMERATION

TW_ONEVALUE

TW_RANGE

For more information on these container types, refer to the TWAIN 1.9 Specification, available at www.twain.org.

For each type of container, LEAD provides a specific method:

CreateNumericContainerArray, allocates the container of the TW_CAPABILITY structure to be of type TW_ARRAY and fills it with the specified data.

CreateNumericContainerEnum, allocates the container of the TW_CAPABILITY structure to be of type TW_ENUMERATION and fills it with the specified data.

CreateNumericContainerOneValue, allocates the container of the TW_CAPABILITY structure to be of type TW_ONEVALUE and fills it with the specified data.

CreateNumericContainerRange, allocates the container of the TW_CAPABILITY structure to be of type TW_RANGE and fills it with the specified data.

The value in a container can be changed once the user has a pointer to the container. To change the value of a container, the user can call LockContainer, make the desired changes to the container value(s), and then call UnlockContainer. Alternately, the user can accomplish the same thing be calling the API GlobalLock and GlobalUnlock methods.

When the created container is no longer needed, it should be freed by calling FreeContainer method.

LEAD provides a number of methods for getting container values, based on the data type of the value. To get the data type of the value in a container, call GetNumericContainerItemType. Once the type is known, the following methods can be used to get the container value(s) from the TW_CAPABILITY structure:

GetNumericContainerValue

GetNumericContainerINTValue

GetNumericContainerUINTValue

GetNumericContainerFIX32Value

GetNumericContainerFRAMEValue

GetNumericContainerSTRINGValue

GetNumericContainerBOOLValue

To get the available values for a specific TWAIN capability, call QueryProperty. This method takes a pointer to a LTWAINPROPERTYQUERY structure, which will be updated with the available values for the capability.


Files To Be Included With Your Application

The installation procedure creates a directory tree for the LEADTOOLS files, and adds the demonstration programs and online help to your desktop. You specify the root directory during installation. The following subdirectory is created:

REDIST\

Redistributable files.

The following table summarizes the files you must include on your distribution diskettes to support the LEADTOOLS Twain functions on a 32-bit system. (\REDIST\ subdirectory contains copies of these files.)

Please note that LTKRN, LTDIS, LTEFX, LTIMG, and LTFIL are required for ALL VCL applications. For more information on LTKRN, LTDIS, LTEFX, LTIMG, LTFIL and other files for the Main VCL, refer to Files To Be Included With Your Application .

Redistributables | Explanation: | If you are using a standard release, the files to use are: | If you are using an evaluation release, the files to use are:
LT14B5MN LT14B5AD LT14B5SN LT14B5DI LT14B5AN | Borland C++ Builder 5.0 runtime files. Required for VCL applications that are built with Borland C++ Builder 5.0. LT14B5MN.BPL is the BPL file for the LEADTOOLS VCL Main Package; LT14B5AD.BPL is the BPL file for the LEADTOOLS VCL Additional Package; LT14B5SN.BPL is the BPL file for the LEADTOOLS VCL Scanning Package; LT14B5DI.BPL is the BPL file for the LEADTOOLS VCL DICOM Package. LT14B5AN.BPL is the BPL for the LEADTOOLS VCL Annotation Package. For more information about the controls included in each package, refer to the Introduction. For information about creating and distributing applications, refer to the Borland Builder documentation. | BPL: LT14B5MN.BPL LT14B5AD.BPL LT14B5SN.BPL LT14B5DI.BPL LT14B5AN.BPL | BPL: LT14B5MNe.BPL LT14B5ADe.BPL LT14B5SNe.BPL LT14B5DIe.BPL LT14B5ANe.BPL
LT14B6MN LT14B6AD LT14B6SN LT14B6DI LT14B6AN | Borland C++ Builder 6.0 runtime files. Required for VCL applications that are built with Borland C++ Builder 6.0. LT14B6MN.BPL is the BPL file for the LEADTOOLS VCL Main Package; LT14B6AD.BPL is the BPL file for the LEADTOOLS VCL Additional Package; LT14B6SN.BPL is the BPL file for the LEADTOOLS VCL Scanning Package; LT14B6DI.BPL is the BPL file for the LEADTOOLS VCL DICOM Package; LT14B6AN.BPL is the BPL file for the LEADTOOLS VCL Annotations Package.. For more information about the controls included in each package, refer to the Introduction. For information about creating and distributing applications, refer to the Borland Builder documentation | BPL: LT14B6MN.BPL LT14B6AD.BPL LT14B6SN.BPL LT14B6DI.BPL LT14B6AN.BPL | BPL: LT14B6MNe.BPL LT14B6ADe.BPL LT14B6SNe.BPL LT14B6DIe.BPL LT14B6ANe.BPL
LT14D6MN LT14D6AD LT143D6SN LT14D6DI LT14D6AN | Borland Delphi 6.0 runtime files. Required for VCL applications that are built with Borland Delphi 6.0 and with RTP checked. LT14D6MN.BPL is the BPL file for the LEADTOOLS VCL Main Package; LT14D6AD.BPL is the BPL file for the LEADTOOLS VCL Additional Package; LT14D6SN.BPL is the BPL file for the LEADTOOLS VCL Scanning Package; LT14D6DI.BPL is the BPL file for the LEADTOOLS VCL DICOM Package; LT14D6AN.BPL is the BPL file for the LEADTOOLS VCL Annotations Package. For more information about the controls included in each package, refer to the Introduction. For information about creating and distributing applications, refer to the Borland Delphi documentation. | BPL: LT14D6MN.BPL LT14D6AD.BPL LT143D6SN.BPL LT14D6DI.BPL LT14D6AN.BPL | BPL: LT14D6MNe.BPL LT14D6ADe.BPL LT143D6SNe.BPL LT14D6DIe.BPL LT14D6ANe.BPL
LT14D7MN LT14D7AD LT14D7SN LT14D7DI LT14D7AN | Borland Delphi 7.0 runtime files. Required for VCL applications that are built with Borland Delphi 7.0 and with RTP checked. LT14D7MN.BPL is the BPL file for the LEADTOOLS VCL Main Package; LT14D7AD.BPL is the BPL file for the LEADTOOLS VCL Additional Package; LT14D7SN.BPL is the BPL file for the LEADTOOLS VCL Scanning Package; LT14D7DI.BPL is the BPL file for the LEADTOOLS VCL DICOM Package; LT14D7AN.BPL is the BPL file for the LEADTOOLS VCL Annotations Package. For more information about the controls included in each package, refer to the Introduction. For information about creating and distributing applications, refer to the Borland Delphi documentation. | BPL: LT14D7MN.BPL LT14D7AD.BPL LT14D7SN.BPL LT14D7DI.BPL LT14D7AN.BPL | BPL: LT14D7MNe.BPL LT14D7ADe.BPL LT14D7SNe.BPL LT14D7DIe.BPL LT14D7ANe.BPL


Installation Directory

The installation procedure creates a directory tree for the LEADTOOLS files, and adds the demonstration programs and online help to your desktop. You specify the root directory during installation.

Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.

The following is a list of the subdirectories in the root directory:

BIN | Executable files for the demonstration programs.
HELP | Online help files.
IMAGES | Sample images and databases containing images.
EXAMPLES\VCL | One subdirectory for each example VCL program.
INCLUDE | Header files, BAS files, and the ActiveX's MFC interface files for versions of Visual C++ earlier than 4.0.
USES | Pascal user uses and includes files.
LIB | Library files.
LIB\VCL\DELPHI6 | The LEADTOOLS VCL Delphi 6.0 package and unit files.
LIB\VCL\DELPHI7 | The LEADTOOLS VCL Delphi 7.0 package and unit files.
LIB\VCL\BUILDER5 | The LEADTOOLS VCL Builder 5.0 package, LIB and header files.
LIB\VCL\BUILDER6 | The LEADTOOLS VCL Builder 6.0 package, LIB and header files.


Tutorial for C++ Builder 6.0 Programmers

Tutorial for C++ Builder Programmers

The following topics provide brief and simple examples to help you learn how to use the LEAD VCL Twain Control.

Note: These tutorial examples are intended to be easy to understand and easy to test. The example programs in the EXAMPLES subdirectory provide more in depth design and more detailed code.

Acquiring an Image

Using the Fast TWAIN Feature

Get a Fast Twain Scan from a Scanner

Set/Get a Twain Capability


Acquiring an Image (C++ Builder 6.0 )

Acquiring an Image (C++ Builder)

Take the following steps to start a project and to add some code that acquires an image from a TWAIN source:

Take the following steps to create and run a program that implement LEADTOOLS TWAIN features. Remember, the purpose of the TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program. For more in depth TWAIN programming, refer to the TWAIN demo.

1. | Start C++ Builder.
2. | On the C++ Builder toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
3. | Select the LEAD Main control on the VCL toolbar. Size and position the control, as you want it to appear at run time.
4. | Select the LEAD Twain control on the LEADTOOLS toolbar. Place the control anywhere on the form.
5. | At the top of your form, add 7 Buttons and name them as follows:
 | Name | Caption
 | btnOK | OK
 | btnCancel | Cancel
 | btnAcquire | Acquire
 | btnSelectSource | Select Source
 | btnNative | Native
 | btnMemBuf | Memory Buffered
 | tnFile | File
6. | Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
LEADTwain1->InitSession ( (L_HANDLE)Handle ) ;
}

7.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
LEADTwain1->EndSession ( );
}

8.

Handle the btnOK OnClick event, and code the btnOKClick procedure as follows.

void __fastcall TForm1::btnOKClick(TObject *Sender)
{
Close ( );
}

9.

Handle the btnCancel OnClick event, and code the btnCancelClick procedure as follows.

void __fastcall TForm1::btnCancelClick(TObject *Sender)
{
Close ( );
}

10.

Handle the btnAcquire OnClick event, and code the btnAcquireClick procedure as follows:

void __fastcall TForm1::btnAcquireClick(TObject *Sender)
{
LEADTwain1->Acquire ( LTWAIN_SHOW_USER_INTERFACE );
}

11.

Handle the btnSelectSource OnClick event, and code the btnSelectSourceClick procedure as follows:

void __fastcall TForm1::btnSelectSourceClick(TObject *Sender)
{
LEADTwain1->SelectSource ( );
}

12.

Handle the btnNative button’s OnClick event, and code the btnNativeClick procedure as Follows:

void __fastcall TForm1::btnNativeClick(TObject *Sender)
{
L_INT nRet;
LTWAINPROPERTIES twProps;

FillMemory ( &twProps, sizeof(LTWAINPROPERTIES), 0 );
nRet= LEADTwain1->GetProperties ( &twProps, LTWAIN_PROPERTIES_GETCURRENT );
if ( nRet != SUCCESS )
return;
twProps.DataTransfer.nTransferMode= TWSX_NATIVE;

LEADTwain1->SetProperties ( &twProps, LTWAIN_PROPERTIES_SET );
}

13.

Handle the btnMemBuf button’s OnClick event, and code the btnMemBufClick procedure as follows:

void __fastcall TForm1::btnMemBufClick(TObject *Sender)
{
L_INT nRet;
LTWAINPROPERTIES twProps;

FillMemory ( &twProps, sizeof(LTWAINPROPERTIES), 0 );
nRet= LEADTwain1->GetProperties ( &twProps, LTWAIN_PROPERTIES_GETCURRENT );
if ( nRet != SUCCESS )
return;
twProps.DataTransfer.nTransferMode= TWSX_MEMORY;
twProps.DataTransfer.nBufMemCompression= TWCP_NONE;
LEADTwain1->SetProperties ( &twProps, LTWAIN_PROPERTIES_SET );

}

14.

Handle the btnFile OnClick event, and code the btnFileClick procedure as follows:

void __fastcall TForm1::btnFileClick(TObject *Sender)
{
L_INT nRet;
LTWAINPROPERTIES twProps;

FillMemory ( &twProps, sizeof(LTWAINPROPERTIES), 0 );
nRet= LEADTwain1->GetProperties ( &twProps, LTWAIN_PROPERTIES_GETCURRENT );
if ( nRet != SUCCESS )
return;
twProps.DataTransfer.nTransferMode= TWSX_NATIVE;
StrCopy ( twProps.DataTransfer.szFileName, "c:\twain.bmp" );
LEADTwain1->SetProperties ( &twProps, LTWAIN_PROPERTIES_SET );
}

15.

Handle the LEADTwain1 OnAcquirePageEvent event, and code the LEADTwain1AcquirePageEvent Function as follows:

int __fastcall TForm1::LEADTwain1AcquirePageEvent(TBITMAPHANDLE Bitmap)
{
ShowMessage ( "Acquisition of Image Done" );
LEADImage1->InsertBitmapListItem ( LST_APPEND, Bitmap );
return SUCCESS;
}

16.

Run your program to test it.


Using the Fast TWAIN Feature (C++ Builder 6.0)

Using the Fast TWAIN Feature (C++ Builder)

Take the following steps to start a project and to add some code that acquires the images using Fast Twain:

1. | Start C++ Builder.
2. | On the C++ Builder toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
3. | Select the LEAD Twain control on the LEADTOOLS toolbar. Place the control anywhere on the form.
4. | At the top of your form, add a check box and name it as follows:
 | Name | Caption
 | chkUseBufferSize | Use Buffer Size
5. | Add 2 radio buttons to your form, and name them as follows:
 | Name | Caption
 | rbNative | Native Mode
 | rbMemory | Memory Mode
6. | Add 1 button to your form, and name it as follows:
 | Name | Caption
 | btnAcquire | Fast Acquire
7. | Add 2 Edit boxes to your form, and name them as follows:
 | Name |
 | edtFName |
 | edtBufferSize |
8. | Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
LEADTwain1->UnlockSupport ( L_SUPPORT_DOCUMENT, "TestKey" );
LEADTwain1->InitSession ( (L_HANDLE)Handle ) ;
LEADTwain1->EnableMethodErrors = false;
rbMemory->Checked= true;
}

9.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
LEADTwain1->EndSession ( );
}

10.

Handle the btnAcquire control's OnClick event, and code the btnAcquireClick procedure as follows.

void __fastcall TForm1::btnAcquireClick(TObject *Sender)
{
L_INT nRet;
L_INT nFormat;
L_UINT uTransferMode;
bool bMemory;

bMemory= rbMemory->Checked;
if ( bMemory )
{
uTransferMode= LTWAIN_BUFFER_MODE;
nFormat= FILE_CCITT_GROUP4;
}
else
{
uTransferMode= LTWAIN_NATIVE_MODE;
nFormat= FILE_TIF;
}

nRet= LEADTwain1->AcquireMulti ( edtFName->Text,
LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
uTransferMode,
nFormat,
1,
true,
StrToInt(edtBufferSize->Text),
!chkUseBufferSize->Checked );

if ( nRet == SUCCESS )
ShowMessage ( "Fast Scanning process done successfully..." );
else
{
ShowMessage ( "AcquireMulti failed, Error = " + IntToStr(nRet) );
}
}

11.

Run your program to test it.


Get a Fast Twain Scan from a Scanner (C++ Builder)

Get a Fast Twain Scan from a Scanner (C++ Builder)

Take the following steps to get fast twain scan using the LEADTOOLS Fast TWAIN features:

1. | Start C++ Builder.
2. | In the File menu, choose New Application.
3. | On the Delphi toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
4. | Select and Add the LEAD TWAIN control from the VCL toolbar to your Main Form.
5. | Add 3 buttons to your form and name them as follows:
 | Name | Caption
 | btnSelectSource | Select Source
 | btnFindFastConfig | Find Fast Config
 | btnAcquireFastConfig | Acquire Fast Config
6. | Define the following variable in the private section of Form1:
 | FASTCONFIG BestConfig;
7. | Handle the Form1 OnCreate event, and code the FormCreate method as follows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
L_INT nRet;
LEADTwain1->EnableMethodErrors = false;
LEADTwain1->ManName = "LEAD Technologies, Inc.";
LEADTwain1->ProdFamily = "LEAD Test Applications";
LEADTwain1->Version = "Version 1.0";
LEADTwain1->AppName = "TWAIN Test Application";
nRet= LEADTwain1->InitSession ( (L_HANDLE)Handle );
if ( nRet != SUCCESS )
{
ShowMessage ( "Failure to Initialize TWAIN" );
return;
}
LEADTwain1->EnableMethodErrors = True;
/* Unlock Document support.
Note that this is a sample key, which will not work in your toolkit. */
LEADTwain1->UnlockSupport ( L_SUPPORT_DOCUMENT, "TestKey" );
}

8.

Handle the Form1 OnClose event, and code the FormClose method as follows:

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
LEADTwain1->EndSession ( );
}

9.

Handle the btnSelectSource OnClick event, and code the btnSelectSourceClick method as follows:

void __fastcall TForm1::btnSelectSourceClick(TObject *Sender)

{

LEADTwain1->SelectSource ( );

}

10.

Handle the btnFindFastConfig OnClick event, and code the btnFindFastConfigClick method as follows:

void __fastcall TForm1::btnFindFastConfigClick(TObject *Sender)
{
L_INT nRet;
L_INT nTestConfigsCount= 0;
pFASTCONFIG pTestConfigs= NULL;

LEADTwain1->EnableMethodErrors = false;
nRet= LEADTwain1->FindFastConfig ( "c:\temp",
LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
8,
5,
NULL,
0,
&pTestConfigs,
&nTestConfigsCount,
&BestConfig );

if ( nRet == SUCCESS )
ShowMessage ( "Find Fast Configuration process completed" );
else
ShowMessage ( "An error occurred during the Finding Fast Configuration process." );

LEADTwain1->EnableMethodErrors = True;
}

11.

Handle the btnAcquireFastConfig OnClick event, and code the btnAcquireFastConfigClick method as follows:

void __fastcall TForm1::btnAcquireFastConfigClick(TObject *Sender)
{
L_INT nRet;

LEADTwain1->EnableMethodErrors = False;
nRet= LEADTwain1->AcquireMulti ( "c:\\temp\\testconfig.tif",
LTWAIN_SHOW_USER_INTERFACE | LTWAIN_USE_THREAD_MODE,
BestConfig.uTransferMode,
BestConfig.nFileFormat,
BestConfig.nBitsPerPixel,
true,
BestConfig.ulBufferSize,
true );
if ( nRet == SUCCESS )
MessageBox ( Handle, "Image acquisition using the Fast TWAIN Configuration is completed.", "Fast Config", MB_OK );
else
MessageBox ( Handle, "An error occurred while acquiring images using the Fast TWAIN Configuration.", "Fast Config", MB_OK );

LEADTwain1->EnableMethodErrors = true;
}

12.

Run your program to test it.


Set/Get a Twain Capability (C++ Builder 6.0 )

Set/Get a Twain Capability (C++ Builder)

Take the following steps to start a project and to add some code to use the Get/Set capability methods and then acquire your image using the newly set capability:

1. | Start C++ Builder.
2. | On the C++ Builder toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
3. | Select the LEAD Main control on the VCL toolbar. Size and position the control, as you want it to appear at run time.
4. | Select the LEAD Twain control on the LEADTOOLS toolbar. Place the control anywhere on the form.
5. | At the top of your form, add 5 button controls and name them as follows:
 | Name | Caption
 | btnSelectSource | Select Source
 | btnGetCapability | Get Capability
 | btnSetCapability | Set Capability
 | btnSetBrightness | Set Brightness
 | btnAcquire | Acquire
6. | Add the following variables declaration to the Form1 private section.

L_UINT uItemValue;
TW_CAPABILITY twCap;

7.

Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

void __fastcall TForm1::FormCreate(TObject *Sender)
{
LEADTwain1->InitSession ( (L_HANDLE)Handle );
LEADTwain1->EnableMethodErrors = false;

/* Unlock Document support.
Note that this is a sample key, which will not work in your toolkit. */
LEADTwain1->UnlockSupport ( L_SUPPORT_DOCUMENT, "TestKey" );
}

8.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
LEADTwain1->EndSession ( );
}

9.

Handle the btnSelectSource OnClick event, and code the btnSelectSourceClick procedure as follows.

void __fastcall TForm1::btnSelectSourceClick(TObject *Sender)
{
LEADTwain1->SelectSource ( );
}

10.

Handle the btnGetCapability OnClick event, and code the btnGetCapabilityClick procedure as follows.

void __fastcall TForm1::btnGetCapabilityClick(TObject *Sender)
{
L_INT nItemType;

twCap.Cap= ICAP_XFERMECH;
twCap.ConType= TWON_DONTCARE16;
twCap.hContainer= NULL;
LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );

LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );

if ( nItemType == TWTY_UINT16 )
LEADTwain1->GetNumericContainerUINTValue ( &twCap, 0, &uItemValue );
else
MessageBox ( Handle, "Returned bad item type", "Get Item Type", MB_OK );
}

11.

Handle the btnSetCapability OnClick event, and code the btnSetCapabilityClick procedure as follows.

void __fastcall TForm1::btnSetCapabilityClick(TObject *Sender)
{
TW_CAPABILITY twSetCap;

if ( uItemValue != TWSX_NATIVE )
{
twSetCap.Cap= ICAP_XFERMECH;
twSetCap.ConType= TWON_ONEVALUE;

LEADTwain1->CreateNumericContainerOneValue ( &twSetCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE );

LEADTwain1->SetCapability ( &twSetCap, LTWAIN_CAPABILITY_SET );
LEADTwain1->FreeContainer ( &twSetCap );
}
else
MessageBox ( Handle, "The Transfer mode is Native", "Set Capability", MB_OK );
}

12.

Handle the btnSetBrightness OnClick event, and code the btnSetBrightnessClick procedure as follows:

void __fastcall TForm1::btnSetBrightnessClick(TObject *Sender)
{
L_INT nRet;
TW_FIX32 twFix32;
pTW_ONEVALUE ptwOneVal;
TW_CAPABILITY twBrightnessCap;

twBrightnessCap.Cap= ICAP_BRIGHTNESS;
twBrightnessCap.ConType= TWON_ONEVALUE;

nRet= LEADTwain1->GetCapability ( &twBrightnessCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet == SUCCESS )
{
ptwOneVal= (pTW_ONEVALUE)(GlobalLock((void*)twCap.hContainer));

CopyMemory ( &twFix32, &ptwOneVal->Item, sizeof(TW_FIX32) );

GlobalUnlock( (void*)twBrightnessCap.hContainer );
GlobalFree( (void*)twBrightnessCap.hContainer );
twBrightnessCap.hContainer= NULL;

if ( twFix32.Whole != 128 )
{
twFix32.Whole= 128;
twFix32.Frac= 0;
}

twBrightnessCap.Cap= ICAP_BRIGHTNESS;
twBrightnessCap.ConType= TWON_ONEVALUE;
twBrightnessCap.hContainer= (TW_HANDLE)GlobalAlloc ( GHND, sizeof(TW_ONEVALUE) + sizeof(TW_FIX32) );

ptwOneVal= (pTW_ONEVALUE)(GlobalLock((void*)twCap.hContainer));

ptwOneVal->ItemType= TWTY_FIX32;
CopyMemory ( &ptwOneVal->Item, &twFix32, sizeof(TW_FIX32) );
GlobalUnlock ( (void*)twBrightnessCap.hContainer );

LEADTwain1->SetCapability ( &twBrightnessCap, LTWAIN_CAPABILITY_SET );
}
}

13.

Handle the btnAcquire OnClick event, and code the btnAcquireClick procedure as follows:

void __fastcall TForm1::btnAcquireClick(TObject *Sender)
{
LEADTwain1->Acquire ( LTWAIN_SHOW_USER_INTERFACE );
}

14.

Handle the LEADTwain1 OnAcquirePageEvent event, and code the LEADTwain1AcquirePageEvent Function as follows:

int __fastcall TForm1::LEADTwain1AcquirePageEvent(TBITMAPHANDLE Bitmap)
{
LEADImage1->Bitmap= Bitmap;
return SUCCESS;
}

15.

Run your program to test it.


Miscellaneous Examples (Builder 3.0)

You can test the following examples by either adding a command button to one of the previous lessons in the tutorial and pasting the sample code in the Click procedure, or by cutting and pasting event code into the appropriate event in a lesson.

Acquire example for Builder

AcquireMulti example for Builder

AcquireSourceName example for Builder

AddCapabilityToFile example for Builder

CreateNumericContainerArray example for Builder

CreateNumericContainerEnum example for Builder

CreateNumericContainerRange example for Builder

FamilyName example for Builder

FindFastConfig example for Builder

GetCapability example for Builder

GetCapabilityFromFile example for Builder

GetExtendedImageInfo example for Builder

GetNumericContainerBOOLValue example for Builder

GetNumericContainerFIX32Value example for Builder

GetNumericContainerFRAMEValue example for Builder

GetNumericContainerINTValue example for Builder

GetNumericContainerSTRINGValue example for Builder

GetNumericContainerUINTValue example for Builder

GetNumericContainerValue example for Builder

GetProperties example for Builder

IsAvailable example for Builder

LockContainer example for Builder

QueryProperty example for Builder

SelectedFamilyName example for Builder

ShowTemplateDlg example for Builder

SourceName example for Builder

UnlockSupport example for Builder


Acquire example for C++ Builder

int __fastcall TForm1::LEADTwain1AcquirePageEvent(TBITMAPHANDLE Bitmap)
{
if ( Bitmap != NULL )
LEADImage1->Bitmap= Bitmap;
return SUCCESS;
}

void __fastcall TForm1::btnAcquireClick(TObject *Sender)
{
L_INT nRet;
TW_CAPABILITY twCap;

// Show the Twain Select Source UI
nRet= LEADTwain1->SelectSource ( );
if ( nRet != SUCCESS )
MessageBox ( Handle, "Error occurred while selecting the source.", "ERROR", MB_OK );

twCap.Cap= ICAP_XFERMECH;
twCap.ConType= TWON_ONEVALUE;

LEADTwain1->CreateNumericContainerOneValue ( &twCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE );

LEADTwain1->SetCapability ( &twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1->FreeContainer ( &twCap );

LEADTwain1->EnableAcquirePageEvent = True;
nRet= LEADTwain1->Acquire ( LTWAIN_SHOW_USER_INTERFACE );
if ( nRet == SUCCESS )
MessageBox ( Handle, "The image acquisition process completed.", "Notice", MB_OK );
else
MessageBox ( Handle, "The image acquisition process failed!", "Error", MB_OK );
}


AcquireMulti example for C++ Builder

void __fastcall TForm1::LEADTwain1AcquireMultiEvent(int nPage,
AnsiString strFileName, bool bFinishScan)
{
AnsiString strBuffer;

if ( bFinishScan )
{
strBuffer= "The page # " + IntToStr(nPage) + " is scanned and saved to file name " + strFileName;
MessageBox ( Handle, strBuffer.c_str( ), "Notice", MB_OK );
}
}

void __fastcall TForm1::btnAcquireMultiClick(TObject *Sender)
{
L_INT nRet;

LEADTwain1->EnableAcquireMultiEvent = True;
nRet= LEADTwain1->AcquireMulti ( "c:\\TWAIN\\test.tif",
LTWAIN_SHOW_USER_INTERFACE,
LTWAIN_BUFFER_MODE,
FILE_TIF,
1,
TRUE,
0,
True );

if ( nRet == SUCCESS )
MessageBox ( Handle, "Fast Twain function was successful", "Notice", MB_OK );
else
MessageBox ( Handle, "Error occurred during fast Twain function!!!", "Error!!!", MB_OK );
}


AcquireSourceName example for C++ Builder

void __fastcall TForm1::Button1Click(TObject *Sender)
{
int nRet;

LEADTwain1->AcquireSourceName = "TWAIN Source Name";
nRet= LEADTwain1->Acquire (LTWAIN_SHOW_USER_INTERFACE);
if(nRet != SUCCESS)
ShowMessage("Error acquiring from source");
}


AddCapabilityToFile example for C++ Builder

HTWAINTEMPLATEFILE hFile;
int __fastcall TForm1::LEADTwain1EnumCapabilityEvent(DWORD uCap,
pTW_CAPABILITY pCapability)
{
return LEADTwain1->AddCapabilityToFile ( hFile, pCapability );
}

void __fastcall TForm1::btnAddCapabilityToFileClick(TObject *Sender)
{
L_INT nRet;

nRet= LEADTwain1->OpenTemplateFile ( &hFile, "c:\\temp.ltt", LTWAIN_TEMPLATE_OPEN_WRITE );
if ( nRet == SUCCESS )
{
LEADTwain1->EnableEnumCapabilityEvent = true;
LEADTwain1->EnumCapabilities ( LTWAIN_CAPABILITY_GETCURRENT );
LEADTwain1->CloseTemplateFile ( hFile );
}
}


CreateNumericContainerArray example for C++ Builder

void __fastcall TForm1::btnCreateNumericContainerArrayClick(TObject *Sender)
{
TW_UINT16 uItem[3];
TW_CAPABILITY twCap;

FillMemory ( &twCap, sizeof(TW_CAPABILITY), 0 );

twCap.Cap= ICAP_FILTER;
twCap.ConType= TWON_ARRAY;

uItem[0]= TWFT_RED;
uItem[1]= TWFT_GREEN;
uItem[2]= TWFT_BLUE;

LEADTwain1->CreateNumericContainerArray ( &twCap, TWAINNUMERICTYPE_TW_UINT32, 3, (void*)uItem );

LEADTwain1->SetCapability ( &twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1->FreeContainer ( &twCap );
}


CreateNumericContainerEnum example for C++ Builder

void __fastcall TForm1::btnCreateNumericContainerEnumClick(TObject *Sender)
{
TW_CAPABILITY twCap;
TW_UINT16 uItem[3];

FillMemory ( &twCap, sizeof(TW_CAPABILITY), 0 );

twCap.Cap= ICAP_XFERMECH;
twCap.ConType= TWON_ENUMERATION;

uItem[0]= TWSX_FILE;
uItem[1]= TWSX_MEMORY;
uItem[2]= TWSX_NATIVE;

LEADTwain1->CreateNumericContainerEnum ( &twCap, TWAINNUMERICTYPE_TW_UINT32, 3, TWSX_MEMORY, TWSX_NATIVE, (void*)uItem );

LEADTwain1->SetCapability ( &twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1->FreeContainer ( &twCap );
}


CreateNumericContainerRange example for C++ Builder

void __fastcall TForm1::btnCreateNumericContainerRangeClick(TObject *Sender)
{
TW_CAPABILITY twCap;

FillMemory ( &twCap, sizeof(TW_CAPABILITY), 0 );

twCap.Cap= ICAP_XRESOLUTION;
twCap.ConType= TWON_RANGE;

LEADTwain1->CreateNumericContainerRange ( &twCap, TWAINNUMERICTYPE_TW_FIX32, 100, 600, 100, 200, 300 );

LEADTwain1->SetCapability ( &twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1->FreeContainer ( &twCap );
}


FamilyName example for C++ Builder

void __fastcall TForm1::Button2Click(TObject *Sender)
{
L_INT n;
L_INT nCount;
AnsiString strBuffer;

nCount= LEADTwain1->SourceCount;
for (n= 0; n < nCount; n ++ )
{
strBuffer= "Source Name = " + LEADTwain1->SourceName [n] + "\n" +
"Product Family Name = " + LEADTwain1->FamilyName [n] + "\n" +
"Manufacturer Name = " + LEADTwain1->ManufacturerName [n] + "\n";
ShowMessage ( strBuffer );
}
}


FindFastConfig example for C++ Builder

int __fastcall TForm1::LEADTwain1FastConfigEvent(pFASTCONFIG pResConfig)
{
AnsiString strBuffer;

if ( pResConfig->bSuccess )
{
strBuffer= "Transfer Mode = "+ IntToStr(pResConfig->uTransferMode) + "\n" +
"File Format = " + IntToStr(pResConfig->nFileFormat) + "\n" +
"Buffer Size = " + IntToStr(pResConfig->ulBufferSize) + "\n" +
"Required Time = " + IntToStr(pResConfig->uTime) + "\n";
MessageBox ( Handle, strBuffer.c_str( ), "Result Scan Configuration...", MB_OK );
}
else
MessageBox ( Handle, "The tested configuration failed…", "Error!", MB_OK );
return SUCCESS;
}

void __fastcall TForm1::btnFindFastConfigClick(TObject *Sender)
{
L_INT nRet;
pFASTCONFIG pTestConfigs= NULL;
L_INT nTestConfigsCount= 0;
pFASTCONFIG pFastConfg;
L_INT nFastConfigCount;
FASTCONFIG BestConfig;
AnsiString strBuffer;

nRet= LEADTwain1->GetScanConfigs ( 1, LTWAIN_BUFFER_MODE, 5, &pFastConfg, &nFastConfigCount );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Error occurred while getting the scan configurations for the Memory transfer mode!!!", "Error!!!", MB_OK );
return;
};

FillMemory ( &BestConfig, sizeof(FASTCONFIG), 0 );
LEADTwain1->EnableFastConfigEvent = true;

nRet= LEADTwain1->FindFastConfig ( "c:\\TWAIN",
LTWAIN_SHOW_USER_INTERFACE,
1,
5,
pFastConfg,
nFastConfigCount,
&pTestConfigs,
&nTestConfigsCount,
&BestConfig );

if ( nRet == SUCCESS )
{
MessageBox ( Handle, "FindFastConfig method was successful.", "Notice", MB_OK );

strBuffer= "Transfer Mode = " + IntToStr(BestConfig.uTransferMode) + "\n" +
"File Format = " + IntToStr(BestConfig.nFileFormat) + "\n" +
"Buffer Size = " + IntToStr(BestConfig.ulBufferSize) + "\n" +
"Required Time = " + IntToStr(BestConfig.uTime);

MessageBox ( Handle, strBuffer.c_str( ), "Best Scan Configuration...", MB_OK );

LEADTwain1->FreeScanConfig ( &pTestConfigs, nTestConfigsCount );
}
else
{
MessageBox( Handle, "Error occurred in the FindFastConfig method!!!", "Error!!!", MB_OK );
LEADTwain1->FreeScanConfig ( &pFastConfg, nFastConfigCount );
}
}


GetCapability example for C++ Builder

void __fastcall TForm1::btnGetCapabilityClick(TObject *Sender)
{
L_INT nRet;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= ICAP_XFERMECH;
twCap.ConType= TWON_DONTCARE16;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}
LEADTwain1->FreeContainer ( &twCap );
}


GetCapabilityFromFile example for C++ Builder

void __fastcall TForm1::btnGetCapabilityFromFileClick(TObject *Sender)
{
L_INT nRet;
L_UINT uIndex;
L_UINT uCapCount;
pTW_CAPABILITY ptwCapability;
HTWAINTEMPLATEFILE hFile;

hFile= 0;
nRet= LEADTwain1->OpenTemplateFile ( &hFile, "c:\\test.ltt", LTWAIN_TEMPLATE_OPEN_READ );

if ( nRet == SUCCESS )
{
uCapCount= 0;
ptwCapability= NULL;
nRet= LEADTwain1->GetNumOfCapsInFile ( hFile, &uCapCount );

if ( nRet == SUCCESS )
{
for ( uIndex= 0; uIndex < uCapCount; uIndex ++ )
{
nRet= LEADTwain1->GetCapabilityFromFile ( hFile, &ptwCapability, uIndex );

if ( nRet == SUCCESS )
{
LEADTwain1->SetCapability ( ptwCapability, LTWAIN_CAPABILITY_SET );
}

if ( ptwCapability != NULL )
{
LEADTwain1->FreeContainer ( ptwCapability );
GlobalFreePtr ( ptwCapability );
}
}
}
LEADTwain1->CloseTemplateFile ( hFile );
}
}


GetExtendedImageInfo example for C++ Builder

int __fastcall TForm1::LEADTwain1AcquirePageEvent(TBITMAPHANDLE Bitmap)
{
L_INT i;
L_INT nRet;
TW_INFO twInfos[2];
TW_INFO twInfo;
pTW_EXTIMAGEINFO pExtImg= NULL;

twInfos[0].InfoID= TWEI_BARCODECOUNT;
twInfos[0].ItemType= TWTY_UINT32;

twInfos[1].InfoID= TWEI_BARCODETYPE;
twInfos[1].ItemType= TWTY_UINT32;

nRet= LEADTwain1->CreateExtendedInfo ( &pExtImg, twInfos, 2 );

if ( (nRet == SUCCESS) && ( pExtImg != NULL ))
{
if ( LEADTwain1->GetExtendedImageInfo ( pExtImg ) == SUCCESS )
{
for ( i= 0; i < 2; i ++ )
{
LEADTwain1->GetExtendedInfo ( pExtImg, i, &twInfo );
// Do processing to returned values
}

LEADTwain1->FreeExtendedImageInfoStructure ( &pExtImg );
}
}
return nRet;
}


GetNumericContainerBOOLValue example for C++ Builder

void __fastcall TForm1::btnGetNumericContainerBOOLValueClick(TObject *Sender)
{
L_INT nRet;
L_INT nItemType;
L_BOOL bValue;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= CAP_AUTOFEED;
twCap.ConType= TWON_ONEVALUE;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}

nRet= LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability item type", "ERROR", MB_OK );
}
else
{
if ( nItemType == TWTY_BOOL )
{
nRet= LEADTwain1->GetNumericContainerBOOLValue ( &twCap, 0, &bValue );

if ( nRet != SUCCESS )
MessageBox ( Handle, "Failed to get capability item value", "ERROR", MB_OK );
}
}
}


GetNumericContainerFIX32Value example for C++ Builder

void __fastcall TForm1::btnGetNumericContainerFIX32ValueClick(TObject *Sender)
{
L_INT nRet;
L_INT nItemType;
TW_FIX32 twFix;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= ICAP_BRIGHTNESS;
twCap.ConType= TWON_ONEVALUE;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}

nRet= LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability item type", "ERROR", MB_OK );
}
else
{
if ( nItemType == TWTY_FIX32 )
{
nRet= LEADTwain1->GetNumericContainerFIX32Value ( &twCap, 0, &twFix );
if ( nRet != SUCCESS )
MessageBox ( Handle, "Failed to get capability item value", "ERROR", MB_OK );
}
}
}


GetNumericContainerFRAMEValue example for C++ Builder

void __fastcall TForm1::btnGetNumericContainerFRAMEValueClick(TObject *Sender)
{
L_INT nRet;
L_INT nItemType;
TW_FRAME twFrame;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= ICAP_FRAMES;
twCap.ConType= TWON_ONEVALUE;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}

nRet= LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability item type", "ERROR", MB_OK );
}
else
{
if ( nItemType == TWTY_FRAME )
{
nRet= LEADTwain1->GetNumericContainerFRAMEValue ( &twCap, 0, &twFrame );
if ( nRet != SUCCESS )
MessageBox ( Handle, "Failed to get capability item value", "ERROR", MB_OK );
}
}
}


GetNumericContainerINTValue example for C++ Builder

void __fastcall TForm1::btnGetNumericContainerINTValueClick(TObject *Sender)
{
L_INT nRet;
L_INT nItemType;
L_INT nValue;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= CAP_XFERCOUNT;
twCap.ConType= TWON_ONEVALUE;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}

nRet= LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability item type", "ERROR", MB_OK );
}
else
{
if ( nItemType == TWTY_INT16 )
{
nRet= LEADTwain1->GetNumericContainerINTValue ( &twCap, 0, &nValue );
if ( nRet != SUCCESS )
MessageBox ( Handle, "Failed to get capability item value", "ERROR", MB_OK );
}
}
}


GetNumericContainerSTRINGValue example for C++ Builder

void __fastcall TForm1::btnGetNumericContainerSTRINGValueClick(TObject *Sender)
{
L_INT nRet;
L_INT nItemType;
TW_STR1024 twString;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= ICAP_HALFTONES;
twCap.ConType= TWON_ONEVALUE;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}

nRet= LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability item type", "ERROR", MB_OK );
}
else
{
if ( nItemType == TWTY_STR32 )
{
nRet= LEADTwain1->GetNumericContainerSTRINGValue ( &twCap, 0, twString );
if ( nRet != SUCCESS )
MessageBox ( Handle, "Failed to get capability item value", "ERROR", MB_OK );
}
}
}


GetNumericContainerUINTValue example for C++ Builder

void __fastcall TForm1::btnGetNumericContainerUINTValueClick(TObject *Sender)
{
L_INT nRet;
L_INT nItemType;
L_UINT uValue;
TW_CAPABILITY twCap;

// Fill the TW_CAPABILITY structure with values
twCap.Cap= ICAP_UNITS;
twCap.ConType= TWON_ONEVALUE;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return;
}

nRet= LEADTwain1->GetNumericContainerItemType ( &twCap, &nItemType );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability item type", "ERROR", MB_OK );
}
else
{
if ( nItemType == TWTY_UINT16 )
{
nRet= LEADTwain1->GetNumericContainerUINTValue ( &twCap, 0, &uValue );
if ( nRet != SUCCESS )
MessageBox ( Handle, "Failed to get capability item value", "ERROR", MB_OK );
}
}
}


GetNumericContainerValue example for C++ Builder

int TForm1::TwainGetCurrentValue ( )
{
L_INT nRet;
L_UINT16 * pVal= NULL;
TW_CAPABILITY twCap;

pVal= NULL;

twCap.Cap= ICAP_XFERMECH;
twCap.ConType= TWON_DONTCARE16;
nRet= LEADTwain1->GetCapability ( &twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet != SUCCESS )
{
MessageBox ( Handle, "Failed to get capability", "ERROR", MB_OK );
return FAILURE;
}

if ( twCap.ConType == TWON_ONEVALUE )
nRet= LEADTwain1->GetNumericContainerValue ( &twCap, 0, &pVal );
else
{
if ( twCap.ConType == TWON_ONEVALUE )
nRet= LEADTwain1->GetNumericContainerValue ( &twCap, LTWAIN_VALUE_CURRENT, &pVal );
}
return nRet;
}


GetProperties example for C++ Builder

int __fastcall TForm1::LEADTwain1SetPropertiesEvent(DWORD uCap,
int nStatus, Pointer pValue)
{
// Do your error notification or any other code here.

return SUCCESS;
}

void __fastcall TForm1::btnGetPropertiesClick(TObject *Sender)
{
L_INT nRet;
LTWAINPROPERTIES twProps;

// Initialize to zero
FillMemory ( &twProps, sizeof(LTWAINPROPERTIES), 0 );

// Get the current properties of the selected twain source
nRet= LEADTwain1->GetProperties ( &twProps, LTWAIN_PROPERTIES_GETCURRENT );

if ( nRet != SUCCESS )
{
return;
}

// Change transfer mode to File
twProps.DataTransfer.nTransferMode= TWSX_FILE;
StrCopy ( twProps.DataTransfer.szFileName, "c:\\temp\\Twain.bmp" );
twProps.DataTransfer.nScanFileFormat= TWFF_BMP;

// Set the new properties
LEADTwain1->EnableSetPropertiesEvent = true;
nRet= LEADTwain1->SetProperties ( &twProps, LTWAIN_PROPERTIES_SET );
if ( nRet != SUCCESS )
{
return;
}
}


IsAvailable example for C++ Builder

void __fastcall TForm1::btnIsAvailableClick(TObject *Sender)
{
L_INT nRet;
bool bAvailable;

/* Check to see if TWAIN is installed */
bAvailable= LEADTwain1->IsAvailable ( (L_HANDLE)Handle );
if ( bAvailable )
{
LEADTwain1->ManName = "LEAD Technologies, Inc.";
LEADTwain1->ProdFamily = "LEAD Test Applications";
LEADTwain1->Version = "Version 1.0";
LEADTwain1->AppName = "TWAIN Test Application";
nRet= LEADTwain1->InitSession ( (L_HANDLE)Handle );
if ( nRet != SUCCESS )
return;

LEADTwain1->Acquire ( LTWAIN_SHOW_USER_INTERFACE );

LEADTwain1->EndSession ( );
}
}


LockContainer example for C++ Builder

void TForm1::CheckConType ( pTW_CAPABILITY ptwCap )
{
pTW_ONEVALUE ptwOneVal= NULL;

if ( ptwCap->ConType == TWON_ONEVALUE )
{
LEADTwain1->LockContainer ( ptwCap, &ptwOneVal );
if ( ptwOneVal != NULL )
{
// Do processing
LEADTwain1->UnlockContainer ( ptwCap );
}
}
}


QueryProperty example for C++ Builder

int TForm1::CheckCapability ( L_INT16 nValue )
{
L_INT nRet;
L_INT nIndex;
pTW_FIX32 ptwFixVal;
TW_CAPABILITY twCap;
pLTWAINPROPERTYQUERY pltQuery= NULL;

// Query capability possible values
nRet= LEADTwain1->QueryProperty ( ICAP_XRESOLUTION, &pltQuery );

if ( nRet != SUCCESS )
{
return nRet;
}

switch (pltQuery->uType)
{
case TWON_ONEVALUE:
{
if ( pltQuery->pltwOneValue->ItemType == TWTY_FIX32 )
{
ptwFixVal= (pTW_FIX32)(pltQuery->pltwOneValue->Item);
if ( ptwFixVal->Whole == nValue )
{
LEADTwain1->FreePropQueryStructure ( &pltQuery );
return SUCCESS;
}
}
}
break;

case TWON_ENUMERATION:
{
if ( pltQuery->pltwEnumeration->ItemType == TWTY_FIX32 )
{
twCap.ConType= TWON_ENUMERATION;
twCap.Cap= ICAP_XRESOLUTION;
twCap.hContainer= (TW_HANDLE)GlobalHandle (pltQuery->pltwEnumeration);
for (nIndex= 0; nIndex < (L_INT)pltQuery->pltwEnumeration->NumItems; nIndex ++ )
{
LEADTwain1->GetNumericContainerFIX32Value ( &twCap, nIndex, ptwFixVal );
if ( ptwFixVal->Whole == nValue )
{
LEADTwain1->FreePropQueryStructure ( &pltQuery );
return SUCCESS;
}
}
}
}
break;
}

LEADTwain1->FreePropQueryStructure ( &pltQuery );
return FAILURE;
}


SelectedFamilyName example for C++ Builder

void __fastcall TForm1::Button3Click(TObject *Sender)
{
AnsiString strBuffer;
strBuffer= "Source Name = " + LEADTwain1->SelectedSourceName + "\n" +
"Product Family Name = " + LEADTwain1->SelectedFamilyName + "\n" +
"Manufacturer Name = " + LEADTwain1->SelectedManufacturerName + "\n";
ShowMessage ( strBuffer );
}


ShowTemplateDlg example for C++ Builder

int __fastcall TForm1::LEADTwain1SaveCapabilityEvent(
pTW_CAPABILITY pCapability)
{
// Do pre operations on data to save

return SUCCESS;
}

void __fastcall TForm1::btnShowTemplateDlgClick(TObject *Sender)
{
L_INT nRet;

LEADTwain1->EnableSaveCapabilityEvent = true;
nRet= LEADTwain1->ShowTemplateDlg ( "c:\\Test.ltt" );
if ( nRet != SUCCESS )
{
// Error check procedure
}
}


SourceName example for C++ Builder

void __fastcall TForm1::Button1Click(TObject *Sender)
{
L_INT n;
L_INT nCount;
AnsiString strName;

nCount= LEADTwain1->SourceCount;
for (n= 0; n < nCount; n ++ )
{
strName= LEADTwain1->SourceName [n];
ShowMessage ( strName );
//Do More processing on source name

}
}


UnlockSupport example for C++ Builder

/*Unlock Document support.*/
/*Note that this is a sample key, which will not work in your toolkit.*/
LEADTwain1->UnlockSupport ( L_SUPPORT_DOCUMENT, "TestKey" );
if ( LEADTwain1->IsSupportLocked (L_SUPPORT_DOCUMENT) )
ShowMessage("Document Support Locked");
else
ShowMessage("Document Support is available");


Tutorial for Delphi Programmers

The following topics provide brief and simple examples to help you learn how to use the LEAD VCL Twain Control.

Note: These tutorial examples are intended to be easy to understand and easy to test. The example programs in the EXAMPLES subdirectory provide more in depth design and more detailed code.

Acquiring an Image

Using the Fast TWAIN Feature

Get a Fast Twain Scan from a Scanner

Set/Get a Twain Capability


Acquiring an Image (Delphi)

Take the following steps to start a project and to add some code that acquires an image from a TWAIN source:

Take the following steps to create and run a program that implement LEADTOOLS TWAIN features. Remember, the purpose of the TWAIN tutorial is to provide you a quick and easy way to generate a TWAIN program. For more in depth TWAIN programming, refer to the TWAIN demo.

1. | Start Delphi.
2. | On the Delphi toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCLbefore continuing with this tutorial.
3. | Select the LEAD Main control on the VCL toolbar. Size and position the control, as you want it to appear at run time.
4. | Select the LEAD Twain control on the LEADTOOLS toolbar. Place the control anywhere on the form.
5. | At the top of your form, add 7 Buttons and name them as follows:
 | Name | Caption
 | btnOK | OK
 | btnCancel | Cancel
 | btnAcquire | Acquire
 | btnSelectSource | Select Source
 | btnNative | Native
 | btnMemBuf | Memory Buffered
 | btnFile | File
6. | Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

procedure TForm1.FormCreate(Sender: TObject);
begin
LEADTwain1.InitSession ( Handle ) ;
end;

7.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LEADTwain1.EndSession ( );
end;

8.

Handle the btnOK OnClick event, and code the btnOKClick procedure as follows.

procedure TForm1.btnOKClick(Sender: TObject);
begin
Close ( );
end;

9.

Handle the btnCancel OnClick event, and code the btnCancelClick procedure as follows.

procedure TForm1.btnCancelClick(Sender: TObject);
begin
Close ( );
end;

10.

Handle the btnAcquire OnClick event, and code the btnAcquireClick procedure as follows:

procedure TForm1.btnAcquireClick(Sender: TObject);
begin
LEADTwain1.Acquire ( LTWAIN_SHOW_USER_INTERFACE );
end;

11.

Handle the btnSelectSource OnClick event, and code the btnSelectSourceClick procedure as follows:

procedure TForm1.btnSelectSourceClick(Sender: TObject);
begin
LEADTwain1.SelectSource ( );
end;

12.

Handle the btnNative button’s OnClick event, and code the btnNativeClick procedure as Follows:

procedure TForm1.btnNativeClick(Sender: TObject);
var
nRet: L_INT;
twProps: LTWAINPROPERTIES;
begin
FillMemory ( @twProps, Sizeof(LTWAINPROPERTIES), 0 );
nRet:= LEADTwain1.GetProperties ( @twProps, LTWAIN_PROPERTIES_GETCURRENT );
if ( nRet <> SUCCESS ) then
Exit;
twProps.DataTransfer.nTransferMode:= TWSX_NATIVE;

LEADTwain1.SetProperties ( @twProps, LTWAIN_PROPERTIES_SET );
end;

13.

Handle the btnMemBuf button’s OnClick event, and code the btnMemBufClick procedure as follows:

procedure TForm1.btnMemBufClick(Sender: TObject);
var

nRet: L_INT;
twProps: LTWAINPROPERTIES;
begin
FillMemory ( @twProps, Sizeof(LTWAINPROPERTIES), 0 );
nRet:= LEADTwain1.GetProperties ( @twProps, LTWAIN_PROPERTIES_GETCURRENT );
if ( nRet <> SUCCESS ) then
Exit;
twProps.DataTransfer.nTransferMode:= TWSX_MEMORY;
twProps.DataTransfer.nBufMemCompression:= TWCP_NONE;
LEADTwain1.SetProperties ( @twProps, LTWAIN_PROPERTIES_SET );
end;

14.

Handle the btnFile OnClick event, and code the btnFileClick procedure as follows:

procedure TForm1.btnFileClick(Sender: TObject);
var
nRet: L_INT;
twProps: LTWAINPROPERTIES;
begin
FillMemory ( @twProps, Sizeof(LTWAINPROPERTIES), 0 );
nRet:= LEADTwain1.GetProperties ( @twProps, LTWAIN_PROPERTIES_GETCURRENT );
if ( nRet <> SUCCESS ) then
Exit;
twProps.DataTransfer.nTransferMode:= TWSX_NATIVE;
StrCopy ( twProps.DataTransfer.szFileName, 'c:\twain.bmp' );
LEADTwain1.SetProperties ( @twProps, LTWAIN_PROPERTIES_SET );
end;

15.

Handle the LEADTwain1 OnAcquirePageEvent event, and code the LEADTwain1AcquirePageEvent Function as follows:

function TForm1.LEADTwain1AcquirePageEvent(Bitmap: TBITMAPHANDLE): Integer;
begin
ShowMessage ( 'Acquisition of Image Done' );
LEADImage1.InsertBitmapListItem ( LST_APPEND, Bitmap );
Result:= SUCCESS;
end;

16. | At the beginning of the Unit1 file, add LEADDef, and LEADTyp to the uses section.
17. | Run your program to test it.


Using the Fast TWAIN Feature (Delphi)

Take the following steps to start a project and to add some code that acquires the images using Fast Twain:

1. | Start Delphi.
2. | On the Delphi toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
3. | Select the LEAD Twain control on the LEADTOOLS toolbar. Place the control anywhere on the form.
4. | At the top of your form, add a check box and name it as follows:
 | Name | Caption
 | chkUseBufferSize | Use Buffer Size
5. | Add 2 radio buttons to your form, and name them as follows:
 | Name | Caption
 | rbNative | Native Mode
 | rbMemory | Memory Mode
6. | Add 1 button to your form, and name it as follows:
 | Name | Caption
 | btnAcquire | Fast Acquire
7. | Add 2 Edit boxes to your form, and name them as follows:
 | Name |
 | edtFName |
 | edtBufferSize |
8. | Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

procedure TForm1.FormCreate(Sender: TObject);
begin
LEADTwain1.UnlockSupport ( L_SUPPORT_DOCUMENT, 'TestKey' );
LEADTwain1.InitSession ( Handle ) ;
LEADTwain1.EnableMethodErrors:= False;
rbMemory.Checked:= True;
end;

9. Handle the Form1 OnClose event, and code the FormClose procedure as follows:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LEADTwain1.EndSession ( );
end;

10. Handle the btnAcquire control's OnClick event, and code the btnAcquireClick procedure as follows.

procedure TForm1.btnAcquireClick(Sender: TObject);
var
nRet: L_INT;
nFormat: L_INT;
uTransferMode: L_UINT;
bMemory: Boolean;
begin
bMemory:= rbMemory.Checked;
if ( bMemory ) then
begin
uTransferMode:= LTWAIN_BUFFER_MODE;
nFormat:= FILE_CCITT_GROUP4;
end
else
begin
uTransferMode:= LTWAIN_NATIVE_MODE;
nFormat:= FILE_TIF;
end;

nRet:= LEADTwain1.AcquireMulti ( edtFName.Text,
LTWAIN_SHOW_USER_INTERFACE Or LTWAIN_USE_THREAD_MODE,
uTransferMode,
nFormat,
1,
TRUE,
StrToInt(edtBufferSize.Text),
Not chkUseBufferSize.Checked );

if ( nRet = SUCCESS ) then
ShowMessage ( 'Fast Scanning process done successfully...' )
else
begin
ShowMessage ( 'AcquireMulti failed, Error = ' + IntToStr(nRet) );
end;
end;

11. At the beginning of the Unit1 file, add LEADDef, and LEADTyp to the uses section.

12. Run your program to test it.


Get a Fast Twain Scan from a Scanner (Delphi)

Take the following steps to get fast twain scan using the LEADTOOLS Fast TWAIN features:

1. | Start Delphi.
2. | On the Delphi toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
3. | Select and Add the LEAD TWAIN control from the VCL toolbar to your Main Form.
4. | Add 3 buttons to your form and name them as follows:
 | Name | Caption
 | btnSelectSource | Select Source
 | btnFindFastConfig | Find Fast Config
 | btnAcquireFastConfig | Acquire Fast Config
5. | Define the following variable in the private section of Form1:

BestConfig: FASTCONFIG;

6.

Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

procedure TForm1.FormCreate(Sender: TObject);

var

nRet: L_INT;

begin

LEADTwain1.EnableMethodErrors := False;

LEADTwain1.ManName:= 'LEAD Technologies, Inc.';

LEADTwain1.ProdFamily:= 'LEAD Test Applications';

LEADTwain1.Version:= 'Version 1.0';

LEADTwain1.AppName:= 'TWAIN Test Application';

nRet:= LEADTwain1.InitSession ( Handle );

if ( nRet <> SUCCESS ) then

begin

ShowMessage ( 'Failure to Initialize TWAIN' );

Exit;

end;

LEADTwain1.EnableMethodErrors := True;

{ Unlock Document support.

Note that this is a sample key, which will not work in your toolkit. }

LEADTwain1.UnlockSupport ( L_SUPPORT_DOCUMENT, ‘TestKey' );

end;

7.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);

begin

LEADTwain1.EndSession ( );

end;

8.

Handle the btnSelectSource OnClick event, and code the btnSelectSourceClick procedure as follows:

procedure TForm1.btnSelectSourceClick(Sender: TObject);

begin

LEADTwain1.SelectSource ( );

end;

9.

Handle the btnFindFastConfig OnClick event, and code the btnFindFastConfigClick procedure as follows:

procedure TForm1.btnFindFastConfigClick(Sender: TObject);

var

nRet: L_INT;

nTestConfigsCount: L_INT;

pTestConfigs: pFASTCONFIG;

begin

nTestConfigsCount:= 0;

pTestConfigs:= Nil;

LEADTwain1.EnableMethodErrors := False;

nRet:= LEADTwain1.FindFastConfig ( 'c:\temp', LTWAIN_SHOW_USER_INTERFACE Or LTWAIN_USE_THREAD_MODE,

8,

5,

Nil,

0,

@pTestConfigs,

@nTestConfigsCount,

@BestConfig );

if (nRet = SUCCESS) then

ShowMessage ( 'Find Fast Configuration process completed' )

else

ShowMessage ( 'An error occurred during the Finding Fast Configuration process.' );

LEADTwain1.EnableMethodErrors := True;

end;

10.

Handle the btnAcquireFastConfig OnClick event, and code the btnAcquireFastConfigClick procedure as follows:

procedure TForm1.btnAcquireFastConfigClick(Sender: TObject);

var

nRet: L_INT;

begin

LEADTwain1.EnableMethodErrors := False;

nRet:= LEADTwain1.AcquireMulti ( 'c:\temp\testconfig.tif',

LTWAIN_SHOW_USER_INTERFACE Or LTWAIN_USE_THREAD_MODE,

BestConfig.uTransferMode,

BestConfig.nFileFormat,

BestConfig.nBitsPerPixel,

True,

BestConfig.ulBufferSize,

True );

if ( nRet = SUCCESS ) then

MessageBox ( Handle, 'Image acquisition using the Fast TWAIN Configuration is completed.', 'Fast Config', MB_OK )

else

MessageBox ( Handle, 'An error occurred while acquiring images using the Fast TWAIN Configuration.', 'Fast Config', MB_OK );

LEADTwain1.EnableMethodErrors := True;

end;

11. | At the beginning of the Unit1 file, add LEADTyp and LEADDef to the uses section.
12. | Run your program to test it.


Set/Get a Twain Capability (Delphi)

Take the following steps to start a project and to add some code to use the Get/Set capability methods and then acquire your image using the newly set capability:

1. | Start Delphi.
2. | On the Delphi toolbar, click the LEADTOOLS tab. If you have used a LEAD VCL control before, the icon appears on the toolbar. Otherwise, refer to Installing VCL before continuing with this tutorial.
3. | Select the LEAD Main control on the VCL toolbar. Size and position the control, as you want it to appear at run time.
4. | Select the LEAD Twain control on the LEADTOOLS toolbar. Place the control anywhere on the form.
5. | At the top of your form, add 5 button controls and name them as follows:
 | Name | Caption
 | btnSelectSource | Select Source
 | btnGetCapability | Get Capability
 | btnSetCapability | Set Capability
 | btnSetBrightness | Set Brightness
 | btnAcquire | Acquire
6. | Add the following variables declaration to the Form1 private section.

uItemValue: L_UINT;
twCap: TW_CAPABILITY;

7.

Handle the Form1 OnCreate event, and code the FormCreate procedure as follows:

procedure TForm1.FormCreate(Sender: TObject);
begin
LEADTwain1.InitSession ( Handle );
LEADTwain1.EnableMethodErrors:= False;

{ Unlock Document support.
Note that this is a sample key, which will not work in your toolkit. }
LEADTwain1.UnlockSupport ( L_SUPPORT_DOCUMENT, 'TestKey' );
end;

8.

Handle the Form1 OnClose event, and code the FormClose procedure as follows:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
LEADTwain1.EndSession ( );
end;

9.

Handle the btnSelectSource OnClick event, and code the btnSelectSourceClick procedure as follows.

procedure TForm1.btnSelectSourceClick(Sender: TObject);
begin
LEADTwain1.SelectSource ( );
end;

10.

Handle the btnGetCapability OnClick event, and code the btnGetCapabilityClick procedure as follows.

procedure TForm1.btnGetCapabilityClick(Sender: TObject);
var
nItemType: L_INT;
begin
twCap.Cap:= ICAP_XFERMECH;
twCap.ConType:= TWON_DONTCARE16;
twCap.hContainer:= 0;
LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );

LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );

if ( nItemType = TWTY_UINT16 ) then
LEADTwain1.GetNumericContainerUINTValue ( @twCap, 0, @uItemValue )
else
MessageBox ( Handle, 'Returned bad item type', 'Get Item Type', MB_OK );
end;

11.

Handle the btnSetCapability OnClick event, and code the btnSetCapabilityClick procedure as follows.

procedure TForm1.btnSetCapabilityClick(Sender: TObject);
var
twSetCap: TW_CAPABILITY;
begin
if ( uItemValue <> TWSX_NATIVE ) then
begin
twSetCap.Cap:= ICAP_XFERMECH;
twSetCap.ConType:= TWON_ONEVALUE;

LEADTwain1.CreateNumericContainerOneValue ( @twSetCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE );

LEADTwain1.SetCapability ( @twSetCap, LTWAIN_CAPABILITY_SET );
LEADTwain1.FreeContainer ( @twSetCap );
end
else
MessageBox ( Handle, 'The Transfer mode is Native', 'Set Capability', MB_OK );
end;

12.

Handle the btnSetBrightness OnClick event, and code the btnSetBrightnessClick procedure as follows:

procedure TForm1.btnSetBrightnessClick(Sender: TObject);
var
nRet: L_INT;
twFix32: TW_FIX32;
ptwOneVal: pTW_ONEVALUE;
twBrightnessCap: TW_CAPABILITY;

begin
twBrightnessCap.Cap:= ICAP_BRIGHTNESS;
twBrightnessCap.ConType:= TWON_ONEVALUE;

nRet:= LEADTwain1.GetCapability ( @twBrightnessCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet = SUCCESS ) then
begin

ptwOneVal:= pTW_ONEVALUE(GlobalLock(twCap.hContainer));

CopyMemory ( @twFix32, @ptwOneVal.Item, sizeof(TW_FIX32) );

GlobalUnlock( twBrightnessCap.hContainer );
GlobalFree( twBrightnessCap.hContainer );
twBrightnessCap.hContainer:= 0;

if ( twFix32.Whole <> 128 ) then
begin
twFix32.Whole:= 128;
twFix32.Frac:= 0;
end;

twBrightnessCap.Cap:= ICAP_BRIGHTNESS;
twBrightnessCap.ConType:= TWON_ONEVALUE;
twBrightnessCap.hContainer:= GlobalAlloc ( GHND, sizeof(TW_ONEVALUE) + sizeof(TW_FIX32) );

ptwOneVal:= pTW_ONEVALUE(GlobalLock(twCap.hContainer));

ptwOneVal.ItemType:= TWTY_FIX32;
CopyMemory ( @ptwOneVal.Item, @twFix32, sizeof(TW_FIX32) );
GlobalUnlock ( twBrightnessCap.hContainer );

LEADTwain1.SetCapability ( @twBrightnessCap, LTWAIN_CAPABILITY_SET );
end;
end;

13.

Handle the btnAcquire OnClick event, and code the btnAcquireClick procedure as follows.

procedure TForm1.btnAcquireClick(Sender: TObject);
begin
LEADTwain1.Acquire ( LTWAIN_SHOW_USER_INTERFACE );
end;

14.

Handle the LEADTwain1 OnAcquirePageEvent event, and code the LEADTwain1AcquirePageEvent Function as follows:

function TForm1.LEADTwain1AcquirePageEvent(Bitmap: TBITMAPHANDLE): Integer;
begin
LEADImage1.Bitmap:= Bitmap;
Result:= SUCCESS;
end;

15. | At the beginning of the Unit1 file, add LEADDef, and LEADTyp to the uses section.
16. | Run your program to test it.


Miscellaneous Examples (Delphi 4.0)

You can test the following examples by either adding a command button to one of the previous lessons in the tutorial and pasting the sample code in the Click procedure, or by cutting and pasting event code into the appropriate event in a lesson.

Acquire example for Delphi

AcquireMulti example for Delphi

AddCapabilityToFile example for Delphi

AcquireSourceName example for Delphi

CreateNumericContainerArray example for Delphi

CreateNumericContainerEnum example for Delphi

CreateNumericContainerRange example for Delphi

FamilyName example for Delphi

FindFastConfig example for Delphi

GetCapability example for Delphi

GetCapabilityFromFile example for Delphi

GetExtendedImageInfo example for Delphi

GetNumericContainerBOOLValue example for Delphi

GetNumericContainerFIX32Value example for Delphi

GetNumericContainerFRAMEValue example for Delphi

GetNumericContainerINTValue example for Delphi

GetNumericContainerSTRINGValue example for Delphi

GetNumericContainerUINTValue example for Delphi

GetNumericContainerValue example for Delphi

GetProperties example for Delphi

IsAvailable example for Delphi

LockContainer example for Delphi

QueryProperty example for Delphi

SelectedFamilyName example for Delphi

ShowTemplateDlg example for Delphi

SourceName example for Delphi

UnlockSupport example for Delphi


Acquire example for Delphi

Function TForm1.LEADTwain1AcquirePageEvent(Bitmap: TBITMAPHANDLE): Integer;
begin
if ( Bitmap <> 0 ) then
LEADImage1.Bitmap:= Bitmap;
Result:= SUCCESS;
end;

procedure TForm1.btnAcquireClick(Sender: TObject);
var
nRet: L_INT;
twCap: TW_CAPABILITY;
begin
// Show the Twain Select Source UI
nRet:= LEADTwain1.SelectSource ( );
if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Error occurred while selecting the source.', 'ERROR', MB_OK );

twCap.Cap:= ICAP_XFERMECH;
twCap.ConType:= TWON_ONEVALUE;

LEADTwain1.CreateNumericContainerOneValue ( @twCap, TWAINNUMERICTYPE_TW_UINT16, TWSX_NATIVE );

LEADTwain1.SetCapability ( @twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1.FreeContainer ( @twCap );

LEADTwain1.EnableAcquirePageEvent:= True;
nRet:= LEADTwain1.Acquire ( LTWAIN_SHOW_USER_INTERFACE );
if ( nRet = SUCCESS ) then
MessageBox ( Handle, 'The image acquisition process completed.', 'Notice', MB_OK )
else
MessageBox ( Handle, 'The image acquisition process failed!', 'Error', MB_OK );
end;


AcquireMulti example for Delphi

procedure TForm1.LEADTwain1AcquireMultiEvent(nPage: Integer;
strFileName: String; bFinishScan: Boolean);
var
strBuffer: String;
begin
if ( bFinishScan ) then
begin
strBuffer:= 'The page # ' + IntToStr(nPage) + ' is scanned and saved to file name ' + strFileName;
MessageBox ( Handle, PChar(strBuffer), 'Notice', MB_OK );
end;
end;

procedure TForm1.btnAcquireMultiClick(Sender: TObject);
var
nRet: L_INT;
begin
LEADTwain1.EnableAcquireMultiEvent:= True;
nRet:= LEADTwain1.AcquireMulti ( 'c:\TWAIN\test.tif',
LTWAIN_SHOW_USER_INTERFACE,
LTWAIN_BUFFER_MODE,
FILE_TIF,
1,
TRUE,
0,
True );

if ( nRet = SUCCESS ) then
MessageBox ( Handle, 'Fast Twain function was successful', 'Notice', MB_OK )
else
MessageBox ( Handle, 'Error occurred during fast Twain function!!!', 'Error!!!', MB_OK );
end;


AcquireSourceName example for Delphi

procedure TForm1.Button1Click(Sender: TObject);
var
nRet: Integer;
begin
LEADTwain1.AcquireSourceName:= 'TWAIN Source Name';
nRet:= LEADTwain1.Acquire (LTWAIN_SHOW_USER_INTERFACE);
if(nRet <> SUCCESS)then
ShowMessage('Error acquiring from source');
end;


AddCapabilityToFile example for Delphi

var
hFile: HTWAINTEMPLATEFILE;
procedure TForm1.btnAddCapabilityToFileClick(Sender: TObject);
var
nRet: L_INT;
begin
nRet:= LEADTwain1.OpenTemplateFile ( @hFile, 'c:\temp.ltt', LTWAIN_TEMPLATE_OPEN_WRITE );
if ( nRet = SUCCESS ) then
begin
LEADTwain1.EnableEnumCapabilityEvent:= True;
LEADTwain1.EnumCapabilities ( LTWAIN_CAPABILITY_GETCURRENT );
LEADTwain1.CloseTemplateFile ( hFile );
end;
end;

Function TForm1.LEADTwain1EnumCapabilityEvent(uCap: Cardinal;
pCapability: pTW_CAPABILITY): Integer;
begin
Result:= LEADTwain1.AddCapabilityToFile ( hFile, pCapability );
end;


CreateNumericContainerArray example for Delphi

procedure TForm1.btnCreateNumericContainerArrayClick(Sender: TObject);
var
uItem: Array [ 0..2 ] of TW_UINT16;
twCap: TW_CAPABILITY;
begin
FillMemory ( @twCap, sizeof(TW_CAPABILITY), 0 );

twCap.Cap:= ICAP_FILTER;
twCap.ConType:= TWON_ARRAY;

uItem[0]:= TWFT_RED;
uItem[1]:= TWFT_GREEN;
uItem[2]:= TWFT_BLUE;

LEADTwain1.CreateNumericContainerArray ( @twCap, TWAINNUMERICTYPE_TW_UINT32, 3, L_PVOID(@uItem) );

LEADTwain1.SetCapability ( @twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1.FreeContainer ( @twCap );
end;


CreateNumericContainerEnum example for Delphi

procedure TForm1.btnCreateNumericContainerEnumClick(Sender: TObject);
var
twCap: TW_CAPABILITY;
uItem: Array [ 0..2 ] of TW_UINT16;
begin

FillMemory ( @twCap, sizeof(TW_CAPABILITY), 0 );

twCap.Cap:= ICAP_XFERMECH;
twCap.ConType:= TWON_ENUMERATION;

uItem[0]:= TWSX_FILE;
uItem[1]:= TWSX_MEMORY;
uItem[2]:= TWSX_NATIVE;

LEADTwain1.CreateNumericContainerEnum ( @twCap, TWAINNUMERICTYPE_TW_UINT32, 3, TWSX_MEMORY, TWSX_NATIVE, L_PVOID(@uItem) );

LEADTwain1.SetCapability ( @twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1.FreeContainer ( @twCap );
end;


CreateNumericContainerRange example for Delphi

procedure TForm1.btnCreateNumericContainerRangeClick(Sender: TObject);
var
twCap: TW_CAPABILITY;
begin
FillMemory ( @twCap, sizeof(TW_CAPABILITY), 0 );

twCap.Cap:= ICAP_XRESOLUTION;
twCap.ConType:= TWON_RANGE;

LEADTwain1.CreateNumericContainerRange ( @twCap, TWAINNUMERICTYPE_TW_FIX32, 100, 600, 100, 200, 300 );

LEADTwain1.SetCapability ( @twCap, LTWAIN_CAPABILITY_SET );
LEADTwain1.FreeContainer ( @twCap );
end;


FamilyName example for Delphi

procedure TForm1.Button2Click(Sender: TObject);
var
n: L_INT;
nCount: L_INT;
strBuffer: String;
begin
nCount:= LEADTwain1.SourceCount;
for n:= 0 To nCount - 1 do
begin
strBuffer:= 'Source Name = ' + LEADTwain1.SourceName [n] + Chr(13) +
'Product Family Name = ' + LEADTwain1.FamilyName [n] + Chr(13) +
'Manufacturer Name = ' + LEADTwain1.ManufacturerName [n] + Chr(13); ShowMessage ( strBuffer ); end;
end;


FindFastConfig example for Delphi

Function TForm1.LEADTwain1FastConfigEvent(
pResConfig: pFASTCONFIG): Integer;
var
strBuffer: String;
begin
if ( pResConfig.bSuccess ) then
begin
strBuffer:= 'Transfer Mode = '+ IntToStr(pResConfig.uTransferMode) + Chr(13) +
'File Format = ' + IntToStr(pResConfig.nFileFormat) + Chr(13) +
'Buffer Size = ' + IntToStr(pResConfig.ulBufferSize) + Chr(13) +
'Required Time = ' + IntToStr(pResConfig.uTime) + Chr(13);

MessageBox ( Handle, PChar(strBuffer), 'Result Scan Configuration...', MB_OK );
end
else
MessageBox ( Handle, 'The tested configuration failed…', 'Error!', MB_OK );
Result:= SUCCESS;
end;

procedure TForm1.btnFindFastConfigClick(Sender: TObject);
var
nRet: L_INT;
pTestConfigs: pFASTCONFIG;
nTestConfigsCount: L_INT;
pFastConfg: pFASTCONFIG;
nFastConfigCount: L_INT;
BestConfig: FASTCONFIG;
strBuffer: String;
begin
pTestConfigs:= Nil;
nTestConfigsCount:= 0;
nRet:= LEADTwain1.GetScanConfigs ( 1, LTWAIN_BUFFER_MODE, 5, @pFastConfg, @nFastConfigCount );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Error occurred while getting the scan configurations for the Memory transfer mode!!!', 'Error!!!', MB_OK );
Exit;
end;

FillMemory ( @BestConfig, sizeof(FASTCONFIG), 0 );
LEADTwain1.EnableFastConfigEvent:= True;

nRet:= LEADTwain1.FindFastConfig ( 'c:\TWAIN',
LTWAIN_SHOW_USER_INTERFACE,
1,
5,
pFastConfg,
nFastConfigCount,
@pTestConfigs,
@nTestConfigsCount,
@BestConfig );

if ( nRet = SUCCESS ) then
begin
MessageBox ( Handle, 'FindFastConfig method was successful.', 'Notice', MB_OK );

strBuffer:= 'Transfer Mode = ' + IntToStr(BestConfig.uTransferMode) + Chr(13) +
'File Format = ' + IntToStr(BestConfig.nFileFormat) + Chr(13) +
'Buffer Size = ' + IntToStr(BestConfig.ulBufferSize) + Chr(13) +
'Required Time = ' + IntToStr(BestConfig.uTime);

MessageBox ( Handle, PChar(strBuffer), 'Best Scan Configuration...', MB_OK );

LEADTwain1.FreeScanConfig ( @pTestConfigs, nTestConfigsCount );
end
else
begin
MessageBox( Handle, 'Error occurred in the FindFastConfig method!!!', 'Error!!!', MB_OK );
LEADTwain1.FreeScanConfig ( @pFastConfg, nFastConfigCount );
end;
end;


GetCapability example for Delphi

procedure TForm1.btnGetCapabilityClick(Sender: TObject);
var
nRet: L_INT;
twCap: TW_CAPABILITY;
begin
// Fill the TW_CAPABILITY structure with values
twCap.Cap:= ICAP_XFERMECH;
twCap.ConType:= TWON_DONTCARE16;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;
LEADTwain1.FreeContainer ( @twCap );
end;


GetCapabilityFromFile example for Delphi

procedure TForm1.btnGetCapabilityFromFileClick(Sender: TObject);
var
nRet: L_INT;
uIndex: L_UINT;
uCapCount: L_UINT;
ptwCapability: pTW_CAPABILITY;
hFile: HTWAINTEMPLATEFILE;
begin
hFile:= 0;
nRet:= LEADTwain1.OpenTemplateFile ( @hFile, 'c:\test.ltt', LTWAIN_TEMPLATE_OPEN_READ );

if ( nRet = SUCCESS ) then
begin
uCapCount:= 0;
ptwCapability:= Nil;
nRet:= LEADTwain1.GetNumOfCapsInFile ( hFile, @uCapCount );

if ( nRet = SUCCESS ) then
begin
for uIndex:= 0 to uCapCount -1 do
begin
nRet:= LEADTwain1.GetCapabilityFromFile ( hFile, @ptwCapability, uIndex );

if ( nRet = SUCCESS ) then
begin
LEADTwain1.SetCapability ( ptwCapability, LTWAIN_CAPABILITY_SET );
end;

if ( ptwCapability <> Nil ) then
begin
LEADTwain1.FreeContainer ( ptwCapability );
GlobalFreePtr ( ptwCapability );
end;
end;
end;
LEADTwain1.CloseTemplateFile ( hFile );
end;
end;


GetExtendedImageInfo example for Delphi

Function TForm1.LEADTwain1AcquirePageEvent(Bitmap: TBITMAPHANDLE): Integer;
var
i: L_INT;
nRet: L_INT;
twInfos: Array [ 0..1 ] of TW_INFO;
twInfo: TW_INFO;
pExtImg: pTW_EXTIMAGEINFO;
begin
pExtImg:= Nil;

twInfos[0].InfoID:= TWEI_BARCODECOUNT;
twInfos[0].ItemType:= TWTY_UINT32;

twInfos[1].InfoID:= TWEI_BARCODETYPE;
twInfos[1].ItemType:= TWTY_UINT32;

nRet:= LEADTwain1.CreateExtendedInfo ( @pExtImg, @twInfos, 2 );

if ( (nRet = SUCCESS) And ( pExtImg <> Nil )) then
begin
if ( LEADTwain1.GetExtendedImageInfo ( pExtImg ) = SUCCESS ) then
begin
for i:= 0 to 2 do
begin
LEADTwain1.GetExtendedInfo ( pExtImg, i, @twInfo );
// Do processing to returned values
end;

LEADTwain1.FreeExtendedImageInfoStructure ( @pExtImg );
end;
end;
Result:= nRet;
end;


GetNumericContainerBOOLValue example for Delphi

procedure TForm1.btnGetNumericContainerBOOLValueClick(Sender: TObject);
var
nRet: L_INT;
nItemType: L_INT;
bValue: L_BOOL;
twCap: TW_CAPABILITY;
begin

// Fill the TW_CAPABILITY structure with values
twCap.Cap:= CAP_AUTOFEED;
twCap.ConType:= TWON_ONEVALUE;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;

nRet:= LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability item type', 'ERROR', MB_OK );
end
else
begin
if ( nItemType = TWTY_BOOL ) then
begin
nRet:= LEADTwain1.GetNumericContainerBOOLValue ( @twCap, 0, @bValue );

if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Failed to get capability item value', 'ERROR', MB_OK );
end;
end;
end;


GetNumericContainerFIX32Value example for Delphi

procedure TForm1.btnGetNumericContainerFIX32ValueClick(Sender: TObject);
var
nRet: L_INT;
nItemType: L_INT;
twFix: TW_FIX32;
twCap: TW_CAPABILITY;
begin
// Fill the TW_CAPABILITY structure with values
twCap.Cap:= ICAP_BRIGHTNESS;
twCap.ConType:= TWON_ONEVALUE;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;

nRet:= LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability item type', 'ERROR', MB_OK );
end
else
begin
if ( nItemType = TWTY_FIX32 ) then
begin
nRet:= LEADTwain1.GetNumericContainerFIX32Value ( @twCap, 0, @twFix );
if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Failed to get capability item value', 'ERROR', MB_OK );
end;
end;
end;


GetNumericContainerFRAMEValue example for Delphi

procedure TForm1.btnGetNumericContainerFRAMEValueClick(Sender: TObject);
var
nRet: L_INT;
nItemType: L_INT;
twFrame: TW_FRAME;
twCap: TW_CAPABILITY;
begin
// Fill the TW_CAPABILITY structure with values
twCap.Cap:= ICAP_FRAMES;
twCap.ConType:= TWON_ONEVALUE;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;

nRet:= LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability item type', 'ERROR', MB_OK );
end
else
begin
if ( nItemType = TWTY_FRAME ) then
begin
nRet:= LEADTwain1.GetNumericContainerFRAMEValue ( @twCap, 0, @twFrame );
if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Failed to get capability item value', 'ERROR', MB_OK );
end;
end;
end;


GetNumericContainerINTValue example for Delphi

procedure TForm1.btnGetNumericContainerINTValueClick(Sender: TObject);
var
nRet: L_INT;
nItemType: L_INT;
nValue: L_INT;
twCap: TW_CAPABILITY;
begin
// Fill the TW_CAPABILITY structure with values
twCap.Cap:= CAP_XFERCOUNT;
twCap.ConType:= TWON_ONEVALUE;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;

nRet:= LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability item type', 'ERROR', MB_OK );
end
else
begin
if ( nItemType = TWTY_INT16 ) then
begin
nRet:= LEADTwain1.GetNumericContainerINTValue ( @twCap, 0, @nValue );
if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Failed to get capability item value', 'ERROR', MB_OK );
end;
end;
end;


GetNumericContainerSTRINGValue example for Delphi

procedure TForm1.btnGetNumericContainerSTRINGValueClick(Sender: TObject);
var
nRet: L_INT;
nItemType: L_INT;
twString: TW_STR1024;
twCap: TW_CAPABILITY;
begin
// Fill the TW_CAPABILITY structure with values
twCap.Cap:= ICAP_HALFTONES;
twCap.ConType:= TWON_ONEVALUE;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;

nRet:= LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability item type', 'ERROR', MB_OK );
end
else
begin
if ( nItemType = TWTY_STR32 ) then
begin
nRet:= LEADTwain1.GetNumericContainerSTRINGValue ( @twCap, 0, twString );
if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Failed to get capability item value', 'ERROR', MB_OK );
end;
end;
end;


GetNumericContainerUINTValue example for Delphi

procedure TForm1.btnGetNumericContainerUINTValueClick(Sender: TObject);
var
nRet: L_INT;
nItemType: L_INT;
uValue: L_UINT;
twCap: TW_CAPABILITY;
begin
// Fill the TW_CAPABILITY structure with values
twCap.Cap:= ICAP_UNITS;
twCap.ConType:= TWON_ONEVALUE;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Exit;
end;

nRet:= LEADTwain1.GetNumericContainerItemType ( @twCap, @nItemType );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability item type', 'ERROR', MB_OK );
end
else
begin
if ( nItemType = TWTY_UINT16 ) then
begin
nRet:= LEADTwain1.GetNumericContainerUINTValue ( @twCap, 0, @uValue );
if ( nRet <> SUCCESS ) then
MessageBox ( Handle, 'Failed to get capability item value', 'ERROR', MB_OK );
end;
end;
end;


GetNumericContainerValue example for Delphi

Function TForm1.TwainGetCurrentValue ( ): L_INT;
var
nRet: L_INT;
pVal: L_PUINT16;
twCap: TW_CAPABILITY;
begin
pVal:= Nil;

twCap.Cap:= ICAP_XFERMECH;
twCap.ConType:= TWON_DONTCARE16;
nRet:= LEADTwain1.GetCapability ( @twCap, LTWAIN_CAPABILITY_GETCURRENT );
if ( nRet <> SUCCESS ) then
begin
MessageBox ( Handle, 'Failed to get capability', 'ERROR', MB_OK );
Result:= FAILURE;
Exit;
end;

if ( twCap.ConType = TWON_ONEVALUE ) then
nRet:= LEADTwain1.GetNumericContainerValue ( @twCap, 0, @pVal )
else
begin
if ( twCap.ConType = TWON_ONEVALUE ) then
nRet:= LEADTwain1.GetNumericContainerValue ( @twCap, LTWAIN_VALUE_CURRENT, @pVal );
end;

Result:= nRet;
end;


GetProperties example for Delphi

procedure TForm1.btnGetPropertiesClick(Sender: TObject);
var
nRet: L_INT;
twProps: LTWAINPROPERTIES;
begin
// Initialize to zero
FillMemory ( @twProps, sizeof(LTWAINPROPERTIES), 0 );

// Get the current properties of the selected twain source
nRet:= LEADTwain1.GetProperties ( @twProps, LTWAIN_PROPERTIES_GETCURRENT );

if ( nRet <> SUCCESS ) then
begin
Exit;
end;

// Change transfer mode to File
twProps.DataTransfer.nTransferMode:= TWSX_FILE;
StrCopy ( twProps.DataTransfer.szFileName, 'c:\temp\Twain.bmp' );
twProps.DataTransfer.nScanFileFormat:= TWFF_BMP;

// Set the new properties
LEADTwain1.EnableSetPropertiesEvent:= True;
nRet:= LEADTwain1.SetProperties ( @twProps, LTWAIN_PROPERTIES_SET );
if ( nRet <> SUCCESS ) then
begin
Exit;
end;
end;

function TForm1.LEADTwain1SetPropertiesEvent(uCap: Cardinal;
nStatus: Integer; pValue: Pointer): Integer;
begin
// Do your error notification or any other code here.

Result:= SUCCESS;
end;


IsAvailable example for Delphi

procedure TForm1.btnIsAvailableClick(Sender: TObject);
var
nRet: L_INT;
bAvailable: Boolean;
begin
{ Check to see if TWAIN is installed }
bAvailable:= LEADTwain1.IsAvailable ( Handle );
if ( bAvailable ) then
begin
LEADTwain1.ManName:= 'LEAD Technologies, Inc.';
LEADTwain1.ProdFamily:= 'LEAD Test Applications';
LEADTwain1.Version:= 'Version 1.0';
LEADTwain1.AppName:= 'TWAIN Test Application';
nRet:= LEADTwain1.InitSession ( Handle );
if ( nRet <> SUCCESS ) then
Exit;

LEADTwain1.Acquire ( LTWAIN_SHOW_USER_INTERFACE );

LEADTwain1.EndSession ( );
end;
end;


LockContainer example for Delphi

Procedure TForm1.CheckConType ( ptwCap: pTW_CAPABILITY );
var
ptwOneVal: pTW_ONEVALUE;
begin
ptwOneVal:= Nil;

if ( ptwCap.ConType = TWON_ONEVALUE ) then
begin
LEADTwain1.LockContainer ( ptwCap, @ptwOneVal );

if ( ptwOneVal <> Nil ) then
begin
// Do processing
LEADTwain1.UnlockContainer ( ptwCap );
end;
end;
end;


QueryProperty example for Delphi

Function TForm1.CheckCapability ( nValue: L_INT16 ): L_INT;
var
nRet: L_INT;
nIndex: L_INT;
ptwFixVal: pTW_FIX32;
twCap: TW_CAPABILITY;
pltQuery: pLTWAINPROPERTYQUERY;
begin
pltQuery:= Nil;

// Query capability possible values
nRet:= LEADTwain1.QueryProperty ( ICAP_XRESOLUTION, @pltQuery );

if ( nRet <> SUCCESS ) then
begin
Result:= nRet;
Exit;
end;

Case ( pltQuery.uType ) of
TWON_ONEVALUE:
begin
if ( pltQuery.pltwOneValue.ItemType = TWTY_FIX32 ) then
begin
ptwFixVal:= pTW_FIX32(pltQuery.pltwOneValue.Item);
if ( ptwFixVal.Whole = nValue ) then
begin
LEADTwain1.FreePropQueryStructure ( @pltQuery );
Result:= SUCCESS;
Exit;
end;
end;
end;

TWON_ENUMERATION:
begin
if ( pltQuery.pltwEnumeration.ItemType = TWTY_FIX32 ) then
begin
twCap.ConType:= TWON_ENUMERATION;
twCap.Cap:= ICAP_XRESOLUTION;
twCap.hContainer := GlobalHandle (pltQuery.pltwEnumeration);
for nIndex:= 0 to pltQuery.pltwEnumeration.NumItems-1 do
begin
LEADTwain1.GetNumericContainerFIX32Value ( @twCap, nIndex, @ptwFixVal );
if ( ptwFixVal.Whole = nValue ) then
begin
LEADTwain1.FreePropQueryStructure ( @pltQuery );
Result:= SUCCESS;
Exit;
end;
end;
end;
end;
end;

LEADTwain1.FreePropQueryStructure ( @pltQuery );
Result:= FAILURE;
end;


SelectedFamilyName example for Delphi

procedure TForm1.Button3Click(Sender: TObject);
var
strBuffer: String;
begin
strBuffer:= 'Source Name = ' + LEADTwain1.SelectedSourceName + Chr(13) +
'Product Family Name = ' + LEADTwain1.SelectedFamilyName + Chr(13) +
'Manufacturer Name = ' + LEADTwain1.SelectedManufacturerName + Chr(13);
ShowMessage ( strBuffer );
end;


ShowTemplateDlg example for Delphi

Function TForm1.LEADTwain1SaveCapabilityEvent(
pCapability: pTW_CAPABILITY): Integer;
begin
// Do pre operations on data to save

Result:= SUCCESS;
end;

procedure TForm1.btnShowTemplateDlgClick(Sender: TObject);
var
nRet: L_INT;
begin
LEADTwain1.EnableSaveCapabilityEvent:= True;
nRet:= LEADTwain1.ShowTemplateDlg ( 'c:\Test.ltt' );
if ( nRet <> SUCCESS ) then
begin
// Error check procedure
end;
end;


SourceName example for Delphi

procedure TForm1.Button1Click(Sender: TObject);
var
n: L_INT;
nCount: L_INT;
strName: String;
begin
nCount:= LEADTwain1.SourceCount;
for n:= 0 to nCount - 1 do
begin
strName:= LEADTwain1.SourceName [n];
ShowMessage ( strName );
//Do More processing on source name
end;
end;


UnlockSupport example for Delphi

{Unlock Document support.}
{Note that this is a sample key, which will not work in your toolkit.}
LEADTwain1.UnlockSupport ( L_SUPPORT_DOCUMENT, 'TestKey' );
if ( LEADTwain1.IsSupportLocked (L_SUPPORT_DOCUMENT) ) then
ShowMessage('Document Support Locked')
else
ShowMessage('Document Support is available');


Technical Support

As a registered user, free technical support is available. You must register your software to receive any technical support. Technical support is available 9 a.m. through 6 p.m. Eastern Standard Time. If you are calling by phone, please be at your computer. You can also contact us through the following methods:

Phone: (704) 372-9681

E-mail: support@leadtools.com

FAX: (704) 372-8161

Home page: http://www.leadtools.com

FTP: ftp.leadtools.com

You can also contact LEAD by mail at:

LEAD Technologies, Inc.
Attn: Technical Support
1201 Greenwood Cliff, Suite 400
Charlotte, NC 28204

Before calling technical support, please look in the online documentation and the example programs for an answer to your question.


Twain Properties, Methods and Events

Properties, Methods and Events

TWAIN Functionality

Applications

Capabilities

Containers

Events

Extended Image Information

Fast TWAIN (Scan Configuration)

Images

Template Files

Twain Sessions

TWAIN Sources

Miscellaneous


TWAIN Functionality: Applications

TWAIN Functionality:
Applications

AppName property

ManName property

ProdFamily property

Version property


TWAIN Functionality: Capability

TWAIN Functionality:
Capabilities

AddCapabilityToFile method

EnumCapabilities method

GetCapability method

GetCapabilityFromFile method

GetNumOfCapsInFile method

SetCapability method


TWAIN Functionality: Containers

TWAIN Functionality:
Containers

CreateNumericContainerArray method

CreateNumericContainerEnum method

CreateNumericContainerOneValue method

CreateNumericContainerRange method

FreeContainer method

GetNumericContainerBOOLValue method

GetNumericContainerFIX32Value method

GetNumericContainerFRAMEValue method

GetNumericContainerINTValue method

GetNumericContainerSTRINGValue method

GetNumericContainerItemType method

GetNumericContainerUINTValue method

GetNumericContainerValue method

LockContainer method

UnlockContainer method


TWAIN Functionality: Events

TWAIN Functionality:
Events

EnableAcquirePageEvent Property

EnableEnumCapabilityEvent Property

EnableSetPropertiesEvent Property

EnableSaveCapabilityEvent Property

EnableFastConfigEvent Property

EnableAcquireMultiEvent Property

 OnAcquirePageEvent Event

OnEnumCapabilityEvent Event

OnSetPropertiesEvent Event

OnSaveCapabilityEvent Event

OnFastConfigEvent Event

OnAcquireMultiEvent Event


TWAIN Functionality: Extended Image Information

TWAIN Functionality:
Extended Image Information

GetExtendedImageInfo method

CreateExtendedInfo method

GetExtendedInfo method

FreeExtendedImageInfoStructure method


TWAIN Functionality: Fast TWAIN (Scan Configuration)

TWAIN Functionality:
Fast TWAIN (Scan Configuration)

AcquireMulti method

FindFastConfig method

GetScanConfigs method

FreeScanConfig method


TWAIN Functionality: Images

TWAIN Functionality:
Images

IsAvailable method

Acquire method

AcquireMulti method

FreePropQueryStructure method

GetProperties method

SelectSource method

SetProperties method

QueryProperty method


TWAIN Functionality: Template File

TWAIN Functionality:
Template File

CloseTemplateFile method

OpenTemplateFile method

ShowTemplateDlg method


TWAIN Functionality: Twain Sessions

TWAIN Functionality:
Twain Sessions

InitSession method

EndSession method


TWAIN Functionality: TWAIN Sources

TWAIN Functionality:
TWAIN Sources

AcquireSourceName property

FamilyName property

ManufacturerName property

SelectedFamilyName property

SelectedManufacturerName property

SelectedSourceName property

SelectSource method

SourceCount property

SourceName property


TWAIN Functionality: Miscellaneous

TWAIN Functionality:
Miscellaneous

EnableMethodErrors property

IsSupportLocked method

UnlockSupport method


Data Types

Basic Data Types and Keywords

LEADTOOLS Basic Data Types

TWAIN Data Types

DATATRANSFER

FASTCONFIG

HTWAINTEMPLATEFILE

IMAGEEFFECTS

IMAGERESOLUTION

LTWAINPROPERTIES

LTWAINPROPERTYQUERY


LEADTOOLS Basic Data Types

LEADTOOLS has defined the following basic data types for portability:

Data Type | Definition and Usage
L_HANDLE | Defined as (type integer), used as LEAD Handle.
L_CHAR | Defined as char, used as a signed 8-bit integer.
L_UCHAR | Defined as Byte, used as an unsigned 8-bit integer.
L_INT16 | Defined as SmallInt, used as a signed 16-bit integer.
L_UINT16 | Defined as Word, used as an unsigned 16-bit integer.
L_INT32 | Defined as Longint, used as a signed 32-bit integer.
L_UINT32 | Defined as LongWord, used as an unsigned 32-bit integer.
L_INT | Defined as integer, used as a signed integer, 16-bits or larger.
L_UINT | Defined as Cardinal, used as an unsigned integer, 16-bits or larger.
L_BOOL | Defined as (type LongBool), used as a Boolean value.
L_BITFIELD | Defined as L_UINT, used as a bit field.
L_FLOAT | Defined as Single, used as a floating-point number (4 bytes).
L_DOUBLE | Defined as double used as a double precision floating point number.
L_RGBQUAD | Defined as RGBQUAD structure.
L_PVOID | Defined as pointer.
L_PHANDLE | Defined as pointer to L_HANDLE.
L_PCHAR | Defined as PChar.
L_PUCHAR | Defined as pointer to L_UCHAR.
L_PINT16 | Defined as pointer to L_INT16.
L_PUINT16 | Defined as pointer to L_UINT16.
L_PINT32 | Defined as pointer to L_INT32.
L_PUINT32 | Defined as pointer to L_UINT32.
L_PINT | Defined as pointer to L_INT.
L_PUINT | Defined as pointer to L_UINT.
L_PBOOL | Defined as pointer to L_BOOL.
L_PBITFIELD | Defined as pointer to L_BITFIELD.
L_PFLOAT | Defined as pointer to L_FLOAT.
L_PDOUBLE | Defined as pointer to L_DOUBLE.
L_PRGBQUAD | Defined as pointer to L_RGBQUAD.
L_PPCHAR | Defined as pointer to L_PCHAR.
L_PPINT | Defined as pointer to L_PINT.
L_PPUINT | Defined as pointer to L_PUINT.


DATATRANSFER

pDATATRANSFER= ^DATATRANSFER;
DATATRANSFER= Packed Record
nFillOrder: L_INT;
nBufMemCompression: L_INT;
nTransferMode: L_INT;
nScanFileFormat: L_INT;
nMemBufSize: L_INT;
bSaveToOneFile: L_BOOL;
bAppendToFile: L_BOOL;
bDumpMemBufsToFile: L_BOOL;
szFileName: Array [ 0..249 ] of L_CHAR;
end;

The DATATRANSFER structure provides information about data transferring.

Member | Description
nFillOrder | Indicates how bytes in the image are to be filled by the source. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWBO_LSBFIRST | Bytes are to be transferred with the least significant byte first.
 | TWBO_MSBFIRST | Bytes are to be transferred with the most significant byte first.
nBufMemCompression | Specifies the compression to be used when having the transfer mode set to be memory. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWCP_NONE | No compression is to be used.
 | TWCP_PACKBITS | Pack Bits compression.
 | TWCP_GROUP31D | CCITT Group 3 compression with no End of Line.
 | TWCP_GROUP31DEOL | CCITT Group 3 compression with End of Line.
 | TWCP_GROUP32D | CCITT Group 3 compression (use cap for K Factor).
 | TWCP_GROUP4 | CCITT Group 4 compression.
 | TWCP_JPEG | JPEG compression.
 | TWCP_LZW | LZW compression (like gifs).
 | TWCP_JBIG | JBIG compression, used mostly for bitonal images.
 | TWCP_PNG | PNG compressed.
 | TWCP_RLE4 | RLE4 compression.
 | TWCP_RLE8 | RLE8 compression.
 | TWCP_BITFIELDS | Bit Fields compression.
nTransferMode | Transfer mode to be used by the TWAIN source. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWSX_NATIVE | Native transfer mode.
 | TWSX_MEMORY | Memory buffered transfer mode. The source will be transferring strips of data to the application according to the buffer size given.
 | TWSX_FILE | File transfer mode. This will use a specified file to have the image data saved to. This will have a certain format specified by the properties.
nScanFileFormat | Determines the file format to use when saving the files from the TWAIN source. Possible values are (according to the TWAIN 1.9 specification) :
 | Value | Meaning
 | TWFF_TIFF | Tagged image file.
 | TWFF_PICT | Macintosh PICT.
 | TWFF_BMP | Windows regular bitmap.
 | TWFF_XBM | X-Windows bitmap.
 | TWFF_JFIF | JPEG file interchange format.
 | TWFF_FPX | Flash pix file.
 | TWFF_TIFFMULTI | Multi-page tiff file format.
 | TWFF_PNG | PNG file.
 | TWFF_SPIFF | SPIFF file.
 | TWFF_EXIF | EXIF file.
nMemBufSize | Specifies the memory buffer size to be used in data transfer.
bSaveToOneFile | Flag that indicates whether to save a multiple pages to a single file. Possible values are:
 | Value | Meaning
 | TRUE | Save to a single file.
 | FALSE | Do not save to a single file.
bAppendToFile | Flag that indicates whether to append pages to the end of the file when saving a multi-page file. Possible values are:
 | Value | Meaning
 | TRUE | Append pages to the end of the file.
 | FALSE | Do not append pages to the end of the file.
bDumpMemBufsToFile | Flag that indicates whether to use the file name specified in szFileName field to dump the memory buffers received from the scanner. In this case the Bitmap Handle will not get the Bitmap Data, all the data will be saved to the file. Possible values are:
 | Value | Meaning
 | TRUE | Use file name.
 | FALSE | Do not use file name.
szFileName | Character string that contains the file name used in the file transfer mode.

Comments

pDATATRANSFER is a pointer to a DATATRANSFER structure. Where the function parameter type is pDATATRANSFER, you can declare a DATATRANSFER variable, update the structure's fields and pass the variable's address in the parameter. Declaring a pDATATRANSFER variable is necessary only if your program requires a pointer.

DATATRANSFER is used with the LTWAINPROPERTIES structure.


FASTCONFIG

ppFASTCONFIG= ^pFASTCONFIG;
pFASTCONFIG= ^FASTCONFIG;
FASTCONFIG= Record
uTransferMode: L_UINT;
nFileFormat: L_INT;
ulBufferSize: L_UINT32;
uTime: L_UINT;
nBitsPerPixel: L_INT;
bSuccess: L_BOOL;
end;

The FASTCONFIG structure provides information about a scan configuration to be tested or a scan configuration that is the result of testing.

Member | Description
uTransferMode | Transfer mode for the scan configuration(s). The possible values are:
 | Value | Meaning
 | LTWAIN_FILE_MODE | [$001] Use File transfer mode
 | LTWAIN_BUFFER_MODE | [$002] Use Memory transfer mode
 | LTWAIN_NATIVE_MODE | [$004] Use Native transfer mode
nFileFormat | The file format that will be used to save scanned images using this scan configuration. Possible values depend upon the transfer mode being used.
 | The following formats are valid when using Memory Transfer mode:
 | FILE_FAX_G4
 | FILE_FAX_G3_2D
 | FILE_FAX_G3_1D
 | FILE_FAX_G3_1D_NOEOL
 | FILE_JBIG
 | FILE_TIF_JPEG
 | FILE_JPEG_411
 | FILE_JPEG_422
 | FILE_JPEG
 | FILE_TIF
 | The following formats are valid when using Native Transfer mode:
 | FILE_CCITT_GROUP4
 | FILE_BMP
 | FILE_JPEG
 | FILE_TIF
 | The following formats are valid when using File Transfer mode:
 | TWFF_TIFF
 | TWFF_PICT
 | TWFF_BMP
 | TWFF_XBM
 | TWFF_JFIF
 | TWFF_FPX
 | TWFF_TIFFMULTI
 | TWFF_PNG
 | TWFF_SPIFF
 | TWFF_EXIF
ulBufferSize | The buffer size that will be used with the buffer transfer mode. If this value is 0, then use the twain driver preferred buffer size.
uTime | The amount of time required to scan the pages used for testing the scan configuration. The number of pages depends on how many pages the user loads in the scanner when testing a scan configuration. The same pages should be used for each test.
nBitsPerPixel | Bits per pixel that will be used.
bSuccess | Specifies whether the configuration being tested succeeded. Possible values are:
 | Value | Meaning
 | TRUE | The current scan configuration was successful.
 | FALSE | The current scan configuration was not successful.

Comments

pFASTCONFIG is a pointer to a FASTCONFIG structure. Where the function parameter type is pFASTCONFIG, you can declare an FASTCONFIG variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pFASTCONFIG variable is necessary only if your program requires a pointer.

FASTCONFIG is used with the FindFastConfig, GetScanConfigs and FreeScanConfig methods.


HTWAINTEMPLATEFILE

LEADTOOLS has defined the following data types for referencing TWAIN template file:

Data Type | Definition and Usage
HTWAINTEMPLATEFILE | Defined as L_HANDLE; used as a handle of a TWAIN template file.
pHTWAINTEMPLATEFILE | Defined as ^HTWAINTEMPLATEFILE; used as a pointer to a TWAIN template file handle.


IMAGEEFFECTS

pIMAGEEFFECTS= ^IMAGEEFFECTS;
IMAGEEFFECTS= Packed Record
nPixFlavor: L_INT;
nColorScheme: L_INT;
fHighLight: L_FLOAT;
fShadow: L_FLOAT;
fBrightness: L_FLOAT;
fContrast: L_FLOAT;
szHalfTone: Array [ 0..31 ] of L_CHAR;
end;

The IMAGEEFFECTS structure provides information about the image effects.

Member | Description
nPixFlavor | Pixel flavor used when acquiring. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWPF_CHOCOLATE | Zero stands for the darkest shade.
 | TWPF_VANILLA | Zero stands for the lightest shade.
nColorScheme | Color scheme to use when scanning is to be done. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWPT_BW | Black and White (1 bit).
 | TWPT_GRAY | 8-bit Gray Scale
 | TWPT_RGB | 24-bit RGB Color.
 | TWPT_PALETTE | 8-bit Color.
 | TWPT_CMY | CYAN, magenta, yellow color space.
 | TWPT_CMYK | CYAN, magenta, yellow, black color space.
 | TWPT_YUV | Color space type that is true color encoding. It uses one luminance value (Y) and two chroma values (UV).
 | TWPT_YUVK | The same as YUV with an additional black variable.
 | TWPT_CIEXYZ | Chromaticity diagram.
fHighLight | Highlight value.
fShadow | Shadow value.
fBrightness | Brightness value.
fContrast | Contrast value.
szHalfTone | A string having the name of the used pattern.

Comments

pIMAGEEFFECTS is a pointer to a IMAGEEFFECTS structure. Where the function parameter type is pIMAGEEFFECTS, you can declare an IMAGEEFFECTS variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pIMAGEEFFECTS variable is necessary only if your program requires a pointer.

IMAGEEFFECTS is used with the LTWAINPROPERTIES structure.


IMAGERESOLUTION

pIMAGERESOLUTION= ^IMAGERESOLUTION;
IMAGERESOLUTION= Packed Record
nUnitOfResolution: L_INT;
nBitsPerPixel: L_INT;
fHorzResolution: L_FLOAT;
fVertResolution: L_FLOAT;
fXScaling: L_FLOAT;
fYScaling: L_FLOAT;
fRotationAngle: L_FLOAT;
fLeftMargin: L_FLOAT;
fRightMargin: L_FLOAT;
fTopMargin: L_FLOAT;
fBottomMargin: L_FLOAT;
end;

The IMAGERESOLUTION structure provides information about the images effects.

Member | Description
nUnitOfResolution | An integer having the unit of resolution to use. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWUN_INCHES | Inches unit.
 | TWUN_CENTIMETERS | Centimeters unit.
 | TWUN_PICAS | Picas unit.
 | TWUN_POINTS | Points unit.
 | TWUN_TWIPS | Twips unit.
 | TWUN_PIXELS | Pixels unit.
nBitsPerPixel | Bits per pixel the acquired images will have.
fHorzResolution | Horizontal resolution of the TWAIN source while acquiring the images.
fVertResolution | Vertical resolution of the TWAIN source while acquiring the images.
fXScaling | The acquired image X-direction scaling value before transferring.
fYScaling | The acquired image X-direction scaling value before transferring.
fRotationAngle | The acquired image rotation angle value before transfer.
fLeftMargin | The left margin of the scanning area.
fRightMargin | The right margin of the scanning area.
fTopMargin | The top margin of the scanning area.
fBottomMargin | The bottom margin of the scanning area.

Comments

pIMAGERESOLUTION is a pointer to a IMAGERESOLUTION structure. Where the function parameter type is pIMAGERESOLUTION, you can declare an IMAGERESOLUTION variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pIMAGERESOLUTION variable is necessary only if your program requires a pointer.

IMAGERESOLUTION is used with the LTWAINPROPERTIES structure.


LTWAINPROPERTIES

pLTWAINPROPERTIES= ^LTWAINPROPERTIES;
LTWAINPROPERTIES= Packed Record
bPaperSource: L_BOOL;
nMaxNumOfPages: L_INT;
nDuplexScanning: L_INT;
ImageRes: IMAGERESOLUTION;
DataTransfer: DATATRANSFER;
ImageEff: IMAGEEFFECTS;
end;

The LTWAINPROPERTIES structure provides information about the available TWAIN properties.

Member | Description
bPaperSource | Flag that indicates whether to use the Auto - Feed capability of the selected TWAIN source. Possible values are:
 | Value | Meaning
 | TRUE | Use the Auto - Feed capability.
 | FALSE | Do not use the Auto - Feed capability.
nMaxNumOfPages | The maximum number of pages to get from the TWAIN source. (If the function updates this field to -1, it means that the number of pages is unlimited.)
nDuplexScanning | Sets the type of duplex scanning. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWDX_NONE | No duplex used.
 | TWDX_1PASSDUPLEX | 1 pass duplex.
 | TWDX_2PASSDUPLEX | 2 pass duplex.
ImageRes | A structure of type IMAGERESOLUTION that contains image resolution data for the TWAIN source.
DataTransfer | A structure of type DATATRANSFER that contains data transfer information for the TWAIN source.
ImageEff | A structure of type IMAGEEFFECTS that contains image effects information for the TWAIN source.

Comments

pLTWAINPROPERTIES is a pointer to a LTWAINPROPERTIES structure. Where the function parameter type is pLTWAINPROPERTIES, you can declare an LTWAINPROPERTIES variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pLTWAINPROPERTIES variable is necessary only if your program requires a pointer.

LTWAINPROPERTIES is used with the GetProperties and SetProperties methods.


LTWAINPROPERTYQUERY

TCapType = (_ONEVALUE, _ENUMERATION, _ARRAY, _RANGE);
// TWAIN structure LTWAINPROPERTYQUERY
ppLTWAINPROPERTYQUERY= ^pLTWAINPROPERTYQUERY;
pLTWAINPROPERTYQUERY= ^LTWAINPROPERTYQUERY;
LTWAINPROPERTYQUERY = Packed Record
uType: L_UINT;
Case TCapType of
_ONEVALUE: (pltwOneValue: pTW_ONEVALUE);
_RANGE: (pltwRange: pTW_RANGE);
_ENUMERATION: (pltwEnumeration: pTW_ENUMERATION);
_ARRAY: (pltwArray: pTW_ARRAY);
end;

The LTWAINPROPERTYQUERY structure provides information about the capability properties.

Member | Description
uType | Holds the type of pointer to use from the union. Possible values are (according to the TWAIN 1.9 specification):
 | Value | Meaning
 | TWON_ONEVALUE | The container is of type TW_ONEVALUE and only the pltwOneValue pointer is used.
 | TWON_RANGE | The container is of type TW_RANGE and only the pltwRange pointer is used.
 | TWON_ONEVALUE | The container is of type TW_ENUMERATION and only the pltwEnumeration pointer is used.
 | TWON_ONEVALUE | The container is of type TW_ARRAY and only the pltwArray pointer is used.
pltwOneValue | Pointer to a TW_ONEVALUE structure.
pltwRange | Pointer to a TW_RANGE structure.
pltwEnumeration | Pointer to a TW_ENUMERATION structure.
pltwArray | Pointer to a TW_ARRAY structure.

Comments

pLTWAINPROPERTYQUERY is a pointer to a LTWAINPROPERTYQUERY structure. Where the methods parameter type is pLTWAINPROPERTYQUERY, you can declare an LTWAINPROPERTYQUERY variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pLTWAINPROPERTYQUERY variable is necessary only if your program requires a pointer.

LTWAINPROPERTIES is allocated by the QueryProperty method and freed by FreePropQueryStructure method.

For more information on the TWAIN 1.9 Specification, refer to the specification, available at www.twain.org.


Error Codes

For a list of all possible return codes for LEADTOOLS Twain VCL functions, refer to LEADTOOLS VCL Error Codes in the Main VCL help file.


Acquire method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int Acquire (unsigned uFlags);
Delphi Syntax | Function Acquire (uFlags: L_UINT ): L_INT;
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Acquires one or more images from a TWAIN source.

When acquiring multiple pages, the OnAcquirePageEvent Event receives the scanned images through the Bitmap parameter. The user can then process these images as desired within the event.

The number of pages to acquire can be determined by getting the TWAIN source's capabilities. To change the number of pages to acquire, set the appropriate capability to the desired number.

See Also

Elements: | InitSession method, EndSession method, OpenTemplateFile method, CloseTemplateFile method, ShowTemplateDlg method, AddCapabilityToFile method, GetNumOfCapsInFile method, GetCapabilityFromFile method.
Topics: | TWAIN Functionality: Images.


AcquireMulti method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int AcquireMulti(AnsiString strBaseFileName, unsigned uFlags, unsigned uTransferMode, int nFormat, int nBitsPerPixel, L_BOOL bMultiPageFile, unsigned uUserBufSize, L_BOOL bUsePrefferedBuffer);
Delphi Syntax | Function AcquireMulti (strBaseFileName: String; uFlags: L_UINT; uTransferMode: L_UINT; nFormat: L_INT; nBitsPerPixel: L_INT; bMultiPageFile: L_BOOL; uUserBufSize: L_UINT32; bUsePrefferedBuffer: L_BOOL ): L_INT;
Overview | Refer to How to Acquire from the Twain Source.

Remarks

(Document/Medical only) Acquires one or more images from a TWAIN source and stores the images in the specified file(s).

Based on the scanner type, this method will determine the best/fastest scanning method to use. This method will be used when actually scanning the image(s). Before calling this method you can call FindFastConfig to determine the best scan configuration and then pass the scan configuration information to the AcquireMulti method. If you do not call FindFastConfig before calling AcquireMulti, then the AcquireMulti method will determine the best scanning method.

If the file format specified in nFormat does not support multi-page files, this method will ignore the bMultiPageFile parameter and automatically save the scanned images in separate files. The naming of the files will be carried out as follows: if the string in strBaseFileName is "Temp.jpg", the method will append the number of the image, 0001, 0002, etc, to the name of the file. Therefore, the output file names will be "Temp0001.jpg", "Temp0002.jpg", etc.

If the file format specified in nFormat supports multi-page files, this method will use the bMultiPageFile parameter to determine how to save multiple images. If bMultiPageFile is FALSE, each scanned page will be saved to a separate file, named in the same manner described in the paragraph above. If bMultiPageFile is TRUE, the name of the output file will be exactly the string in strBaseFileName (Temp.jpg) and it will be saved as a multi-page file.

If uTransferMode is LTWAIN_BUFFER_MODE, and bUsePreferredBuffer is FALSE, then the method will use the user-defined buffer size in uUserBufSize. If however bUsePreferredBuffer is TRUE, then the method will use the Twain driver preferred buffer size and will ignore uUserBufSize.

See Also

Elements: | Acquire method, InitSession method, EndSession method, OpenTemplateFile method, CloseTemplateFile method, ShowTemplateDlg method, AddCapabilityToFile method, GetNumOfCapsInFile method, GetCapabilityFromFile method, FindFastConfig method, GetScanConfigs method, FreeScanConfig method.
Topics: | TWAIN Functionality: Images.


AcquireSourceName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString AcquireSourceName;
Delphi Syntax | AcquireSourceName: String;
Overview | Refer to Managing the TWAIN Source.

Remarks

(Write Only) This property is used to set the source name when the select source procedure is done without showing a user interface.

This value has to be set to a valid source name. You can get all available source names using the SourceName property.

This property is a write only property.

See Also

Elements: | SourceName property, SourceCount property
Topics: | TWAIN Functionality: TWAIN Sources


AddCapabilityToFile method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int AddCapabilityToFile(HTWAINTEMPLATEFILE hFile, pTW_CAPABILITY pCapability);
Delphi Syntax | Function AddCapabilityToFile (hFile: HTWAINTEMPLATEFILE; pCapability: pTW_CAPABILITY ): L_INT;
Overview | Refer to Handling Template Files.

Remarks

Adds a capability to a file.

In order to add a capability to a template file, the template file must first be opened for writing using the OpenTemplateFile method. Opening the file for writing will create a new empty file. The process of adding capabilities to the file will add them sequentially. When all capabilities have been added, save the file by calling CloseTemplateFile. For more information on capabilities, refer to Getting and Setting Capabilities.

For more information on Template files, refer to Handling Template Files.

See Also

Elements: | OpenTemplateFile method, ShowTemplateDlg method, GetCapabilityFromFile method, GetNumOfCapsInFile method, CloseTemplateFile method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Capabilities.


AppName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString AppName
Delphi Syntax | AppName: String
Overview | Refer to Initializing a TWAIN Session.

Remarks

(Write only) An application specific string that contains the user's application name. Using this property is optional.

See Also

Elements: | ManName property, ProdFamily property, Version property.
Topics: | TWAIN Functionality: Applications


CloseTemplateFile method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int CloseTemplateFile(HTWAINTEMPLATEFILE hFile);
Delphi Syntax | Function CloseTemplateFile (hFile: HTWAINTEMPLATEFILE ): L_INT;
Overview | Refer to Handling Template Files.

Remarks

Closes the opened template file.

Closes and saves the template file opened by calling the OpenTemplateFile method.

For more information on template files, refer to Handling Template Files.

See Also

Elements: | OpenTemplateFile method, AddCapabilityToFile method, GetCapabilityFromFile method, GetNumOfCapsInFile method, ShowTemplateDlg method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Template Files.


CreateExtendedInfo method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int CreateExtendedInfo (ppTW_EXTIMAGEINFO pptwExtImgInfo, pTW_INFO ptwInfo, int ntwInfoCount);
Delphi Syntax | Function CreateExtendedInfo (pptwExtImgInfo: ppTW_EXTIMAGEINFO; ptwInfo: pTW_INFO; ntwInfoCount: L_INT ): L_INT;
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Creates extended image info using image info that passed in ptwInfo parameter.

To get the extended image info use GetExtendedImageInfo method.

To get specific image info call GetExtendedInfo method.

When application doesn’t require the extended image info, you should call FreeExtendedImageInfo method to free it.

See Also

Elements: | GetExtendedInfo method, Acquire method, OnAcquirePageEvent Event, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Extended Image Information


CreateNumericContainerArray method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int CreateNumericContainerArray(pTW_CAPABILITY pCapability, int nType, unsigned uNumOfItems, void * pData);
Delphi Syntax | Function CreateNumericContainerArray (pCapability: pTW_CAPABILITY; nType: L_INT; uNumOfItems: L_UINT32; pData: L_PVOID ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_ARRAY and fills it with the appropriate data.

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the SetCapability method, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

See Also

Elements: | FreeContainer method, CreateNumericContainerRange method, CreateNumericContainerOneValue method, CreateNumericContainerEnum method, LockContainer method, UnlockContainer method.
Topics: | TWAIN Functionality: Containers.


CreateNumericContainerEnum method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int CreateNumericContainerEnum(pTW_CAPABILITY pCapability, int nType, unsigned uNumOfItems, unsigned uCurrentIndex, unsigned uDefaultIndex, void * pData);
Delphi Syntax | Function CreateNumericContainerEnum (pCapability: pTW_CAPABILITY; nType: L_INT; uNumOfItems: L_UINT32; uCurrentIndex: L_UINT32; uDefaultIndex: L_UINT32 ; pData: L_PVOID ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_ENUMERATION and fills it with the appropriate data.

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the SetCapability method, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

See Also

Elements: | FreeContainer method, CreateNumericContainerRange method, CreateNumericContainerOneValue method, CreateNumericContainerArray method, LockContainer method, UnlockContainer method.
Topics: | TWAIN Functionality: Containers.


CreateNumericContainerOneValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int CreateNumericContainerOneValue(pTW_CAPABILITY pCapability, int nType, unsigned uValue);
Delphi Syntax | Function CreateNumericContainerOneValue (pCapability:pTW_CAPABILITY; nType: L_INT; uValue: L_UINT32 ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_ONEVALUE and fills it with the appropriate data.

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the SetCapability method, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

See Also

Elements: | FreeContainer method, CreateNumericContainerRange method, CreateNumericContainerEnum method, CreateNumericContainerArray method, LockContainer method, UnlockContainer method.
Topics: | TWAIN Functionality: Containers.


CreateNumericContainerRange method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int CreateNumericContainerRange(pTW_CAPABILITY pCapability, int nType, unsigned uMinValue, unsigned uMaxValue, unsigned uStepSize, unsigned uDefaultValue, unsigned uCurrentValue);
Delphi Syntax | Function CreateNumericContainerRange (pCapability: pTW_CAPABILITY; nType: L_INT; uMinValue: L_UINT32; uMaxValue: L_UINT32 ; uStepSize: L_UINT32 ; uDefaultValue: L_UINT32; uCurrentValue: L_UINT32 ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Allocates the hContainer member of the TW_CAPABILITY structure to be type TW_RANGE and fills it with the appropriate data.

When enumerating and getting capabilities, the toolkit takes care of creating the necessary TW_CAPABILITY containers. However, if the user wants to set a capability using the SetCapability method, he or she must declare a TW_CAPABILITY container of the appropriate type (TW_ARRAY, TW_ENUMERATION, TW_RANGE, or TW_ONEVALUE).

The step size is the amount of increase from one step to the next within the range uMinVal to uMaxVal. For example, if uMinValue = 0, uMaxValue = 100, and uStepSize = 2, then it will take 50 steps to increase from 0 to 100.

See Also

Elements: | FreeContainer method, CreateNumericContainerOneValue method, CreateNumericContainerEnum method, CreateNumericContainerArray method, LockContainer method, UnlockContainer method.
Topics: | TWAIN Functionality: Containers.


EnableAcquireMultiEvent property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableAcquireMultiEvent
Delphi Syntax | EnableAcquireMultiEvent: Boolean
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Enables or disables the generation of the OnAcquireMultiEvent event. Possible values are:

Setting | Description
TRUE | Enable the generation of the OnAcquireMultiEvent event.
FALSE | Disable the generation of the OnAcquireMultiEvent event.

See Also

Elements: | OnAcquireMultiEvent event.
Topics: | TWAIN Functionality: Events


EnableAcquirePageEvent property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableAcquirePageEvent
Delphi Syntax | EnableAcquirePageEvent: Boolean
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Enables or disables the generation of the OnAcquirePageEvent Event. Possible values are:

Setting | Description
TRUE | Enable the generation of the OnAcquirePageEvent Event.
FALSE | Disable the generation of the OnAcquirePageEvent Event.

See Also

Elements: | OnAcquirePageEvent event
Topics: | TWAIN Functionality: Events


EnableEnumCapabilityEvent property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableEnumCapabilityEvent
Delphi Syntax | EnableEnumCapabilityEvent: Boolean
Overview | Refer to Getting and Setting Capabilities.

Remarks

Enables or disables the generation of the OnEnumCapabilityEvent event. Possible values are:

Setting | Description
TRUE | Enable the generation of the OnEnumCapabilityEvent event.
FALSE | Disable the generation of the OnEnumCapabilityEvent event.

See Also

Elements: | OnEnumCapabilityEvent event
Topics: | TWAIN Functionality: Events


EnableFastConfigEvent property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableFastConfigEvent
Delphi Syntax | EnableFastConfigEvent: Boolean
Overview | Refer to Fast TWAIN (Scan Configurations).

Remarks

Enables or disables the generation of the OnFastConfigEvent event. Possible values are:

Setting | Description
TRUE | Enable the generation of the OnFastConfigEvent event.
FALSE | Disable the generation of the OnFastConfigEvent event.

See Also

Elements: | OnFastConfigEvent event.
Topics: | TWAIN Functionality: Events


EnableMethodErrors property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableMethodErrors
Delphi Syntax | EnableMethodErrors: Boolean
Overview | Refer to Initializing a TWAIN Session.

Remarks

(Persistent property, available at design time) Specifies whether LEADTOOLS generates system error events (in addition to error return codes).

Setting | Description
TRUE | Generates system error events.
FALSE | Does not generate system error events.

See Also

Topics:

TWAIN Functionality: Miscellaneous Methods and Properties


EnableSaveCapabilityEvent property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableSaveCapabilityEvent
Delphi Syntax | EnableSaveCapabilityEvent: Boolean
Overview | Refer to Handling Template Files.

Remarks

Enables or disables the generation of the OnSaveCapabilityEvent event. Possible values are:

Setting | Description
TRUE | Enable the generation of the OnSaveCapabilityEvent event.
FALSE | Disable the generation of the OnSaveCapabilityEvent event.

See Also

Elements: | OnSaveCapabilityEvent event
Topics: | TWAIN Functionality: Events


EnableSetPropertiesEvent property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool EnableSetPropertiesEvent
Delphi Syntax | EnableSetPropertiesEvent: Boolean
Overview | Refer to Getting and Setting Capabilities.

Remarks

Enables or disables the generation of the OnSetPropertiesEvent event. Possible values are:

Setting | Description
TRUE | Enable the generation of the OnSetPropertiesEvent event.
FALSE | Disable the generation of the OnSetPropertiesEvent event.

See Also

Elements: | OnSetPropertiesEvent event.
Topics: | TWAIN Functionality: Events


EndSession method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int EndSession(void);
Delphi Syntax | Function EndSession ( ): L_INT;
Overview | Refer to Freeing the TWAIN Session.

Remarks

Ends a TWAIN session.

A TWAIN session is started by calling the InitSession method.

For each call to InitSession method there must be a call to EndSession. This function should be the last function to be called in the toolkit. It will clean up and free memory allocated during the TWAIN session.

See Also

Elements: | InitSession method.
Topics: | TWAIN Functionality: Twain Sessions.


EnumCapabilities method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int EnumCapabilities(unsigned uFlags);
Delphi Syntax | Function EnumCapabilities (uFlags: L_UINT ): L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Gets the supported capabilities and specified value(s) of each capability.

EnumCapabilities calls OnEnumCapabilityEvent as it gets each TWAIN capability.

See Also

Elements: | SetProperties method, GetProperties method, SetCapability method, GetCapability method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Capabilities.


FamilyName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString FamilyName[int nIndex]
Delphi Syntax | FamilyName [nIndex: Integer]: String
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) Gets a character string that contains the family product name of the specified TWAIN source. This name is provided by the manufacturer.

See Also

Elements: | ManName property, ProdFamily property, Version property, AppName property, SourceCount property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method, ManufacturerName property, SelectedFamilyName property, SelectedManufacturerName property
Topics: | TWAIN Functionality: TWAIN Sources.


FindFastConfig method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int FindFastConfig(AnsiString strWorkingFolder, unsigned uFlags, int nBitsPerPixel, int nBufferIteration, pFASTCONFIG pInFastConfigs, int nInFastConfigsCount, ppFASTCONFIG ppTestConfigs, L_PINT pnTestConfigsCount, pFASTCONFIG pOutBestConfig);
Delphi Syntax | Function FindFastConfig (strWorkingFolder: String; uFlags: L_UINT; nBitsPerPixel: L_INT; nBufferIteration: L_INT; pInFastConfigs: pFASTCONFIG; nInFastConfigsCount: L_INT; ppTestConfigs: ppFASTCONFIG; pnTestConfigsCount: L_PINT; pOutBestConfig: pFASTCONFIG ): L_INT;
Overview | Refer to Fast TWAIN (Scan Configurations).

Remarks

(Document/Medical only) Determines the best scanner configuration.

This method will test scan configurations for the scanner selected by calling SelectSource. It will update the pOutBestConfig parameter with the best scan configuration tested. Once the best scan configuration has been determined, the scan configuration's values for the transfer mode, bits per pixel, format and buffer size can be passed to AcquireMulti method so the images can be scanned as fast as possible.

To test user-defined/custom configurations, pass these configurations in pInFastConfigs and the number of configurations in nInFastConfigsCount.

To test the default configurations available for the Twain driver, pass Nil for pInFastConfigs and 0 for nInFastConfigsCount. In this case, the method will test scan configurations based the values passed in the nBitsPerPixel and nBufferIteration parameters.

The list of default scan configurations to test can be shortened by using the GetScanConfigs method to get a list of default scan configurations based on transfer mode, bits per pixel and number of buffers. This list can then be passed to FindFastConfig method to determine the best and fastest scan configuration.

If LTWAIN_CHECK_ALL_DEFAULT_BPP is set in uFlags then the method will test all supported bits per pixel for the selected scanner. If this flag is not set in uFlags, then the method will use the iBitsPerPixel parameter value.

If LTWAIN_USE_THREAD_MODE is set in uFlags, then the image acquisition process will run in thread mode. In some scanners, acquiring images in thread will improve the speed at which the image(s) is(are) acquired. In other scanners, high-speed scanners, for example, acquiring the image(s) in thread mode will provide little to no improvement in the speed at which the image(s) is(are) acquired.

The nBitsPerPixel parameter and LTWAIN_CHECK_ALL_DEFAULT_BPP flag will be used only if the transfer mode for the scan configuration being tested is LTWAIN_BUFFER_MODE or LTWAIN_NATIVE_MODE.

The nBufferIteration parameter will be used only if the transfer mode for the scan configuration being tested is LTWAIN_BUFFER_MODE.

If a valid callback method is passed for pfnCallBack, the scan configuration testing process can be stopped by returning any value other than SUCCESS for the callback method. The testing process is continued by returning SUCCESS for the callback method.

This method allocates storage for the array of scan configurations in ppTestConfigs. When this storage is no longer needed, you must free the storage by calling FreeScanConfig.

See Also

Elements: | Acquire method, InitSession method, EndSession method, OpenTemplateFile method, CloseTemplateFile method, ShowTemplateDlg method, AddCapabilityToFile method, GetNumOfCapsInFile method, GetCapabilityFromFile method, AcquireMulti method, GetScanConfigs method, FreeScanConfig method.
Topics: | TWAIN Functionality: Fast TWAIN (Scan Configuration).


FreeContainer method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int FreeContainer(pTW_CAPABILITY pCapability);
Delphi Syntax | Function FreeContainer (pCapability: pTW_CAPABILITY ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Frees the container of the specified structure.

The container in the TW_CAPABILITY structure will be internally freed.

This is a container that was allocated by one of the following methods:

CreateNumericContainerOneValue

CreateNumericContainerArray

CreateNumericContainerEnum

CreateNumericContainerRange

See Also

Elements: | CreateNumericContainerOneValue method, CreateNumericContainerArray method, CreateNumericContainerEnum method, CreateNumericContainerRange method.
Topics: | TWAIN Functionality: Containers.


FreeExtendedImageInfoStructure method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int FreeExtendedImageInfoStructure(ppTW_EXTIMAGEINFO pptwExtImgInfo);
Delphi Syntax | Function FreeExtendedImageInfoStructure (pptwExtImgInfo: ppTW_EXTIMAGEINFO ): L_INT;
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Frees the TW_EXTIMAGEINFO structure.

This method will free the TW_EXTIMAGEINFO structure allocated by the GetExtendedImageInfo method.

For more information on extended image information, refer to the Twain 1.9 Specification, available at www.twain.org.

See Also

Elements: | GetExtendedImageInfo method.
Topics: | TWAIN Functionality: Extended Image Information


FreePropQueryStructure method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int FreePropQueryStructure(ppLTWAINPROPERTYQUERY ppltProperty);
Delphi Syntax | Function FreePropQueryStructure (ppltProperty: ppLTWAINPROPERTYQUERY ): L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Frees the pointer to the specified structure.

ppltProperty parameter was allocated by calling the QueryProperty method.

The ppltProperty parameter will be internally freed.

See Also

Elements: | QueryProperty method.
Topics: | TWAIN Functionality: Images


FreeScanConfig method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int FreeScanConfig(ppFASTCONFIG ppFastConfig, int nFastConfigCount);
Delphi Syntax | Function FreeScanConfig (ppFastConfig: ppFASTCONFIG; nFastConfigCount: L_INT ): L_INT;
Overview | Refer to Fast TWAIN (Scan Configurations).

Remarks

(Document/Medical only) Frees storage allocated for a scan configuration array.

Call this method to free the memory allocated by the FindFastConfig and GetScanConfigs methods.

This method should be called when your program no longer needs the array of FASTCONFIG structures.

See Also

Elements: | Acquire method, InitSession method, EndSession method, OpenTemplateFile method, CloseTemplateFile method, ShowTemplateDlg method, AddCapabilityToFile method, GetNumOfCapsInFile method, GetCapabilityFromFile method, AcquireMulti method, FindFastConfig method, GetScanConfigs method
Topics: | TWAIN Functionality: Fast TWAIN (Scan Configuration).


GetCapability method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetCapability(pTW_CAPABILITY pCapability, unsigned uFlags);
Delphi Syntax | Function GetCapability (pCapability:pTW_CAPABILITY; uFlags:L_UINT):L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Gets the specified capability value(s).

See Also

Elements: | SetProperties method, GetProperties method, SetCapability method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Capabilities.


GetCapabilityFromFile method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetCapabilityFromFile(HTWAINTEMPLATEFILE hFile, ppTW_CAPABILITY ppCapability, unsigned uIndex);
Delphi Syntax | Function GetCapabilityFromFile (hFile: HTWAINTEMPLATEFILE; ppCapability: ppTW_CAPABILITY; uIndex: L_UINT ): L_INT;
Overview | Refer to Handling Template Files.

Remarks

Gets the capability, at the specified index, in the specified file.

To get a capability stored in a file; the file must be opened for reading by calling OpenTemplateFile method. The user must declare a variable of type pTW_CAPABILITY and pass the address of this to the method. This parameter will be updated with a pointer to the capability at the specified index.

Note:

If the method is successful, the user must do the following:

Free the container of the TW_CAPABILITY structure by calling FreeContainer method.

Free the value referenced by the contents of the ppCapability using GlobalUnlock and GlobalFree.

See Also

Elements: | OpenTemplateFile method, AddCapabilityToFile method, ShowTemplateDlg method, GetNumOfCapsInFile method, CloseTemplateFile method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Capabilities.


GetExtendedImageInfo method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetExtendedImageInfo(pTW_EXTIMAGEINFO ptwExtImgInfo);
Delphi Syntax | Function GetExtendedImageInfo (ptwExtImgInfo:pTW_EXTIMAGEINFO): L_INT;
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Gets the extended image information related to the image acquired by the Acquire method.

This method can only be called during the OnAcquirePageEvent Event, which is called by the Acquire method, and only after a page has been acquired from a TWAIN source.

Extended image information can be Barcode texts, Barcode data, etc. For more information on extended image information, refer to the Twain 1.9 Specification, available at www.twain.org.

See Also

Elements: | Acquire method, OnAcquirePageEvent Event, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Extended Image Information


GetExtendedInfo method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetExtendedInfo(pTW_EXTIMAGEINFO ptwExtImgInfo, int nIndex, pTW_INFO ptwInfo);
Delphi Syntax | Function GetExtendedInfo (ptwExtImgInfo: pTW_EXTIMAGEINFO; nIndex: L_INT; ptwInfo: pTW_INFO ): L_INT;
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Gets the image info by the specified index in nIndex parameter from the extended image info structure ptwExtImgInfo parameter.

You should free the extended image info when application doesn’t require that information by calling FreeExtendedImageInfoStructure method.

See Also

Elements: | CreateExtendedInfo method, Acquire method, OnAcquirePageEvent Event, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Extended Image Information.


GetNumericContainerBOOLValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerBOOLValue(pTW_CAPABILITY pCapability, int nIndex, L_PBOOL pbValue);
Delphi Syntax | Function GetNumericContainerBOOLValue (pCapability: pTW_CAPABILITY; nIndex: L_INT; pbValue: L_PBOOL ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

Use this method to get a value from a container's item list when the item list type is Boolean.

See Also

Elements: | GetNumericContainerItemType method, GetNumericContainerINTValue method, GetNumericContainerUINTValue method, GetNumericContainerFIX32Value method, GetNumericContainerFRAMEValue method, GetNumericContainerSTRINGValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerFIX32Value method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerFIX32Value(pTW_CAPABILITY pCapability, int nIndex, pTW_FIX32 ptwFix);
Delphi Syntax | Function GetNumericContainerFIX32Value (pCapability: pTW_CAPABILITY; nIndex: L_INT; ptwFix: pTW_FIX32 ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

Use this method to get a value from a container's item list when the item list type is TW_FIX32.

See Also

Elements: | GetNumericContainerItemType method, GetNumericContainerINTValue method, GetNumericContainerUINTValue method, GetNumericContainerBOOLValue method, GetNumericContainerFRAMEValue method, GetNumericContainerSTRINGValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerFRAMEValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerFRAMEValue(pTW_CAPABILITY pCapability, int nIndex, pTW_FRAME ptwFrame);
Delphi Syntax | Function GetNumericContainerFRAMEValue (pCapability: pTW_CAPABILITY; nIndex: L_INT; ptwFrame: pTW_FRAME ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

Use this method to get a value from a container's item list when the item list type is TW_FRAME.

See Also

Elements: | GetNumericContainerItemType method, GetNumericContainerINTValue method, GetNumericContainerUINTValue method, GetNumericContainerBOOLValue method, GetNumericContainerFIX32Value method, GetNumericContainerSTRINGValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerINTValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerINTValue(pTW_CAPABILITY pCapability, int nIndex, L_PINT pnValue);
Delphi Syntax | Function GetNumericContainerINTValue (pCapability: pTW_CAPABILITY; nIndex: L_INT; pnValue: L_PINT ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

Use this method to get a value from a container's item list when the item list type is integer.

See Also

Elements: | GetNumericContainerItemType method, GetNumericContainerUINTValue method, GetNumericContainerBOOLValue method, GetNumericContainerFIX32Value method, GetNumericContainerFRAMEValue method, GetNumericContainerSTRINGValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerItemType method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerItemType(pTW_CAPABILITY pCapability, L_PINT pnItemType);
Delphi Syntax | Function GetNumericContainerItemType (pCapability: pTW_CAPABILITY; pnItemType: L_PINT ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the item type of the container of the specified capability.

See Also

Elements: | GetNumericContainerINTValue method, GetNumericContainerUINTValue method, GetNumericContainerBOOLValue method, GetNumericContainerFIX32Value method, GetNumericContainerFRAMEValue method, GetNumericContainerSTRINGValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerSTRINGValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerSTRINGValue(pTW_CAPABILITY pCapability, int nIndex, const char * twString);
Delphi Syntax | Function GetNumericContainerSTRINGValue (pCapability: pTW_CAPABILITY; nIndex: L_INT; twString: TW_STR1024 ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

Use this method to get a value from a container's item list when the item list type is TW_STR1024.

See Also

Elements: | GetNumericContainerItemType method, GetNumericContainerINTValue method, GetNumericContainerUINTValue method, GetNumericContainerBOOLValue method, GetNumericContainerFIX32Value method, GetNumericContainerFRAMEValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerUINTValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int __fastcall GetNumericContainerUINTValue(pTW_CAPABILITY pCapability, int nIndex, L_PUINT puValue);
Delphi Syntax | Function GetNumericContainerUINTValue (pCapability: pTW_CAPABILITY; nIndex: L_INT; puValue: L_PUINT ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

Use this method to get a value from a container's item list when the item list type is unsigned integer.

See Also

Elements: | GetNumericContainerItemType method, GetNumericContainerINTValue method, GetNumericContainerBOOLValue method, GetNumericContainerFIX32Value method, GetNumericContainerFRAMEValue method, GetNumericContainerSTRINGValue method.
Topics: | TWAIN Functionality: Containers.


GetNumericContainerValue method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumericContainerValue(pTW_CAPABILITY pCapability, int nIndex, void * ppValue);
Delphi Syntax | FunctionGetNumericContainerValue (pCapability: pTW_CAPABILITY; nIndex: L_INT; ppValue: Pointer ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the specified value from a container.

See Also

Elements: | CreateNumericContainerOneValue method, CreateNumericContainerEnum method, CreateNumericContainerArray method, CreateNumericContainerRange method, FreeContainer method.
Topics: | TWAIN Functionality: Containers.


GetNumOfCapsInFile method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetNumOfCapsInFile(HTWAINTEMPLATEFILE hFile, L_PUINT puCapCount);
Delphi Syntax | Function GetNumOfCapsInFile (hFile: HTWAINTEMPLATEFILE; puCapCount: L_PUINT ): L_INT;
Overview | Refer to Handling Template Files.

Remarks

Gets the number of stored capabilities from the specified file.

The template file must be opened for reading by calling OpenTemplateFile method.

See Also

Elements: | OpenTemplateFile method, AddCapabilityToFile method, GetCapabilityFromFile method, ShowTemplateDlg method, CloseTemplateFile method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Capabilities.


GetProperties method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetProperties(pLTWAINPROPERTIES pProperties, unsigned uFlags);
Delphi Syntax | Function GetProperties (pProperties: pLTWAINPROPERTIES; uFlags: L_UINT ): L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Gets the current or default values of the properties defined in the LTWAINPROPERTIES structure.

This method lets the user get information on the properties contained in the LTWAINPROPERTIES structure. It is a high-level alternative to getting capabilities using the GetCapability method or the EnumCapabilities method. For more information on getting and setting TWAIN capabilities, refer to Getting and Setting Capabilities.

To set properties, use the SetProperties method.

See Also

Elements: | SetProperties method, SetCapability method, GetCapability method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Images.


GetScanConfigs method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int GetScanConfigs(int nBitsPerPixel, unsigned uTransferMode, int nBufferIteration, ppFASTCONFIG ppFastConfig, L_PINT pnFastConfigCount);
Delphi Syntax | Function GetScanConfigs (nBitsPerPixel: L_INT; uTransferMode: L_UINT; nBufferIteration: L_INT; ppFastConfig: ppFASTCONFIG; pnFastConfigCount: L_PINT ): L_INT;
Overview | Refer to Fast TWAIN (Scan Configurations).

Remarks

(Document/Medical only) Gets the default scan configurations for the given transfer mode, buffer iteration and bits per pixel.

If uTransferMode is LTWAIN_NATIVE_MODE, this method will use the value of nBitsPerPixel to determine which scan configurations to get.

If uTransferMode is LTWAIN_BUFFER_MODE, this method will use both nBitsPerPixel and nBufferIteration to determine which scan configurations to get.

If uTransferMode is LTWAIN_FILE_MODE, this method will use the value of nBitsPerPixel to determine which scan configurations to get.

This method allocates storage for the array of scan configurations in ppFastConfig. When this storage is no longer needed, you must free the storage by calling FreeScanConfig.

See Also

Elements: | Acquire method, InitSession method, EndSession method, OpenTemplateFile method, CloseTemplateFile method, ShowTemplateDlg method, AddCapabilityToFile method, GetNumofCapsInFile method, GetCapabilityFromFile method, AcquireMulti method, FindFastConfig method, FreeScanConfig method
Topics: | TWAIN Functionality: Fast TWAIN (Scan Configuration).


InitSession method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int InitSession(L_HANDLE hWind);
Delphi Syntax | Function InitSession (hWind: L_HANDLE ): L_INT;
Overview | Refer to Initializing a TWAIN Session.

Remarks

Initializes the TWAIN session.

InitSession must be called before calling any other LEADTOOLS TWAIN toolkit methods.

When the TWAIN session is no longer needed, it should be ended by calling the EndSession method. For every call to the InitSession method there must be a call to the EndSession method.

See Also

Elements: | EndSession method
Topics: | TWAIN Functionality: Twain Sessions.


IsAvailable method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | L_BOOL IsAvailable(L_HANDLE hWind);
Delphi Syntax | Function IsAvailable (hWind: L_HANDLE ): L_BOOL;
Overview | Refer to Managing the TWAIN Source.

Remarks

Determines whether a TWAIN source is installed. Possible values are:

Setting | Description
TRUE | At least one TWAIN source is installed.
FALSE | No TWAIN source is installed.

You can use this method when deciding whether to enable or disable TWAIN menu items.

See Also

Elements: | Acquire method, InitSession method, EndSession method, OpenTemplateFile method, CloseTemplateFile method, ShowTemplateDlg method, AddCapabilityToFile method, GetNumOfCapsInFile method, GetCapabilityFromFile method.
Topics: | TWAIN Functionality: Images.


IsSupportLocked method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | bool IsSupportLocked (int nType);
Delphi Syntax | IsSupportLocked (nType: L_INT): Boolean;
Overview | Refer to Unlocking Special LEAD Features.

Remarks

Indicates whether support is locked for an optional feature, such as LEADTOOLS Document/Medical capabilities.

For information about LEADTOOLS Document/Medical capabilities, contact LEAD.

To unlock a feature, use the UnlockSupport method.

See Also

Elements: | UnlockSupport method
Topics: | TWAIN Functionality: Miscellaneous Methods and Properties.


LockContainer method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int LockContainer(pTW_CAPABILITY pCapability, void * ppContainer);
Delphi Syntax | Function LockContainer (pCapability: pTW_CAPABILITY; ppContainer: Pointer ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Gets the container information for the specified capability.

This method is used to lock the container present in the TW_CAPABILITY structure. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.

Once the user has the pointer to the container, the container may be changed. When the user has finished changing the container he or she must call the UnlockContainer method. Note that this can also be accomplished using the API GlobalLock and GlobalUnlock methods.

See Also

Elements: | UnlockContainer method.
Topics: | TWAIN Functionality: Containers.


ManName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString ManName
Delphi Syntax | ManName: String
Overview | Refer to Initializing a TWAIN Session.

Remarks

(Write only) Application specific string that contains the name of the application's manufacturer. Using this property is optional.

See Also

Elements: | ProdFamily property, Version property, AppName property, SourceCount property, SourceName property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method.
Topics: | TWAIN Functionality: Applications


ManufacturerName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString ManufacturerName [int nIndex]
Delphi Syntax | ManufacturerName [nIndex: Integer]: String
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) Gets a character string that contains the manufacturer's name of the specified TWAIN source. This name is provided by the manufacturer.

See Also

Elements: | ManName property, ProdFamily property, Version property, AppName property, SourceCount property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method, FamilyName property, SelectedFamilyName property, SelectedManufacturerName property
Topics: | TWAIN Functionality: TWAIN Sources.


OnAcquireMultiEvent Event (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | void OnAcquireMultiEvent (int nPage, AnsiString strFileName, bool bFinishScan)
Delphi Syntax | OnAcquireMultiEvent (nPage: L_INT; strFileName: String; bFinishScan: Boolean )
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Called twice for each scanned page.

This event will be called twice for each scanned page. It will be called the first time when the TWAIN source begins scanning the page. It is called the second time when the TWAIN source has finished scanning the page.

See Also

Elements: | AcquireMulti method, EnableAcquireMultiEvent property.
Topics: | TWAIN Functionality: Events


OnAcquirePageEvent Event (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int OnAcquirePageEvent (TBITMAPHANDLE Bitmap)
Delphi Syntax | OnAcquirePageEvent (Bitmap: TBITMAPHANDLE ): L_INT
Overview | Refer to How to Acquire from the Twain Source.

Remarks

Called for each image being acquired from the TWAIN source to the application.

The GetExtendedImageInfo method can only be called within this event.

See Also

Elements: | Acquire method, EnableAcquirePageEvent property, GetExtendedImageInfo method.
Topics: | TWAIN Functionality: Events


OnEnumCapabilityEvent Event (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int OnEnumCapabilityEvent (unsigned uCap, pTW_CAPABILITY pCapability)
Delphi Syntax | OnEnumCapabilityEvent (uCap: L_UINT; pCapability: pTW_CAPABILITY ): L_INT
Overview | Refer to Getting and Setting Capabilities.

Remarks

Called for each capability enumerated by the EnumCapabilities method.

See Also

Elements: | EnumCapabilities method, EnableEnumCapabilityEvent property.
Topics: | TWAIN Functionality: Events


OnFastConfigEvent Event (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int OnFastConfigEvent (pFASTCONFIG pResConfig)
Delphi Syntax | OnFastConfigEvent (pResConfig: pFastConfig): L_INT
Overview | Refer to Fast TWAIN (Scan Configurations).

Remarks

Called for each configuration tested.

If you return SUCCESS, then the scan configuration testing process will be continued, otherwise, the process will be stopped.

See Also

Elements: | FindFastConfig method, EnableFastConfigEvent property.
Topics: | TWAIN Functionality: Events


OnSaveCapabilityEvent Event (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int OnSaveCapabilityEvent (pTW_CAPABILITY pCapability)
Delphi Syntax | OnSaveCapabilityEvent (pCapability: pTW_CAPABILITY ): L_INT
Overview | Refer to Handling Template Files.

Remarks

Called for each capability supported by a particular TWAIN source, before saving it to a specific template file.

The user can only modify the capability data before saving it to the specified template file.

See Also

Elements: | ShowTemplateDlg method, EnableSaveCapabilityEvent property.
Topics: | TWAIN Functionality: Events


OnSetPropertiesEvent Event (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int OnSetPropertiesEvent (unsigned uCap, int nStatus, void * pValue)
Delphi Syntax | OnSetPropertiesEvent (uCap: L_UINT; nStatus: L_INT; pValue: L_PVOID ): L_INT
Overview | Refer to Getting and Setting CapabilitiesCapabilitiesNegotiations.

Remarks

Called for each property to set.

See Also

Elements: | SetProperties method, EnableSetPropertiesEvent property.
Topics: | TWAIN Functionality: Events


OpenTemplateFile method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int OpenTemplateFile(pHTWAINTEMPLATEFILE phFile, AnsiString strTemplateFile, unsigned uAccess);
Delphi Syntax | Function OpenTemplateFile (phFile: pHTWAINTEMPLATEFILE; strTemplateFile: String; uAccess: L_UINT ): L_INT;
Overview | Refer to Handling Template Files.

Remarks

Opens the specified template file for either reading or writing, but not both.

For more information on template files, refer to Handling Template Files.

When a file is opened for writing, a new file is created.

See Also

Elements: | ShowTemplateDlg method, AddCapabilityToFile method, GetCapabilityFromFile method, GetNumOfCapsInFile method, CloseTemplateFile method, InitSession method, EndSession method
Topics: | TWAIN Functionality: Template Files.


ProdFamily property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString ProdFamily
Delphi Syntax | ProdFamily: String
Overview | Refer to Initializing a TWAIN Session.

Remarks

(Write only) Application specific string that contains the product family name. Using this property is optional.

See Also

Elements: | ManName property, Version property, AppName property, SourceCount property, SourceName property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method.
Topics: | TWAIN Functionality: Applications


QueryProperty method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int QueryProperty(unsigned uCapability, ppLTWAINPROPERTYQUERY ppProperty);
Delphi Syntax | Function QueryProperty (uCapability: L_UINT; ppProperty: ppLTWAINPROPERTYQUERY ): L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Gets the available property values.

Getting these values can help in determining what values a certain TWAIN source supports for a certain capability or property.

See Also

Elements: | GetProperties method, SetCapability method, GetCapability method, InitSession method, EndSession method
Topics: | TWAIN Functionality: Images


SelectedFamilyName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString SelectedFamilyName
Delphi Syntax | SelectedFamilyName: String
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) Gets a character string that contains the family name of the selected TWAIN source. This name is provided by the manufacturer.

See Also

Elements: | FamilyName property, ManufacturerName property, SelectedManufacturerName property, ManName property, ProdFamily property, Version property, AppName property, SourceCount property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method.
Topics: | TWAIN Functionality: TWAIN Sources.


SelectedManufacturerName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString SelectedManufacturerName
Delphi Syntax | SelectedManufacturerName: String
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) Gets a character string that contains the manufacturer's name of the selected TWAIN source. This name is provided by the manufacturer.

See Also

Elements: | ManufacturerName property, SelectedFamilyName property, FamilyName property, ManName property, ProdFamily property, Version property, AppName property, SourceCount property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method.
Topics: | TWAIN Functionality: TWAIN Sources.


SelectedSourceName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString SelectedSourceName
Delphi Syntax | SelectedSourceName: String
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) String that contains the name of the selected TWAIN source. This name is provided by the manufacturer.

See Also

Elements: | SourceName property, ManName property, ProdFamily property, Version property, AppName property, SourceCount property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method, AcquireSourceName property
Topics: | TWAIN Functionality: TWAIN Sources.


SelectSource method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int SelectSource(void);
Delphi Syntax | Function SelectSource ( ): L_INT;
Overview | Refer to Managing the TWAIN Source.

Remarks

Displays the TWAIN dialog box to be used to select a TWAIN source for acquiring images.

See Also

Elements: | InitSession method, EndSession method, AcquireSourceName property
Topics: | TWAIN Functionality: Images.


SetCapability method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int SetCapability(pTW_CAPABILITY pCapability, unsigned uFlags);
Delphi Syntax | Function SetCapability (pCapability:pTW_CAPABILITY; uFlags: L_UINT): L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Sets the value of the specified capability.

See Also

Elements: | SetProperties method, GetProperties method, GetCapability method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Capabilities.


SetProperties method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int SetProperties(pLTWAINPROPERTIES pProperties, unsigned uFlags);
Delphi Syntax | Function SetProperties (pProperties: pLTWAINPROPERTIES; uFlags: L_UINT ): L_INT;
Overview | Refer to Getting and Setting Capabilities.

Remarks

Sets predefined capabilities of the TWAIN source in the form of properties.

The method can set the values of the properties to the values specified in the LTWAINPROPERTIES structure or it can reset the values defined in the structure to their default values defined by the TWAIN source.

See Also

Elements: | GetProperties method, SetCapability method, GetCapability method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Images


ShowTemplateDlg method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int ShowTemplateDlg(AnsiString strTemplateFile);
Delphi Syntax | Function ShowTemplateDlg (strTemplateFile: String ): L_INT;
Overview | Refer to Handling Template Files.

Remarks

Displays the TWAIN source manufacturer's template dialog, without actually acquiring an image.

This method saves the current values of all the supported capabilities to the specified file.

See Also

Elements: | OpenTemplateFile method, AddCapabilityToFile method, GetCapabilityFromFile method, GetNumOfCapsInFile method, CloseTemplateFile method, InitSession method, EndSession method.
Topics: | TWAIN Functionality: Template Files.


SourceCount property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int SourceCount
Delphi Syntax | SourceCount: Integer
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) Contains the number of available TWAIN sources installed on the system.

This property is updated when the SelectSource method is called.

See Also

Elements: | SourceName property, ManName property, ProdFamily property, Version property, AppName property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method, AcquireSourceName property
Topics: | TWAIN Functionality: TWAIN Sources.


SourceName property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString SourceName[int nIndex]
Delphi Syntax | SourceName[nIndex: Integer]: String
Overview | Refer to Managing the TWAIN Source.

Remarks

(Read only) String that contains the name of the specified TWAIN source. This name is provided by the manufacturer.

See Also

Elements: | SelectedSourceName Property, ManName property, ProdFamily property, Version property, AppName property, SourceCount property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method, AcquireSourceName property
Topics: | TWAIN Functionality: TWAIN Sources.


UnlockContainer method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | int UnlockContainer(pTW_CAPABILITY pCapability);
Delphi Syntax | Function UnlockContainer (pCapability: pTW_CAPABILITY ): L_INT;
Overview | Refer to How to Work with the Containers.

Remarks

Sets the container information of the specified capability.

This method is used to unlock the container present in the TW_CAPABILITY stucture. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.

To access the container so that it may be modified, call LockContainer method. This method provides the user with a pointer to the container. At this point the container may be changed. When the user has finished changing the container he or she must call UnlockContainer to unlock the container. Note that this can also be accomplished using the API GlobalLock and GlobalUnlock methods.

See Also

Elements: | LockContainer method
Topics: | TWAIN Functionality: Containers.


UnlockSupport method (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | void UnlockSupport (int nType, AnsiString strKey);
Delphi Syntax | UnlockSupport (nType:L_INT; strKey:String);
Overview | Refer to Unlocking Special LEAD Features.

Remarks

Unlocks support for an optional feature, such as LEADTOOLS Document/Medical capabilities.

For information about LEADTOOLS Document/Medical capabilities, contact LEAD.

See Also

Elements: | IsSupportLocked method
Topics: | TWAIN Functionality: Miscellaneous Methods and Properties


Version property (Twain Control)

C++ Builder example

Delphi 4.0 example

Builder Syntax | AnsiString Version
Delphi Syntax | Version: String
Overview | Refer to Initializing a TWAIN Session.

Remarks

(Write only) Application specific string that contains the version information.

See Also

Elements: | ManName property, ProdFamily property, AppName property, SourceCount property, SourceName property, InitSession method, EndSession method, SelectSource method, SetCapability method, GetCapability method, Acquire method, ShowTemplateDlg method.
Topics: | TWAIN Functionality: Applications


Document/Medical Support and Licensing Requirements

Document/Medical Licensing and Royalty Agreements:

Congratulations! You have licensed one of the LEADTOOLS Document/Medical software products, the most comprehensive imaging toolkits on the market, enabling you to create powerful imaging applications. The license terms for LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite require runtime licensing based on the number of copies of your application that you deploy (i.e., distribute or install and use internally).

By paying the initial box price for the applicable LEADTOOLS product, you have obtained a development license, which entitles you to develop your application and test it. Once completed, if you wish to distribute the application or deploy it internally on multiple machines, you are required to enter into a duplication and distribution agreement with LEAD. You have the ability to choose from several licensing options depending on your volume needs.

The product you are installing is a fully functional working version and includes support for all features in LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite. (Depending on which product you have licensed, some of the features may ultimately not be available to you. See the on-line help file for a product feature comparison.) Until you sign and return the correct licensing agreement, your application will display a "nag" message. Once LEAD receives the executed contract, we will provide you a password that will permit you to terminate the "nag" message for the product that you have licensed. In addition to providing the password, you must also use the no nag version of the LTKRN14N.DLL, found in the REDIST\NONAGLTKRN directory. This is also the version you must redistribute.

Duplication and Distribution Agreements

Click this button to start the Licensing help file to review the License Agreements governing your use of the software.


LEADTOOLS Documentation

LEADTOOLS Reference Manuals

LEADTOOLS provides reference manuals that contain the same information as the online help. You can print them from PDF files. Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.

To print the PDF files, you must use the Adobe Acrobat Reader 3.0 or higher. You can download a copy of the Acrobat Reader from the Adobe web site (http://www.adobe.com). Note that different versions of the Acrobat Reader are available for different operating systems, but they all can read the same PDF files.


Raster Pro/Document/Medical Features

Raster Pro:

LEADTOOLS Raster Imaging Pro provides some imaging capabilities that are not available in the LEADTOOLS Raster Imaging product. In order to access these features, you must unlock them by calling UnlockSupport (L_SUPPORT_LTPRO, L_KEY_LTPRO). L_KEY_LTPRO can be found in ltkey.h.

If you are a licensed user of LEADTOOLS Raster Imaging, and would like to access Raster Imaging Pro features, you must contact Tech Support for information on obtaining a license and the unlock key for calling LSettings::UnlockSupport.

Document/Medical:

LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite are the most comprehensive imaging toolkits on the market. No other toolkit provides as many imaging features for color, gray-scale and black & white images in one development package, and for one price. These toolkits comprise LEAD's best code and are designed for the programmer who is looking for the fastest performance, and/or the most extensive color, document, and medical imaging capabilities available.

These toolkits contain powerful annotation capabilities and optimized document image processing filters, and high performance compression, decompression and viewing of JPEG, LEAD CMP, MRC and CCITT G3/G4. The annotation capabilities enable the programmer to add text, highlights, sticky notes, audio, ellipses, buttons, lines, arrows, rectangles, polygons, redaction (blackout), hotspots, freehand scribble, pointers, bitmap and text stamps, to black & white and color images. Programmers working with document imaging will also find special processing filters such as despeckle, deskew, favor black, and scale to gray to enhance their black and white 1 bit images. Additionally, you can achieve faster rotation in 90-degree increments by applying a rotated view perspective to the bitmap. These LEADTOOLS toolkits offer the fastest software-only JPEG decoder available.

LEADTOOLS Document Imaging

The LEADTOOLS Document Imaging toolkit contains all the features available in the LEADTOOLS Raster Imaging Pro. In addition, it contains the following capabilities:

Special functions for Document (bitonal) images. The LEADTOOLS functions for bitonal images are especially useful for working with images from black-and-white scanners or FAX machines. These functions let you do things such as automatically straighten (deskew) an image, remove spots (despeckle), or clarify a scaled display (using scale-to-gray and favor-black features).

Annotation. LEADTOOLS supports annotation of images by letting you overlay images with text, lines, shapes, arrows, buttons, highlights, hot spots, sticky notes, stamps, buttons, and sounds.

Fast rotation. LEADTOOLS achieves fast rotation in 90-degree increments by applying a rotated view perspective to the bitmap.

ISIS support. LEADTOOLS supports ISIS interfaces for driving scanning devices.

Faster compression and decompression. The Document/Medical editions work faster when loading and saving LEAD CMP, JPEG, and CCITT Group 3 and Group 4 images. The LEADTOOLS functions for loading and saving are the same in all products. The only difference is in performance.

1-bit Image Clean-up. The Document toolkits include support for removing dots, blobs, holes, inverted text, lines, borders, bumps and nicks from 1-bit images.

Region Clean-up. [Document/Medical] Remove all the holes from a region.

Embedded Messages. The Document toolkits include support for embedding messages in lossless image formats like bmp, tiff, lossless jpeg, etc. The message is embedded without any visible changes to the image, and does not appreciably increase the size of the image. The message is password-protected.

Image Conversion. The Document toolkits include support for transforming a bitmap into a binary image using specified thresholds or a threshold calculated automatically based on statistical features of the bitmap.

12 and 16 bit grayscale images. [Document/Medical] Load, process, display, window level and save 12 and 16 bit grayscale images (including support for 16-bit grayscale TIFF).

48 and 64 bit color images. [Document/Medical] Load, process, display, and save 48 and 64 bit color images.

MRC Support. [Document/Medical] LEADTOOLS supports the Mixed Raster Content format for color documents containing mixed image and text components. For more information, refer to the .

Halftoning. [Document/Medical] Convert 1-, 4-, 8-, 16-, 24-, or 32-bit bitmaps to a halftoned bitmap, with a specified pattern rotation. A halftoned bitmap is a 1-bit bitmap that has been dithered for black and white printing or display.

LEADTOOLS Document Imaging Suite

The LEADTOOLS Document Imaging Suite toolkit contains all the capabilities of LEADTOOLS Document Imaging, and includes the features listed below. Please note that the OCR features are included in this toolkit, however they can also be purchased as a plug-in for the LEADTOOLS Document Imaging toolkit. Also, JBIG support is provided in this toolkit, however a JBIG Module may be added on to LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging or LEADTOOLS Medical Imaging Suite.

OCR features. [Document/Medical] LEAD offers OCR features that use Scansoft Textbridge technology. Support for these features is included in the LEADTOOLS Document Imaging Suite, and can be added, via plug-in to the LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite toolkits. The OCR features allow you to perform optical character recognition and turn images into documents. Features include preset confidence and accuracy levels for controlling how sensitive the engine is to unrecognized text, artificial intelligence for improving recognition on documents of the same type, and built-in and user-defined lexicons for limiting the type of text to recognize within a particular zone. LEADTOOLS provides the ability to verify or correct text during, and (using LEAD's unique OCR editor) after recognition. LEAD's OCR editor ties the text being edited directly to the image, providing a visual reference to the original bitmap data. The OCR engine can perform Automatic area segmentation creating multi-layered zones, recognizing areas such as tables, rules, images and text. Or, you can manually designate up to 250 such zones. The OCR features support different fonts, sizes (5 to 72 point) and styles. Fax, dot matrix and halftones can be preprocessed to improve recognition results. The OCR Engine supports major European and Scandinavian languages (Danish, Dutch, Finnish, French, German, Italian, Norwegian, Portuguese, Russian, Spanish, and Swedish) as well as English. Support for dialects such as US. English, French Canadian, Latin American Spanish, Swiss German, and Brazilian Portuguese is also provided.

Recognized text can be exported to more than 40 different formats, including MS Word, MS Excel, Dbase andWordPerfect. The LEADTOOLS OCR features contain superior OCR processing speeds, for use in form recognition and processing applications.

LEAD's JBIG filter. [Document/Medical] LEAD includes support for this filter in the LEADTOOLS Document Imaging Suite toolkit. Support for this filter can be added to LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging or LEADTOOLS Medical Imaging Suite by purchasing the JBIG Module. JBIG defines a method for lossless compression encoding of a bi-level image (two-color image). This method can also be used for coding grayscale and color images. LEADTOOLS completely supports all three types of images, giving you the ability to make full use of this powerful compression technology. LEADTOOLS also supports the progressive capability of JBIG, allowing you to store and send multiple representations of images at different resolutions without any extra storage overhead.

LEADTOOLS Medical Imaging

LEADTOOLS Medical Imaging contains all the capabilities of LEADTOOLS Document Imaging. It also includes general medical imaging technologies (1-16,24,32 bit color, 1-16 bit grayscale and window leveling of 12 and 16-bit grayscale images) and support for the DICOM file format.

DICOM file support. [Medical] LEADTOOLS Medical Imaging provides COMPLETE support for the DICOM 3.0 specification, including all standard IOD classes and modalities (CR, CT, MR, NM, US, RF, SC, VL, etc.) and complete DICOM Basic Directory support.

Window leveling. [Document/Medical] Detect and set LowBit and HighBit for image data, display images with automatic LUT intensity expansion, or set LUT entries and ranges with specific values and gradients. Display images through the LUT without changing the data, or process the image data using the LUT. Linearize the number of pixels locally in a bitmap, based on the specified color space in order to bring out the detail in dark areas of an image, and smooth the edges between blocks.

Medical Imaging Processing. [Medical] LEADTOOLS Medical Imaging provides image processing functionality designed specifically to allow you to examine and improve the quality of medical images.

LEADTOOLS Medical Imaging Suite

LEADTOOLS Medical Imaging Suite contains all the capabilities of LEADTOOLS Medical Imaging. In addition, it supports the following:

DICOM Communication support. [Medical Suite] LEADTOOLS provides COMPLETE support for DICOM Communications, including all Service Classes (Verification, Storage, Query/Retrieve, Patient Management, etc), and contains high-level communications functions simplifying the creation of DICOM client/server applications.

(Document/Medical) is used in the documentation to designate the features that are available in LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite. Those features that are available only in the Medical toolkits are indicated in the documentation by (Medical). Features available only in the LEADTOOLS Medical Imaging Suite toolkit are indicated in the documentation by (Medical Suite).

(Internet only) is used in the documentation to designate the features that are available only in the LEADTOOLS Internet toolkit.

For more information, refer to Document/Medical Edition Support and Licensing Requirements.


Topic Selection

LEAD Technologies, Inc.
Suite 400
1201 Greenwood Cliff
Charlotte, NC 28204

Sales@Leadtools.com
www.leadtools.com

(704) 332-5532
FAX: (704) 372-8161
Tech Support: (704) 372-9681

LEADTOOLS is ideal for developers involved in still frame, multimedia, document, medical, and vector imaging projects, including Internet/Intranet applications. Independent of the specific application requirement – scanning, file format support/conversion, compression, image processing, annotation, database support, multimedia, etc. – LEADTOOLS provides the most comprehensive, robust, flexible, and powerful imaging solution available.

Click this button to start the Licensing help file to review the License Agreements governing your use of the software.

Click this button to start the Products help file to review the full line of LEADTOOLS Products.

Click this button to start the Imaging help file to review the full line of LEADTOOLS Image Categories.


Return for Acquire

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


bMultiPageFile Parameter For AcquireMulti

bMultiPageFile

Flag that indicates whether to save multiple images into a single multi-page file, or into a series of single page files. Possible values are:

Value | Meaning
TRUE | The scanned images will be saved in one multi-page file.
FALSE | Each scanned image will be saved in a separate file. Notice that it the format doesn't support multi-page files, then each scanned page will be saved in a separate file.


bUsePreferredBuffer Parameter For AcquireMulti

bUsePreferredBuffer

Flag that indicates whether to use the user-defined buffer size or the Twain driver preferred buffer size. Possible values are:

Value | Meaning
TRUE | Use the Twain driver preferred buffer size.
FALSE | Use the user-defined buffer size in the uUserBufSize parameter.


Return for AcquireMulti

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nBitsPerPixel Parameter For AcquireMulti

nBitsPerPixel

Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Formats of Output Files . If nBitsPerPixel is 0, the file will be stored using the closest BitsPerPixel value supported by that format.


nFormat Parameter For AcquireMulti

nFormat

Output file format. For valid values, refer to Formats of Output Files .


strBaseFileName Parameter For AcquireMulti

strBaseFileName

String variable contains the base name of the image file(s) in which to save the acquired data.


uFlags Parameter For AcquireMulti

uFlags

Flag that indicates whether to display the manufacturer's user interface. Possible values are:

Value | Meaning
LTWAIN_SHOW_NONE | [0] Do not show the manufacturer's user interface.
LTWAIN_SHOW_USER_INTERFACE | [1] Show the manufacturer's user interface as modeless.
LTWAIN_MODAL_USER_INTERFACE | [2] Show the manufacturer's user interface as a modal dialog. Works only if the LTWAIN_SHOW_USER_INTERFACE flag is set.


uTransferMode Parameter For AcquireMulti

uTransferMode

Flag that indicates the transfer mode to use when acquiring the image(s). Possible values are:

Value | Meaning
LTWAIN_FILE_MODE | [$001] Use the File transfer mode
LTWAIN_BUFFER_MODE | [$002] Use the Memory transfer mode
LTWAIN_NATIVE_MODE | [$004] Use the Native transfer mode


uUserBufSize Parameter For AcquireMulti

uUserBufSize

User-defined buffer size. This value will be used if uTransferMode is LTWAIN_BUFFER_MODE and the bUsePreferredBuffer parameter is FALSE. This value must be a multiple of 16.


uFlags Parameter For Acquire

uFlags

Flag that indicates whether to display the manufacturer's user interface. Possible values are:

Value | Meaning
LTWAIN_SHOW_NONE | [0] Do not show the manufacturer's user interface.
LTWAIN_SHOW_USER_INTERFACE | [1] Shows the manufacturer's user interface as modeless.
LTWAIN_MODAL_USER_INTERFACE | [2] Shows the manufacturer's user interface as a modal dialog. Works only if the LTWAIN_SHOW_USER_INTERFACE flag is set.


hFile Parameter For AddCapabilityToFile

hFile

Handle to an existing template file.


Return for AddCapabilityToFile

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For AddCapabilityToFile

pCapability

Pointer to a structure that contains the capability to add.


hFile Parameter For CloseTemplateFile

hFile

Handle to an existing template file.


Return for CloseTemplateFile

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


Return for CreateExtendedInfo

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


ntwInfoCount Parameter For CreateExtendedInfo

ntwInfoCount

Specifies the image info count that will be used to allocate the pptwExtImgInfo parameter.


pptwExtImgInfo Parameter For CreateExtendedInfo

pptwExtImgInfo

Address of the pointer to the TW_EXTIMAGEINFO structure, the method will automatically allocate TW_EXTIMAGEINFO structure using the total number of image info.


ptwInfo Parameter For CreateExtendedInfo

ptwInfo

Array of the image info that will be filled with the in pptwExtImgInfo parameter.


Return for CreateNumericContainerArray

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nType Parameter For CreateNumericContainerArray

nType

Type of data contained in the TW_ARRAY container. Possible values are:

Value | Meaning
TWAINNUMERICTYPE_TW_INT8 | The variable is of type L_CHAR or char.
TWAINNUMERICTYPE_TW_INT16 | The variable is of type L_INT16 or short.
TWAINNUMERICTYPE_TW_INT32 | The variable is of type L_INT32 or long.
TWAINNUMERICTYPE_TW_UINT8 | The variable is of type L_UCHAR or unsigned char.
TWAINNUMERICTYPE_TW_UINT16 | The variable is of type L_UINT16 or unsigned short.
TWAINNUMERICTYPE_TW_UINT32 | The variable is of type L_UINT32 or unsigned long.
TWAINNUMERICTYPE_TW_BOOL | The variable is of type L_BOOL or BOOL.
TWAINNUMERICTYPE_TW_FIX32 | The variable is of type TW_FIX32(TWAIN defined structure).
TWAINNUMERICTYPE_TW_FRAME | The variable is of type TW_FRAME(TWAIN defined structure).
TWAINNUMERICTYPE_TW_STR32 | The variable is of type L_CHAR[32].
TWAINNUMERICTYPE_TW_STR64 | The variable is of type L_CHAR[64].
TWAINNUMERICTYPE_TW_STR128 | The variable is of type L_CHAR[128].
TWAINNUMERICTYPE_TW_STR255 | The variable is of type L_CHAR[255].
TWAINNUMERICTYPE_TW_STR1024 | The variable is of type L_CHAR[1024].
TWAINNUMERICTYPE_TW_UNI512 | The variable is of type wchar_t[512].


pCapability Parameter For CreateNumericContainerArray

pCapability

Pointer to a structure that contains the capability container to allocate as type TW_ARRAY.


pDataParameter For CreateNumericContainerArray

pData

Pointer to an allocated array of type TW_ARRAY that has been initialized with the appropriate data and size information.


uNumOfItems Parameter For CreateNumericContainerArray

uNumOfItems

Number of items in the array.


Return for CreateNumericContainerEnum

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nType Parameter For CreateNumericContainerEnum

nType

Type of data contained in the TW_ENUMERATION container. Possible values are:

Value | Meaning
TWAINNUMERICTYPE_TW_INT8 | The variable is of type L_CHAR or char.
TWAINNUMERICTYPE_TW_INT16 | The variable is of type L_INT16 or short.
TWAINNUMERICTYPE_TW_INT32 | The variable is of type L_INT32 or long.
TWAINNUMERICTYPE_TW_UINT8 | The variable is of type L_UCHAR or unsigned char.
TWAINNUMERICTYPE_TW_UINT16 | The variable is of type L_UINT16 or unsigned short.
TWAINNUMERICTYPE_TW_UINT32 | The variable is of type L_UINT32 or unsigned long.
TWAINNUMERICTYPE_TW_BOOL | The variable is of type L_BOOL or BOOL.
TWAINNUMERICTYPE_TW_FIX32 | The variable is of type TW_FIX32(TWAIN defined structure).
TWAINNUMERICTYPE_TW_FRAME | The variable is of type TW_FRAME(TWAIN defined structure).
TWAINNUMERICTYPE_TW_STR32 | The variable is of type L_CHAR[32].
TWAINNUMERICTYPE_TW_STR64 | The variable is of type L_CHAR[64].
TWAINNUMERICTYPE_TW_STR128 | The variable is of type L_CHAR[128].
TWAINNUMERICTYPE_TW_STR255 | The variable is of type L_CHAR[255].
TWAINNUMERICTYPE_TW_STR1024 | The variable is of type L_CHAR[1024].
TWAINNUMERICTYPE_TW_UNI512 | The variable is of type wchar_t[512].


pCapability Parameter For CreateNumericContainerEnum

pCapability

Pointer to a structure that contains the capability container to allocate as type TW_ENUMERATION.


pData Parameter For CreateNumericContainerEnum

pData

Pointer to an allocated array of type TW_ENUMERATION that has been initialized with the appropriate data and size information.


uCurrentIndex Parameter For CreateNumericContainerEnum

uCurrentIndex

Index of the current value in the enumeration data.


uDefaultIndex Parameter For CreateNumericContainerEnum

uDefaultIndex

Index of the default value in the enumeration data.


uNumOfItems Parameter For CreateNumericContainerEnum

uNumOfItems

Number of items in the enumeration.


Return for CreateNumericContainerOneValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nType Parameter For CreateNumericContainerOneValue

nType

Type of data contained in the TW_ONEVALUE container. Possible values are:

Value | Meaning
TWAINNUMERICTYPE_TW_INT8 | The variable is of type L_CHAR or char.
TWAINNUMERICTYPE_TW_INT16 | The variable is of type L_INT16 or short.
TWAINNUMERICTYPE_TW_INT32 | The variable is of type L_INT32 or long.
TWAINNUMERICTYPE_TW_UINT8 | The variable is of type L_UCHAR or unsigned char.
TWAINNUMERICTYPE_TW_UINT16 | The variable is of type L_UINT16 or unsigned short.
TWAINNUMERICTYPE_TW_UINT32 | The variable is of type L_UINT32 or unsigned long.
TWAINNUMERICTYPE_TW_BOOL | The variable is of type L_BOOL or BOOL.
TWAINNUMERICTYPE_TW_FIX32 | The variable is of type TW_FIX32(TWAIN defined structure).
TWAINNUMERICTYPE_TW_FRAME | The variable is of type TW_FRAME(TWAIN defined structure).
TWAINNUMERICTYPE_TW_STR32 | The variable is of type L_CHAR[32].
TWAINNUMERICTYPE_TW_STR64 | The variable is of type L_CHAR[64].
TWAINNUMERICTYPE_TW_STR128 | The variable is of type L_CHAR[128].
TWAINNUMERICTYPE_TW_STR255 | The variable is of type L_CHAR[255].
TWAINNUMERICTYPE_TW_STR1024 | The variable is of type L_CHAR[1024].
TWAINNUMERICTYPE_TW_UNI512 | The variable is of type wchar_t[512].


pCapability Parameter For CreateNumericContainerOneValue

pCapability

Pointer to a structure that contains the capability container to allocate as type TW_ONEVALUE.


uValue Parameter For CreateNumericContainerOneValue

uValue

Value of the TW_ONEVALUE structure.


Return for CreateNumericContainerRange

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nType Parameter For CreateNumericContainerRange

nType

Type of data contained in the TW_RANGE container. Possible values are:

Value | Meaning
TWAINNUMERICTYPE_TW_INT8 | The variable is of type L_CHAR or char.
TWAINNUMERICTYPE_TW_INT16 | The variable is of type L_INT16 or short.
TWAINNUMERICTYPE_TW_INT32 | The variable is of type L_INT32 or long.
TWAINNUMERICTYPE_TW_UINT8 | The variable is of type L_UCHAR or unsigned char.
TWAINNUMERICTYPE_TW_UINT16 | The variable is of type L_UINT16 or unsigned short.
TWAINNUMERICTYPE_TW_UINT32 | The variable is of type L_UINT32 or unsigned long.
TWAINNUMERICTYPE_TW_BOOL | The variable is of type L_BOOL or BOOL.
TWAINNUMERICTYPE_TW_FIX32 | The variable is of type TW_FIX32(TWAIN defined structure).
TWAINNUMERICTYPE_TW_FRAME | The variable is of type TW_FRAME(TWAIN defined structure).
TWAINNUMERICTYPE_TW_STR32 | The variable is of type L_CHAR[32].
TWAINNUMERICTYPE_TW_STR64 | The variable is of type L_CHAR[64].
TWAINNUMERICTYPE_TW_STR128 | The variable is of type L_CHAR[128].
TWAINNUMERICTYPE_TW_STR255 | The variable is of type L_CHAR[255].
TWAINNUMERICTYPE_TW_STR1024 | The variable is of type L_CHAR[1024].
TWAINNUMERICTYPE_TW_UNI512 | The variable is of type wchar_t[512].


pCapability Parameter For CreateNumericContainerRange

pCapability

Pointer to a structure that contains the capability container to allocate as type TW_RANGE.


uCurrentValue Parameter For CreateNumericContainerRange

uCurrentValue

The current value of the range.


uDefaultValue Parameter For CreateNumericContainerRange

uDefaultValue

The default value of the range.


uMaxValue Parameter For CreateNumericContainerRange

uMaxValue

The maximum value of the range.


uMinValue Parameter For CreateNumericContainerRange

uMinValue

The minimum value of the range.


uStepSize Parameter For CreateNumericContainerRange

uStepSize

The step size value of the range.


Return for EndSession

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


Return for EnumCapabilities

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


uFlags Parameter For EnumCapabilities

uFlags

Flag that indicates the capability values to get when enumerating the TWAIN capability. Possible values are:

Value | Meaning
LTWAIN_CAPABILITY_DONTGET | [0] Get no capability values.
LTWAIN_CAPABILITY_GETCURRENT | [3] Get the current capability value.
LTWAIN_CAPABILITY_GETDEFAULT | [4] Get the default capability value.
LTWAIN_CAPABILITY_GETVALUES | [5] Get all available capability values.


nIndex Parameter For FamilyName

nIndex

Index of the source for which to get the family name. This value must be between 0 and the value of the SourceCount property.


Return for FindFastConfig

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nBitsPerPixel Parameter For FindFastConfig

nBitsPerPixel

Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Formats of Output Files . If nBitsPerPixel is 0, the file will be stored using the closest BitsPerPixel value supported by that format.


nBufferIteration Parameter For FindFastConfig

nBufferIteration

This value is used to determine the number of memory configurations that will be tested. The maximum value for this parameter is 10.


nInFastConfigsCount Parameter For FindFastConfig

nInFastConfigsCount

Number of scan configurations referenced in pInFastConfigs. Pass 0 to test the default scan configurations.


pInFastConfigs Parameter For FindFastConfig

pInFastConfigs

Pointer to a FASTCONFIG structure that contains an array of scan configurations to be tested. Pass NULL to test the default scan configurations


pnTestConfigsCount Parameter For FindFastConfig

pnTestConfigsCount

Pointer to an integer variable to be updated with number of tested configurations.


pOutBestConfig Parameter For FindFastConfig

pOutBestConfig

Pointer to a FASTCONFIG structure to be updated with the best configuration for the scanner.


ppTestConfigs Parameter For FindFastConfig

ppTestConfigs

Address of a pointer to a FASTCONFIG structure. The method will automatically allocate an array of FASTCONFIG structures using the total number of tested configurations.


strWorkingFolder Parameter For FindFastConfig

strWorkingFolder

String that contains the path to the working folder in which to save the tested images.


uFlags Parameter For FindFastConfig

uFlags

Flag that controls the display of the user interface and the actions of the method. Possible values are:

Value | Meaning
LTWAIN_SHOW_USER_INTERFACE | [$0001] Shows the manufacturer's user interface as modeless.
LTWAIN_MODAL_USER_INTERFACE | [$0002] Shows the manufacturer's user interface as a modal dialog. Works only if the LTWAIN_SHOW_USER_INTERFACE flag is set.
LTWAIN_USE_THREAD_MODE | [$0008] Use the fast Thread mode.
LTWAIN_CHECK_ALL_DEFAULT_BPP | [$0010] Test all supported BPP.


Return for FreeContainer

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For FreeContainer

pCapability

Pointer to a structure that contains the capability container to free.


Return for FreeExtendedImageInfoStructure

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pptwExtImgInfo Parameter For FreeExtendedImageInfoStructure

pptwExtImgInfo

Pointer to a pointer to the TW_EXTIMAGEINFO structure to be freed.


Return for FreePropQueryStructure

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


ppltProperty Parameter For FreePropQueryStructure

ppltProperty

Pointer to a pointer to a LTWAINPROPERTYQUERY structure to free.


Return for FreeScanConfig

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nFastConfigCount Parameter For FreeScanConfig

nFastConfigCount

Number of array elements to free.


ppFastConfig Parameter For FreeScanConfig

ppFastConfig

Address of the pointer to the array of FASTCONFIG structures. This method will free the array of FASTCONFIG structures allocated by FindFastConfig and GetScanConfigs methods.


hFile Parameter For GetCapabilityFromFile

hFile

Handle to an existing template file.


Return for GetCapabilityFromFile

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


ppCapability Parameter For GetCapabilityFromFile

ppCapability

Pointer to a pointer to a TW_CAPABILITY structure. This structure will be allocated internally.


uIndex Parameter For GetCapabilityFromFile

uIndex

Index of the capability to get from the file. This is a zero-based index.


Return for GetCapability

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For GetCapability

pCapability

Pointer to a TW_CAPABILITY structure that references the required capability. This structure must be allocated and it will be filled with data corresponding to the required capability to get.


uFlags Parameter For GetCapability

uFlags

Flags that indicate the capability values to get. Possible values are:

Value | Meaning
LTWAIN_CAPABILITY_GETCURRENT | [3] Get the current value.
LTWAIN_CAPABILITY_GETDEFAULT | [4] Get the default value.
LTWAIN_CAPABILITY_GETVALUES | [5] Get all available values.


Return for GetExtendedImageInfo

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


ptwExtImgInfo Parameter For GetExtendedImageInfo

ptwExtImgInfo

Pointer to a TW_EXTIMAGEINFO structure that references extended image info to fill.


Return for GetExtendedInfo

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetExtendedInfo

nIndex

Index of the image info that will be get in ptwInfo parameter.


ptwExtImgInfo Parameter For GetExtendedInfo

ptwExtImgInfo

Pointer to a TW_EXTIMAGEINFO structure contains extended image info.


ptwInfo Parameter For GetExtendedInfo

ptwInfo

Pointer to a TW_INFO structure that refernces the image info to fill.


Return for GetNumericContainerBOOLValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerBOOLValue

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pbValue Parameter For GetNumericContainerBOOLValue

pbValue

Reference to a Boolean value to be updated with the specified container value.


pCapability Parameter For GetNumericContainerBOOLValue

pCapability

Pointer to a TW_CAPABILITY structure that references the container value to get. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


Return for GetNumericContainerFIX32Value

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerFIX32Value

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pCapability Parameter For GetNumericContainerFIX32Value

pCapability

Pointer to a TW_CAPABILITY structure that references the container value to get. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


ptwFix Parameter For GetNumericContainerFIX32Value

ptwFix

Pointer to a TW_FIX32 value to be updated with the specified container value.


Return for GetNumericContainerFRAMEValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerFRAMEValue

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pCapability Parameter For GetNumericContainerFRAMEValue

pCapability

Pointer to a TW_CAPABILITY structure that references the container value to get. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


ptwFrame Parameter For GetNumericContainerFRAMEValue

ptwFrame

Pointer to a TW_FRAME value to be updated with the specified container value.


Return for GetNumericContainerINTValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerINTValue

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pCapability Parameter For GetNumericContainerINTValue

pCapability

Pointer to a TW_CAPABILITY structure that references the container value to get. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


pnValue Parameter For GetNumericContainerINTValue

pnValue

Pointer to an integer value to be updated with the specified container value.


Return for GetNumericContainerItemType

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For GetNumericContainerItemType

pCapability

Pointer to a TW_CAPABILITY structure. The nItemType parameter will be updated with the item type of this structure's container. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


pnItemType Parameter For GetNumericContainerItemType

pnItemType

Pointer to an integer to be updated with the container's item type.


Return for GetNumericContainerSTRINGValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerSTRINGValue

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pCapability Parameter For GetNumericContainerSTRINGValue

pCapability

Pointer to a TW_CAPABILITY structure that references the container value to get. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


twString Parameter For GetNumericContainerSTRINGValue

twString

A TW_STR1024 value to be updated with the specified container value.


Return for GetNumericContainerUINTValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerUINTValue

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pCapability Parameter For GetNumericContainerUINTValue

pCapability

Pointer to a TW_CAPABILITY structure that references the container value to get. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


puValue Parameter For GetNumericContainerUINTValue

puValue

Pointer to an unsigned integer value to be updated with the specified container value.


Return for GetNumericContainerValue

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nIndex Parameter For GetNumericContainerValue

nIndex

Index of the value to get. Possible values are:

Value | Meaning
LTWAIN_VALUE_COUNT | [-1] Update ppValue with the number of items in the item list of the specified container. This option is only valid if the container is of type TW_ARRAY or TW_ENUMERATION. If the container is of any other type, this method will return an error code.
LTWAIN_VALUE_CURRENT | [-2] Update ppValue with the current value of the container. If the container is of type TW_RANGE, ppValue is updated with the CurrentValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppValue is updated with the CurrentIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_DEFAULT | [-3] Update ppValue with the default value of the container. If the container is of type TW_RANGE, ppValue is updated with the DefaultValue member of the TW_RANGE structure. If the container is of type TW_ENUMERATION, ppvalue is updated with the DefaultIndex member of the TW_ENUMERATION structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MINIMUM | [-4] Update ppValue with the minimum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MinValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_MAXIMUM | [-5] Update ppValue with the maximum value of the container. If the container is of type TW_RANGE, ppValue is updated with the MaxValue member of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
LTWAIN_VALUE_STEPSIZE | [-6] Update ppValue with the step size of the container. If the container is of type TW_RANGE, ppValue is updated with the StepSize membr of the TW_RANGE structure. If the container is of any other type, the method will return an error code.
>= 0 | Update ppValue with the value at the specified index. If the container is of type TW_ONEVALUE, nIndex must be zero and ppValue will be updated with the value of the TW_ONEVALUE structure. If the container is of type TW_ARRAY or TW_ENUMERATION, ppValue will be updated with the value at the specified index in the list of items. If the container is of type TW_ENUMERATION or TW_ARRAY, the value must not exceed the number of items in the container's item list or the method will return an error code.


pCapability Parameter For GetNumericContainerValue

pCapability

Pointer to a structure that contains the capability container value to get.


ppValue Parameter For GetNumericContainerValue

ppValue

Variable to be allocated by the method and updated with the specified value. The user must free this value using the Windows APIs GlobalUnlock and GlobalFree methods.


hFile Parameter For GetNumOfCapsInFile

hFile

Handle to an existing HTWAINTEMPLATEFILE template file.


Return for GetNumOfCapsInFile

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


puCapCount Parameter For GetNumOfCapsInFile

puCapCount

Pointer to a variable to be updated with the number of capabilities in the specified file.


Return for GetProperties

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pProperties Parameter For GetProperties

pProperties

Pointer to a LTWAINPROPERTIES structure to be updated with the current or default properties. This must be a valid pointer for an LTWAINPROPERTIES structure.


uFlags Parameter For GetProperties

uFlags

Flag that indicates the property values to get. Possible values are:

Value | Meaning
LTWAIN_PROPERTIES_GETCURRENT | [3] Get the current values.
LTWAIN_PROPERTIES_GETDEFAULT | [4] Get the default values.


Return for GetScanConfigs

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


nBitsPerPixel Parameter For GetScanConfigs

nBitsPerPixel

The number of bits per pixel for which to get the default scan configurations.


nBufferIteration Parameter For GetScanConfigs

nBufferIteration

Number used to determine the number of memory configurations that will be tested. This method uses this number to determine which default scan configurations to get.


pnFastConfigCount Parameter For GetScanConfigs

pnFastConfigCount

Pointer to an integer to be updated with number of scan configurations in ppFastConfig.


ppFastConfig Parameter For GetScanConfigs

ppFastConfig

Address of a pointer to a FASTCONFIG structure. This method will automatically allocate an array of FASTCONFIG structures using the total number of scan configurations. This array will be updated with the scan configurations retrieved based on the specified bits per pixel, transfer mode and number of buffers.


uTransferMode Parameter For GetScanConfigs

uTransferMode

Transfer mode for which to get the default scan configurations.

Value | Meaning
LTWAIN_FILE_MODE | [$001] Use File transfer mode
LTWAIN_BUFFER_MODE | [$002] Use Memory transfer mode
LTWAIN_NATIVE_MODE | [$004] Use Native transfer mode


hWind Parameter For InitSession

hWind

Handle of the parent window. This may not be 0 or NULL.


Return for InitSession

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


hWind Parameter For IsAvailable

hWind

Handle to a window. (Internal TWAIN methods require a window handle; any valid window handle will work in this case).


Return for IsSupportLocked

Return Value

Return | Meaning
TRUE | The optional feature is locked.
FALSE | The optional feature is available in your toolkit.


nType Parameter For IsSupportLocked

nType

The optional feature to check.

Value | Meaning
L_SUPPORT_BARCODES_1D | Support for reading and writing Linear bar codes. This is available in the LEADTOOLS 1D Module.
L_SUPPORT_BARCODES_PDF_READ | Support for reading PDF bar codes. This is available in the LEADTOOLS 2D PDF Module (read).
L_SUPPORT_BARCODES_PDF_WRITE | Support for writing PDF bar codes. This is available in the LEADTOOLS 2D PDF Module (write).
L_SUPPORT_BARCODES_DATAMATRIX_READ | Support for reading Data Matrix bar codes. This is available in the LEADTOOLS 2D Data Matrix Module (read).
L_SUPPORT_BARCODES_DATAMATRIX_WRITE | Support for writing Data Matrix bar codes. This is available in the LEADTOOLS 2D Data Matrix Module (write).
L_SUPPORT_BITONAL | Support for Scale to Gray and Favor Black processing.
L_SUPPORT_CMW | Support for the CMW file format, which uses Wavelet CMP compression.
L_SUPPORT_DICOM | DICOM file format support, but not the DICOM Communication support.
L_SUPPORT_DOCUMENT | LEADTOOLS Document features . A LEADTOOLS Document license is required
L_SUPPORT_EXTGRAY | Support for 12 bit grayscale, 16-bit grayscale, 48-bit color and 64-bit color image creation and manipulation.
L_SUPPORT_ICR | Support for the ICR Module within the OCR engine. This supports the recognition of handwritten text. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_J2K | Unlocks support for JPEG2000 images. The support needs to be unlocked to read and write both types of JPEG 2000 images (JPEG 2000 stream and JP2 files).
L_SUPPORT_LTPRO | Support for advanced image processing functions only available in the Raster Pro and above toolkits.
L_SUPPORT_MEDICAL | Support for the capabilities unlocked by L_SUPPORT_DICOM and L_SUPPORT_EXTGRAY, plus all Medical features.
L_SUPPORT_MEDICAL_NET | Support for everything unlocked by L_SUPPORT_MEDICAL, plus support for the unsecure DICOM Network Communication for Message Exchange.
L_SUPPORT_OCR | Support for the OCR features. (Document/Medical).
L_SUPPORT_OCR_ASIAN | Support for the OCR engine to recognize Asian text. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_OCR_PDF_OUTPUT | Support for saving OCR results as a PDF file. This license is in addition to the cost of the OCR Plugin or Document Imaging Suite.
L_SUPPORT_OMR | Support for the OMR Module within the OCR engine. This supports the recognition of check boxes. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_PDF | Support for the PDF, PS and EPS file formats. Available only in the LEADTOOLS PDF Plug in. If this support is locked, the PDF, PS and EPS files will not be loaded or saved.
L_SUPPORT_PDF_SAVE | Support for saving raster images as a PDF file. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_VECTOR | Support for the Vector Features and Vector file formats. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selection.


Return for LockContainer

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For LockContainer

pCapability

Pointer to a TW_CAPABILITY structure from which to get the container.


ppContainer Parameter For LockContainer

ppContainer

Pointer to be updated with a pointer to the container.


nIndex Parameter For ManufacturerName

nIndex

Index of the source for which to get the manufacturer's name. This value must be between 0 and the value of the SourceCount property.


bFinishScan Parameter For OnAcquireMultiEvent

bFinishScan

Flag that indicates the scanning status. Possible values are:

Value | Meaning
TRUE | Scanning of the page has finished.
FALSE | Scanning of the page has just started.


nPage Parameter For OnAcquireMultiEvent

nPage

Number of the page being acquired


strFileName Parameter For OnAcquireMultiEvent

strFileName

String that contains the name of the file in which to save the scanned image(s).


Bitmap Parameter For OnAcquirePageEvent

Bitmap

Handle of the bitmap acquired from the TWAIN source.


Return for OnAcquirePageEvent

Return Value

SUCCESS | The method was successful.
SUCCESS_ABORT | The callback wants to abort the scanning operation.
< 1 | An error occurred. Refer to Return Codes.


Return for OnEnumCapabilityEvent

Return Value

SUCCESS | The method was successful.
< 1 | An error occurred. Refer to Return Codes.


pCapability Parameter For OnEnumCapabilityEvent

pCapability

Pointer to the TW_CAPABILITY structure that references the capability data being enumerated. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site www.twain.org.


uCap Parameter For OnEnumCapabilityEvent

uCap

The capability being enumerated. For more information on capability values, refer to the Twain 1.9 Specification, available at www.twain.org.


Return for OnFastConfigEvent

Return Value

SUCCESS | The function was successful.
SUCCESS_ABORT | Abort the testing configuration.


pResConfig Parameter For OnFastConfigEvent

pResConfig

Pointer to a FASTCONFIG structure that contains the scan configuration that is currently being tested.


Return for OnSaveCapabilityEvent

Return Value

SUCCESS | The function was successful.
SUCCESS_ABORT | The callback wants to abort the saving procedure.
SUCCESS_DELETE | Abort saving procedure and delete the file.
< 1 | An error occurred. Refer to Return Codes.


pCapability Parameter For OnSaveCapabilityEvent

pCapability

Pointer to the TW_CAPABILITY structure that references the capability data to save to the specified template file. For more information about TW_CAPABILITY, refer to the TWAIN 1.9 specification from the site www.twain.org.


Return for OnSetPropertiesEvent

Return Value

SUCCESS | The function was successful.
SUCCESS_RETRY | Retry with the new value in (pValue^) parameter.
SUCCESS_ABORT | Abort the negotiation.


nStatus Parameter For OnSetPropertiesEvent

nStatus

Variable that holds the value of the error that occurred while the property was being set.


pValue Parameter For OnSetPropertiesEvent

pValue

Pointer to the original value. The user can cast this depending on the type of the property, and modify it.


uCap Parameter For OnSetPropertiesEvent

uCap

The capability being set.


Return for OpenTemplateFile

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


phFile Parameter For OpenTemplateFile

phFile

Pointer to a HTWAINTEMPLATEFILE file handle.


strTemplateFile Parameter For OpenTemplateFile

strTemplateFile

A String that contains the name of the template file to open. A LEADTOOLS template file extension is .ltt.


uAccess Parameter For OpenTemplateFile

uAccess

Flag that indicates the access type for opening the file. Possible values are:

Value | Meaning
LTWAIN_TEMPLATE_OPEN_READ | [0] Open the template file for reading. This should be used to load data from an existing template file.
LTWAIN_TEMPLATE_OPEN_WRITE | [1] Open the template file for writing. This should be used to save data to a template file.


Return for QueryProperty

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


ppProperty Parameter For QueryProperty

ppProperty

Pointer to a pointer to a LTWAINPROPERTYQUERY structure to be updated with the property values.

The structure will be internally allocated if the method is successful.

The structure should be freed by calling FreePropQueryStructure method.


uCapability Parameter For QueryProperty

uCapability

This is a capability constant defined by the TWAIN 1.9 specification. For example if the user wants the value(s) for the transfer count, the uCapability will be ICAP_XFERCOUNT. . For more information on capability constants, refer to the Twain 1.9 Specification, available at www.twain.org.


Return for SetCapability

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For SetCapability

pCapability

Pointer to the TW_CAPABILITY structure that references the capability value to set. This structure must be allocated and filled with data corresponding to the required capability before passing it to the method. For more information on the TW_CAPABILITY structure, refer to the Twain 1.9 Specification, available at www.twain.org.


uFlags Parameter For SetCapability

uFlags

Flags that indicate whether to set or reset the capability value. Possible values are:

Value | Meaning
LTWAIN_CAPABILITY_SET | [1] Set the capability to the value specified in pCapability.
LTWAIN_CAPABILITY_RESET | [2] Reset the value of the capability to the default value defined by the TWAIN source. In this case the pCapability can be NULL since it is not needed.


Return for SetProperties

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pProperties Parameter For SetProperties

pProperties

Pointer to a LTWAINPROPERTIES structure that contains the values to set.


uFlags Parameter For SetProperties

uFlags

Flags that indicate whether to set or reset the property values. Possible values are:

Value | Meaning
LTWAIN_PROPERTIES_SET | [1] Set the properties to the values specified in the LTWAINPROPERTIES structure.
LTWAIN_PROPERTIES_RESET | [2] Set the properties to their default values neglecting the values specified in the LTWAINPROPERTIES structure. In this case the LTWAINPROPERTIES pointer can be NULL since it is not used.


Return for ShowTemplateDlg

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


strTemplateFile Parameter For ShowTemplateDlg

strTemplateFile

A string that contains the name of the template file used in saving the capability values.


nIndex Parameter For SourceName

nIndex

Index of the source name to get. This value must be between 0 and the value of the SourceCount property.


Return for UnlockContainer

Return Value

SUCCESS | The method was successful.
<> SUCCESS | An error occurred. Refer to Return Codes.


pCapability Parameter For UnlockContainer

pCapability

Pointer to a TW_CAPABILITY structure that contains the information to set.


nType Parameter For UnlockSupport

nType

The optional feature to check.

Value | Meaning
L_SUPPORT_BARCODES_1D | Support for reading and writing Linear bar codes. This is available in the LEADTOOLS 1D Module.
L_SUPPORT_BARCODES_1D_SILVER | Support for reading and writing Linear bar codes silver module. This is available in the LEADTOOLS 1D Silver Module.
L_SUPPORT_BARCODES_PDF_READ | Support for reading PDF bar codes. This is available in the LEADTOOLS 2D PDF Module (read).
L_SUPPORT_BARCODES_PDF_WRITE | Support for writing PDF bar codes. This is available in the LEADTOOLS 2D PDF Module (write).
L_SUPPORT_BARCODES_DATAMATRIX_READ | Support for reading Data Matrix bar codes. This is available in the LEADTOOLS 2D Data Matrix Module (read).
L_SUPPORT_BARCODES_DATAMATRIX_WRITE | Support for writing Data Matrix bar codes. This is available in the LEADTOOLS 2D Data Matrix Module (write).
L_SUPPORT_BARCODES_QR_READ | Support for reading QR bar codes. This is available in the LEADTOOLS 2D QR Module (read).
L_SUPPORT_BARCODES_QR_WRITE | Support for writing QR bar codes. This is available in the LEADTOOLS 2D QR Module (write).
L_SUPPORT_BITONAL | Support for Scale to Gray and Favor Black processing.
L_SUPPORT_CMW | Support for the CMW file format, which uses Wavelet CMP compression.
L_SUPPORT_DICOM | DICOM file format support, but not the DICOM Communication support.
L_SUPPORT_DOCUMENT | LEADTOOLS Document features . A LEADTOOLS Document license is required
L_SUPPORT_EXTGRAY | Support for 12 bit grayscale, 16-bit grayscale, 48-bit color and 64-bit color image creation and manipulation.
L_SUPPORT_ICR | Support for the ICR Module within the OCR engine. This supports the recognition of handwritten text. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_J2K | Unlocks support for JPEG2000 images. The support needs to be unlocked to read and write both types of JPEG 2000 images (JPEG 2000 stream and JP2 files).
L_SUPPORT_LTPRO | Support for advanced image processing functions only available in the Raster Pro and above toolkits.
L_SUPPORT_MEDICAL | Support for the capabilities unlocked by L_SUPPORT_DICOM and L_SUPPORT_EXTGRAY, plus all Medical features.
L_SUPPORT_MEDICAL_NET | Support for everything unlocked by L_SUPPORT_MEDICAL, plus support for the unsecure DICOM Network Communication for Message Exchange.
L_SUPPORT_OCR | Support for the OCR features. (Document/Medical).
L_SUPPORT_OCR_ASIAN | Support for the OCR engine to recognize Asian text. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_OCR_PDF_OUTPUT | Support for saving OCR results as a PDF file. This license is in addition to the cost of the OCR Plugin or Document Imaging Suite.
L_SUPPORT_OMR | Support for the OMR Module within the OCR engine. This supports the recognition of check boxes. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_PDF | Support for the PDF, PS and EPS file formats. Available only in the LEADTOOLS PDF Plug in. If this support is locked, the PDF, PS and EPS files will not be loaded or saved.
L_SUPPORT_PDF_SAVE | Support for saving raster images as a PDF file. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selections.
L_SUPPORT_VECTOR | Support for the Vector Features and Vector file formats. Available only in selected LEADTOOLS products. For a list of products, refer to Topic Selection.


strKey Paremeter for UnlockSupport

strKey

The key to unlock the feature.


Return for UnlockSupport

Return Value

None.