LTwain::GetDeviceEventCapability

Summary

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

Syntax

#include "ltwrappr.h"

L_INT LTwain::GetDeviceEventCapability(pDeviceCap)

Parameters

pTW_CAPABILITY 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

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

Comments

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

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

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

Required DLLs and Libraries

See Also

Functions

Topics

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; 
} 
Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

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