←Select platform

GetDeviceEventCapability Method

Summary
Gets device events capability values for current TWAIN session.

Syntax
C#
C++/CLI
Python
public TwainCapability GetDeviceEventCapability() 
public: 
TwainCapability^ GetDeviceEventCapability();  
def GetDeviceEventCapability(self): 

Return Value

A TwainCapability object that represents CAP_DEVICEEVENT capability values

Remarks

Call this function to get CAP_DEVICEEVENT capability values. To set CAP_DEVICEEVENT capability, you can call SetDeviceEventCapability method, also to rest CAP_DEVICEEVENT capability to default values, call ResetDeviceEventCapability method.

To get status for each device event, set EnableGetDeviceEvent to TRUE. Also, to get information for device event, call GetDeviceEventData method.

Example
C#
using Leadtools; 
using Leadtools.Twain; 
 
 
public void GetDeviceEventCapabilityExample(IntPtr parent) 
{ 
   TwainSession session = new TwainSession(); 
   session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None); 
 
   try 
   { 
      TwainCapability twnCap = session.GetDeviceEventCapability(); 
      if (twnCap.Information.Type == TwainCapabilityType.DeviceEvent) 
      { 
         int count = twnCap.ArrayCapability.Count; 
         for (int i = 0; i < count; i++) 
         { 
            TwainCapabilityValue capValue = (TwainCapabilityValue)twnCap.ArrayCapability.GetValue(i); 
            switch (capValue) 
            { 
               case TwainCapabilityValue.DeviceEventCheckBattery: 
                  MessageBox.Show("Device event checks the battery"); 
                  break; 
               case TwainCapabilityValue.DeviceEventCheckResolution: 
                  MessageBox.Show("Device event checks the resolution"); 
                  break; 
               case TwainCapabilityValue.DeviceEventDeviceReady: 
                  MessageBox.Show("Device event is ready"); 
                  break; 
            } 
         } 
 
         TwainCapability cap = new TwainCapability(); 
         cap.Information.Type = TwainCapabilityType.DeviceEvent; 
         cap.Information.ContainerType = TwainContainerType.Array; 
 
         cap.ArrayCapability.Count = 5; 
         cap.ArrayCapability.ItemType = TwainItemType.Uint16; 
         cap.ArrayCapability.SetValue(0, TwainCapabilityValue.DeviceEventDeviceReady); 
         cap.ArrayCapability.SetValue(1, TwainCapabilityValue.DeviceEventCheckDeviceOnline); 
         cap.ArrayCapability.SetValue(2, TwainCapabilityValue.DeviceEventCheckBattery); 
         cap.ArrayCapability.SetValue(3, TwainCapabilityValue.DeviceEventCheckPowerSupply); 
         cap.ArrayCapability.SetValue(4, TwainCapabilityValue.DeviceEventCheckResolution); 
 
         session.SetDeviceEventCapability(cap); 
         MessageBox.Show("DeviceEvent is changed successfully"); 
         session.ResetDeviceEventCapability(twnCap); 
         MessageBox.Show("DeviceEvent is reset to default values successfully"); 
      } 
   } 
   catch 
   { } 
 
   session.Shutdown(); 
} 
Requirements

Target Platforms

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

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