LTwain::AddCapabilityToFile

#include "ltwrappr.h"

virtual L_INT LTwain::AddCapabilityToFile (hFile, pCapability)

Adds a capability to a file.

Parameters

HTWAINTEMPLATEFILE hFile

Handle to an existing template file.

pTW_CAPABILITY pCapability

Pointer to a structure that contains the capability to add.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

In order to add a capability to a template file, the template file must first be opened for writing using the LTwain::OpenTemplateFile. 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 LTwain::CloseTemplateFile. For more information on capabilities, refer to Getting and Setting Capabilities.

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

Required DLLs and Libraries

See Also

Functions

Topics

Example

// Create your own class Inherited from LTwain  
// to override the call back function 
#ifdef CMyTwain 
class CMyTwain : public LTwain 
 
{ 
 
public: 
 
   L_INT CapabilityCallBack(L_UINT uCap, pTW_CAPABILITY pCapability); 
   L_VOID AcquireCallBack(L_INT nPage, L_TCHAR * pszFileName, L_BOOL bFinishScan); 
   L_INT FindFastConfigCallBack(pFASTCONFIG pResConfig); 
   L_INT SourceInfoCallBack(pLTWAINSOURCEINFO pSourceInfo); 
   L_INT SetPropertyCallBack(L_UINT uCap, L_INT nStatus, L_VOID * pValue); 
   L_INT BitmapCallBack(pBITMAPHANDLE pBitmap); 
 
   HTWAINTEMPLATEFILE m_hFile; 
 
}; 
#endif // #ifdef CMyTwain 
 
// initialize session and call this function 
 
L_INT LTwain__AddCapabilityToFileExample(CMyTwain *MyClass, HWND hWndParent) 
{ 
   L_INT          nRet; 
   OPENFILENAME   ofn; 
   L_TCHAR        szFilePath [MAX_PATH]; 
 
   memset (&ofn, 0, sizeof(OPENFILENAME)); 
   memset (szFilePath, 0, MAX_PATH); 
 
   ofn.lStructSize   = sizeof(OPENFILENAME); 
   ofn.hwndOwner     = hWndParent; 
   ofn.lpstrFile     = szFilePath; 
   ofn.nMaxFile      = MAX_PATH; 
   ofn.lpstrFilter   = TEXT("LEAD TWAIN TEMPLATE\0*.ltt\0All Files\0*.*\0\0"); 
   ofn.lpstrDefExt   = TEXT("ltt"); 
   ofn.lpstrTitle    = TEXT("Save Template File"); 
   ofn.Flags         = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY; 
 
   if (GetSaveFileName (&ofn)) 
 
   { 
#if defined(FOR_WIN64) 
      HTWAINTEMPLATEFILE* __unaligned  hfile=&MyClass->m_hFile; 
#else  
      HTWAINTEMPLATEFILE*   hfile=&MyClass->m_hFile; 
#endif 
      nRet = MyClass->OpenTemplateFile(hfile, szFilePath, LTWAIN_TEMPLATE_OPEN_WRITE); 
 
      if (nRet == SUCCESS) 
 
      { 
 
         MyClass->EnumCapabilities( LTWAIN_CAPABILITY_GETCURRENT ); 
 
         MyClass->CloseTemplateFile( MyClass->m_hFile); 
 
      } 
      else 
         return nRet; 
 
   } 
 
   return SUCCESS; 
 
} 
 
 
L_INT CMyTwain::CapabilityCallBack(L_UINT uCap, pTW_CAPABILITY pCapability) 
{ 
   UNREFERENCED_PARAMETER(uCap); 
 
   L_INT nRet; 
 
 
   if (!pCapability) 
 
      return SUCCESS; 
 
 
 
   if (!pCapability->hContainer) 
 
      GlobalFree (pCapability); 
 
 
 
   nRet = AddCapabilityToFile(m_hFile, pCapability); 
 
 
 
   GlobalFree (pCapability->hContainer); 
 
   GlobalFree (pCapability); 
 
 
 
   return SUCCESS; 
 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS TWAIN C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.