Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS TWAIN C++ Class Library Help

LTwain::AddCapabilityToFile

Show in webframe

#include "ltwrappr.h"

virtual L_INT LTwain::AddCapabilityToFile (hFile, pCapability)

HTWAINTEMPLATEFILE hFile;

/* handle to an existing template file */

pTW_CAPABILITY pCapability;

/* pointer to a structure */

Adds a capability to a file.

Parameter

Description

hFile

Handle to an existing template file.

pCapability

Pointer to a structure that contains the capability to add.

Returns

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

LTTWN

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.

See Also

Functions:

LTwain::CapabilityCallback, LTwain::OpenTemplateFile, LTwain::TemplateDlg, LTwain::GetCapabilityFromFile, LTwain::GetNumOfCapsInFile, LTwain::CloseTemplateFile, LTwain::InitSession, LTwain::EndSession.

Topics:

Handling Template Files

 

TWAIN Functionality: Capability Functions.

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.lpstrTitle    = TEXT("Save Template File");
   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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.