LTwain::AddCapabilityToFile
#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
Example
// Create your own class Inherited from LTwain
// to override the call back function
class CMyTwain : public LTwain
{
public:
L_INT CapabilityCallBack(L_UINT uCap, pTW_CAPABILITY pCapability);
HTWAINTEMPLATEFILE m_hFile;
};
// initialize session and call this function
void TestAddCapabilityToFile(CMyTwain *MyClass, HWND hWndParent)
{
OPENFILENAME ofn;
L_INT nRet;
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))
{
nRet = MyClass->OpenTemplateFile(&MyClass->m_hFile, szFilePath, LTWAIN_TEMPLATE_OPEN_WRITE);
if (nRet == SUCCESS)
{
MyClass->EnumCapabilities( LTWAIN_CAPABILITY_GETCURRENT );
MyClass->CloseTemplateFile( MyClass->m_hFile);
}
}
}
L_INT CMyTwain::CapabilityCallBack(L_UINT uCap, pTW_CAPABILITY pCapability)
{
L_INT nRet;
if (!pCapability)
return SUCCESS;
if (!pCapability->hContainer)
GlobalFree (pCapability);
nRet = AddCapabilityToFile(m_hFile, pCapability);
GlobalFree (pCapability->hContainer);
GlobalFree (pCapability);
return SUCCESS;
}