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 for working with template files:

image\sqrblit.gif The ShowTemplateDlg method 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. Before calling this method you can determine which user interface to display by setting the EnableShowUserInterfaceOnly property.

image\sqrblit.gif To get all the supported capability values set by the selected TWAIN source and save them to the specified file, call the SaveTemplate method. The SaveTemplateEvent event or SaveTemplateEvent2 event will occur after each capability is obtained from the TWAIN source, but before it is saved in the template file. This allows the user to change the value. The SaveTemplateEvent2 event will occur only if the EnableSaveTemplateEvent property has been set to TRUE. The SaveTemplateEvent event is designed more for MFC users, and takes as a parameter a pointer to an ICapability interface that references the capability values to be saved. The SaveTemplateEvent2 event is for VB users, and takes as a parameter a pointer to an ILEADTwainCapability interface that references the capability values to be saved.

image\sqrblit.gif To load the TWAIN capability values stored in the specified template file and set the selected TWAIN source using these values, call the LoadTemplate method. The LoadTemplateEvent event or LoadTemplateEvent2 event will occur after each capability has been obtained from the file, but before it is set in the TWAIN source. This allows the user to change the value. The LoadTemplateEvent2 event will occur only if the EnableLoadTemplateEvent property has been set to TRUE. The LoadTemplateEvent event is designed more for MFC users, and takes as a parameter a pointer to an ICapability interface, that references the capability values loaded from the file. The LoadTemplateEvent2 event is for VB users, and takes as a parameter a pointer to an ILEADTwainCapability interface, that references the capability values loaded from the file.