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::GetDeviceEventCapability

Show in webframe

#include "ltwrappr.h"

L_INT LTwain::GetDeviceEventCapability(pDeviceCap)

pTW_CAPABILITY pDeviceCap;

/* pointer to a structure */

Gets the device event capability (CAP_DEVICEEVENT) values for the current TWAIN session.

Parameter

Description

pDeviceCap

Pointer to a TW_CAPABILITY structure that references the required device event capability. This structure must be allocated and it will be filled with data corresponding to the required capability to get.

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

To set the CAP_DEVICEEVENT capability value, call LTwain::SetDeviceEventCapability function.

To rest the CAP_DEVICEEVENT capability value to the default, call LTwain::ResetDeviceEventCapability function.

To get the device event information, call LTwain::GetDeviceEventData function.

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::GetDeviceEventData, LTwain::SetDeviceEventCapability, LTwain::ResetDeviceEventCapability

Topics:

Getting and Setting Capabilities

 

TWAIN Functionality: Capability Functions

Example

L_INT LTwain__GetDeviceEventCapabilityExample(LTwain * plTwain)
{
   L_INT nRet = SUCCESS;
   TW_CAPABILITY twCap;
   memset(&twCap, 0, sizeof(TW_CAPABILITY));
   nRet = plTwain->GetDeviceEventCapability(&twCap);
   if (nRet != SUCCESS)
      return nRet;
   if (twCap.Cap == CAP_DEVICEEVENT)
   {
      pTW_ARRAY ptwArray = (pTW_ARRAY)GlobalLock(twCap.hContainer);
      int count = ptwArray->NumItems;
      for (int i = 0; i < count; i++)
      {
         pTW_UINT16 ptwItems = (pTW_UINT16)ptwArray->ItemList;
         TW_UINT16 capValue = ptwItems[i];
         switch (capValue)
         {
         case TWDE_CHECKBATTERY:
            MessageBox(NULL, TEXT("Device event checks the battery"), TEXT("Notice!"), MB_OK);
            break;
         case TWDE_CHECKRESOLUTION:
            MessageBox(NULL, TEXT("Device event checks the resolution"), TEXT("Notice!"), MB_OK);
            break;
         case TWDE_DEVICEREADY:
            MessageBox(NULL, TEXT("Device event is ready"), TEXT("Notice!"), MB_OK);
            break;
         }
      }
      GlobalUnlock(twCap.hContainer);
      GlobalFree(twCap.hContainer);
      memset(&twCap, 0, sizeof(TW_CAPABILITY));
      twCap.Cap = CAP_DEVICEEVENT;
      twCap.ConType = TWON_ARRAY;
      twCap.hContainer = (TW_HANDLE)GlobalAlloc(GHND, sizeof(TW_ARRAY)+ sizeof(TW_UINT16) * 5);
      ptwArray = (pTW_ARRAY)GlobalLock(twCap.hContainer);
      ptwArray->ItemType = TWTY_UINT16;
      ptwArray->NumItems = 5;
      TW_UINT16 twItems[5];
      twItems[0] = TWDE_DEVICEREADY;
      twItems[1] = TWDE_CHECKDEVICEONLINE;
      twItems[2] = TWDE_CHECKBATTERY;
      twItems[3] = TWDE_CHECKPOWERSUPPLY;
      twItems[4] = TWDE_CHECKRESOLUTION;
      memcpy((void *)&ptwArray->ItemList, twItems, sizeof(TW_UINT16)*5);
      GlobalUnlock(twCap.hContainer);
      nRet = plTwain->SetDeviceEventCapability(&twCap);
      if (nRet == SUCCESS)
         MessageBox(NULL, TEXT("DeviceEvent is changed successfully"), TEXT("Notice!"), MB_OK);
      nRet = plTwain->ResetDeviceEventCapability(&twCap);
      if (nRet == SUCCESS)
         MessageBox(NULL, TEXT("DeviceEvent is reset to default values successfully"), TEXT("Notice!"), MB_OK);
   }
   return SUCCESS;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.