L_TwainGetDeviceEventData

Summary

Gets information for a specific device event.

Syntax

#include "lttwn.h"

L_LTTWN_API L_INT L_TwainGetDeviceEventData(hSession, pDeviceEvent)

Parameters

HTWAINSESSION hSession

Handle to an existing TWAIN session. This handle is obtained by calling L_TwainInitSession or L_TwainInitSession2.

pTW_DEVICEEVENT pDeviceEvent

Pointer to a TW_DEVICEEVENT structure that references the required device event capability. This structure must be allocated and 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

This function should be called inside the LTWAINDEVICEEVENTCALLBACK callback to get the device event information.

To get the status for each device event, call L_TwainSetDeviceEventCallback.

To get the CAP_DEVICEEVENT capability values, call L_TwainGetDeviceEventCapability.

To set the CAP_DEVICEEVENT capability values, call L_TwainSetDeviceEventCapability.

To reset the CAP_DEVICEEVENT capability value to the default, call L_TwainResetDeviceEventCapability.

For information about TW_DEVICEEVENT, refer to the TWAIN specification.

Required DLLs and Libraries

See Also

Functions

Topics

Example

float MyFix32ToFloat(TW_FIX32 * ptwFix) 
{ 
   float Floater = 0; 
   Floater = (float)ptwFix->Whole + (float)ptwFix->Frac / (float)65536.0; 
   return Floater; 
} 
 
L_INT EXT_CALLBACK DeviceEventCB(HTWAINSESSION hSession, L_VOID * /*pUserData*/) 
{ 
   TW_DEVICEEVENT twDevice; 
   memset(&twDevice, 0, sizeof(TW_DEVICEEVENT)); 
   L_INT nRet = L_TwainGetDeviceEventData(hSession, &twDevice); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   L_TCHAR szBuffer[MAX_PATH]; 
   memset(szBuffer, 0, sizeof(szBuffer)); 
   wsprintf(szBuffer, TEXT("Event = %d\nEvent Name  =%s\n"), twDevice.Event, twDevice.DeviceName); 
   MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
 
   if (twDevice.Event == TWDE_CHECKBATTERY) 
   { 
      wsprintf(szBuffer, TEXT("Battery Minutes = %d\nBattery Percentage = %d\n"), twDevice.BatteryMinutes, twDevice.BatteryPercentage); 
      MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   } 
   else if (twDevice.Event == TWDE_CHECKPOWERSUPPLY) 
   { 
      wsprintf(szBuffer, TEXT("Power Supply =%d\n"), twDevice.PowerSupply); 
      MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   } 
   else if (twDevice.Event == TWDE_CHECKRESOLUTION) 
   { 
      wsprintf(szBuffer, TEXT("XResolution = %f\nYResolution = %f\n"), MyFix32ToFloat(&twDevice.XResolution), MyFix32ToFloat(&twDevice.YResolution)); 
      MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   } 
   else if (twDevice.Event == TWDE_CHECKFLASH) 
   { 
      wsprintf(szBuffer, TEXT("FlashUsed2 =%d\n"), twDevice.FlashUsed2); 
      MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   } 
   else if (twDevice.Event == TWDE_CHECKAUTOMATICCAPTURE) 
   { 
      wsprintf(szBuffer, TEXT("Automatic Capture =%d\nTime Before First Capture =%d\nTime Between Captures = %d\n"), twDevice.AutomaticCapture, twDevice.TimeBeforeFirstCapture, twDevice.TimeBetweenCaptures); 
      MessageBox(NULL, szBuffer, TEXT("Notice!"), MB_OK); 
   } 
 
   return SUCCESS; 
} 
 
L_INT GetDeviceEventDataExample(HTWAINSESSION hSession) 
{ 
   BITMAPHANDLE MyBtmp; 
   memset(&MyBtmp, 0, sizeof(BITMAPHANDLE)); 
 
   L_TwainStartCapsNeg(hSession); 
   L_TwainSetDeviceEventCallback(hSession, DeviceEventCB, NULL); 
   L_TwainEndCapsNeg(hSession); 
 
   L_TwainAcquire(hSession, &MyBtmp, sizeof(BITMAPHANDLE), NULL, LTWAIN_SHOW_USER_INTERFACE, NULL, NULL); 
   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 API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.