Leadtools.Wia Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
EnumFormats Method
See Also  Example
Leadtools.Wia Namespace > WiaSession Class : EnumFormats Method



item

Handle to the item having its supported transfer formats enumerated. Retrieve this parameter by either calling the WiaSession.GetRootItem method to get the device’s root item itself, or by enumerating the child items of the device through a call to EnumChildItems method.

flags
Reserved for future use, pass WiaEnumFormatsFlags.None.
item

Handle to the item having its supported transfer formats enumerated. Retrieve this parameter by either calling the WiaSession.GetRootItem method to get the device’s root item itself, or by enumerating the child items of the device through a call to EnumChildItems method.

flags
Reserved for future use, pass WiaEnumFormatsFlags.None.
Enumerates all of the available WIA driver transfer formats.

Syntax

Visual Basic (Declaration) 
Public Sub EnumFormats( _
   ByVal item As Object, _
   ByVal flags As WiaEnumFormatsFlags _
) 
Visual Basic (Usage)Copy Code
Dim instance As WiaSession
Dim item As Object
Dim flags As WiaEnumFormatsFlags
 
instance.EnumFormats(item, flags)
C# 
public void EnumFormats( 
   object item,
   WiaEnumFormatsFlags flags
)
C++/CLI 
public:
void EnumFormats( 
   Object^ item,
   WiaEnumFormatsFlags flags
) 

Parameters

item

Handle to the item having its supported transfer formats enumerated. Retrieve this parameter by either calling the WiaSession.GetRootItem method to get the device’s root item itself, or by enumerating the child items of the device through a call to EnumChildItems method.

flags
Reserved for future use, pass WiaEnumFormatsFlags.None.

Example

Visual BasicCopy Code
Public Sub EnumFormatsExample(ByVal parent As IWin32Window)
   If (Not WiaSession.IsAvailable(WiaVersion.Version1)) Then
      MessageBox.Show("WIA version 1.0 not installed.")
      Return
   End If

   Dim session As WiaSession = New WiaSession()
   session.Startup(WiaVersion.Version1)

   Dim res As DialogResult = session.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault)
   If res <> DialogResult.OK Then
      MessageBox.Show("Error selecting WIA device.")
      session.Shutdown()
      Return
   End If

   AddHandler session.EnumFormatsEvent, AddressOf session_EnumFormatsEvent

   session.GetRootItem(Nothing)
   If Not session.RootItem Is Nothing Then
      session.EnumFormats(session.RootItem, WiaEnumFormatsFlags.None)
   End If

   RemoveHandler session.EnumFormatsEvent, AddressOf session_EnumFormatsEvent

   session.Shutdown()
End Sub

Private Sub session_EnumFormatsEvent(ByVal sender As Object, ByVal e As WiaEnumFormatsEventArgs)
   Dim strMsg As String = String.Empty

   strMsg = String.Format("WIA Formats count = {0}" & Constants.vbLf, e.FormatsCount)
   Console.WriteLine(strMsg)

   ' print out the received formats into the console window.
   If e.FormatsCount > 0 Then
      WiaSession.GetFormatGuid(e.Format)
      strMsg = String.Format("WIA Format: {0}" & Constants.vbLf & "WIA Format Transfer Mode: {1}" & Constants.vbLf & "WIA Format Guid: " & Constants.vbLf + Constants.vbLf, e.Format.ToString(), e.TransferMode.ToString(), WiaSession.FormatGuid)
      Console.WriteLine(strMsg)
   End If
End Sub
C#Copy Code
public void EnumFormatsExample(IWin32Window parent) 

   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
   { 
      MessageBox.Show("WIA version 1.0 not installed."); 
      return; 
   } 
 
   WiaSession wiaSession = new WiaSession(); 
   wiaSession.Startup(WiaVersion.Version1); 
 
   DialogResult res = wiaSession.SelectDeviceDlg(parent, WiaDeviceType.Default, WiaSelectSourceFlags.NoDefault); 
   if (res != DialogResult.OK) 
   { 
      MessageBox.Show("Error selecting WIA device."); 
      wiaSession.Shutdown(); 
      return; 
   } 
 
   wiaSession.EnumFormatsEvent += new EventHandler<WiaEnumFormatsEventArgs>(wiaSession_EnumFormatsEvent); 
 
   wiaSession.GetRootItem(null); 
   if (wiaSession.RootItem != null) 
   { 
      wiaSession.EnumFormats(wiaSession.RootItem, WiaEnumFormatsFlags.None); 
   } 
 
   wiaSession.EnumFormatsEvent -= new EventHandler<WiaEnumFormatsEventArgs>(wiaSession_EnumFormatsEvent); 
 
   wiaSession.Shutdown(); 

 
void wiaSession_EnumFormatsEvent(object sender, WiaEnumFormatsEventArgs e) 

   string strMsg = string.Empty; 
 
   strMsg = string.Format("WIA Formats count = {0}\n", e.FormatsCount); 
   Console.WriteLine(strMsg); 
 
   // print out the received formats into the console window. 
   if (e.FormatsCount > 0) 
   { 
      WiaSession.GetFormatGuid(e.Format); 
      strMsg = string.Format("WIA Format: {0}\nWIA Format Transfer Mode: {1}\nWIA Format Guid: \n\n", e.Format.ToString(), e.TransferMode.ToString(), WiaSession.FormatGuid); 
      Console.WriteLine(strMsg); 
   } 
}

Remarks

This function will enumerate all of the available WIA driver transfer formats for the specified item.

Each enumerated transfer format will be sent to the user through the WiaSession.EnumFormatsEvent event. Add this event when enumerating the device's transfer formats. To cancel the enumeration proces, add the WiaSession.EnumFormatsEvent event and then set the Cancel member of the WiaEnumFormatsEventArgs to true.

For more information, refer to Managing WIA Sources.

Requirements

Target Platforms: Microsoft .NET Framework 3.0, Windows 2000, Windows XP, Windows Vista, Windows Server 2003 family, Windows Server 2008 family

See Also