Leadtools TWAIN(Leadtools.Twainアセンブリ)

フレームを表示

GetDeviceEventCapabilityメソッド






現在のTWAINセッションの間デバイスイベント機能値を取得します。
構文
public TwainCapability GetDeviceEventCapability()
'Declaration
 
Public Function GetDeviceEventCapability() As TwainCapability
'Usage
 
Dim instance As TwainSession
Dim value As TwainCapability
 
value = instance.GetDeviceEventCapability()

            

            
public:
TwainCapability^ GetDeviceEventCapability(); 

戻り値

CAP_DEVICEEVENT機能値を表すTwainCapabilityオブジェクト
解説

CAP_DEVICEEVENT機能値を取得するために、この関数を呼び出します。CAP_DEVICEEVENT機能を設定するには、SetDeviceEventCapabilityメソッドを呼び出します。CAP_DEVICEEVENT機能をデフォルト値にリセットするには、ResetDeviceEventCapabilityメソッドを呼び出します。

デバイスイベントごとにステータスを取得するために、EnableGetDeviceEventをTRUEに設定します。また、デバイスイベントのために情報を取得するために、GetDeviceEventDataメソッドを呼び出します。

サンプル
Copy Code  
Imports Leadtools
 Imports Leadtools.Twain

#If Not LEADTOOLS_V19_OR_LATER Then
      Public Sub GetDeviceEventCapabilityExample(ByVal parent As IWin32Window)
#Else
      Public Sub GetDeviceEventCapabilityExample(ByVal parent As IntPtr)
#End If ' #If LEADTOOLS_V19_OR_LATER Then
         Dim session As TwainSession = New TwainSession()
         session.Startup(parent, "manufacturer", "productFamily", "version", "application", TwainStartupFlags.None)
         Try
            Dim twnCap As TwainCapability = session.GetDeviceEventCapability()
            If twnCap.Information.Type = TwainCapabilityType.DeviceEvent Then
               Dim count As Integer = twnCap.ArrayCapability.Count
               Dim i As Integer

               For i = 0 To count - 1
                  Dim capValue As TwainCapabilityValue = CType(twnCap.ArrayCapability.GetValue(i), TwainCapabilityValue)
                  Select Case capValue
                     Case TwainCapabilityValue.DeviceEventCheckBattery
                        MessageBox.Show("Device event checks the battery")
                     Case TwainCapabilityValue.DeviceEventCheckResolution
                        MessageBox.Show("Device event checks the resolution")
                     Case TwainCapabilityValue.DeviceEventDeviceReady
                        MessageBox.Show("Device event is ready")
                  End Select
               Next

               Dim cap As TwainCapability = 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")
            End If
         Catch
         End Try
         session.Shutdown()
      End Sub
using Leadtools;
 using Leadtools.Twain;

#if !LEADTOOLS_V19_OR_LATER
      public void GetDeviceEventCapabilityExample(IWin32Window parent)
#else
      public void GetDeviceEventCapabilityExample(IntPtr parent)
#endif // #if !LEADTOOLS_V19_OR_LATER
      {
         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();
      }
必要条件

ターゲットプラットホーム

参照

参照

TwainSessionクラス
TwainSessionメンバ
EnableGetDeviceEventプロパティ
GetDeviceEventDataメソッド
SetDeviceEventCapabilityメソッド
ResetDeviceEventCapabilityメソッド
Leadtools.Twain.TwainSession.GetDeviceEvent
TwainDeviceEventクラス