←Select platform

GetDeviceEventData Method

Summary
Gets information for specific device event.

Syntax
C#
C++/CLI
Python
public TwainDeviceEvent GetDeviceEventData() 
public: 
TwainDeviceEvent^ GetDeviceEventData();  
def GetDeviceEventData(self): 

Return Value

A TwainDeviceEvent object that represents device event information

Remarks

This method will returns information for specific device event. To get status for each device event, set EnableGetDeviceEvent property to TRUE to enable firing GetDeviceEvent event To get CAP_DEVICEEVENT capability values, call GetDeviceEventCapability method, and to set CAP_DEVICEEVENT capability call SetDeviceEventCapability method, also call ResetDeviceEventCapability method to reset CAP_DEVICEEVENT capability.\

This method should be called inside GetDeviceEvent event to get the device event information.

Example
C#
using Leadtools; 
using Leadtools.Twain; 
 
 
TwainSession session = new TwainSession(); 
 
public void GetDeviceEventDataExample(IntPtr parent) 
{ 
   try 
   { 
      session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
      session.GetDeviceEvent += new EventHandler<EventArgs>(session_GetDeviceEvent); 
      session.EnableGetDeviceEvent = true; 
 
      session.Acquire(TwainUserInterfaceFlags.Show); 
      session.Shutdown(); 
   } 
   catch 
   { } 
} 
 
void session_GetDeviceEvent(object sender, EventArgs e) 
{ 
   try 
   { 
      TwainDeviceEvent deviceEvent = session.GetDeviceEventData(); 
      string msg = string.Format("Event ={0}\nEvent Name ={1}\n", deviceEvent.Event, deviceEvent.DeviceName); 
      MessageBox.Show(msg); 
 
      if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckBattery) 
      { 
         msg = string.Format("Battery Minutes ={0}\nBattery Percentage ={1}\n", deviceEvent.BatteryMinutes, deviceEvent.BatteryPercentage); 
         MessageBox.Show(msg); 
      } 
      else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckPowerSupply) 
      { 
         msg = string.Format("Power Supply ={0}\n", deviceEvent.PowerSupply); 
         MessageBox.Show(msg); 
      } 
      else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckPowerSupply) 
      { 
         msg = string.Format("XResolution ={0}\nYResolution ={1}\n", deviceEvent.XResolution, deviceEvent.YResolution); 
         MessageBox.Show(msg); 
      } 
      else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckFlash) 
      { 
         msg = string.Format("FlashUsed2 ={0}\n", deviceEvent.FlashUsed2); 
         MessageBox.Show(msg); 
      } 
      else if (deviceEvent.Event == TwainCapabilityValue.DeviceEventCheckAutomaticCapture) 
      { 
         msg = string.Format("Automatic Capture ={0}\nTime Before First Capture ={1}\nTime Between Captures = {2}\n", deviceEvent.AutomaticCapture, deviceEvent.TimeBeforeFirstCapture, deviceEvent.TimeBetweenCaptures); 
         MessageBox.Show(msg); 
      } 
   } 
   catch 
   { } 
} 
Requirements

Target Platforms

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Twain Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.