←Select platform

SelectDeviceDlg Method

Summary
Displays a dialog box that enables the user to select a WIA hardware device for image acquisition.

Syntax
C#
C++/CLI
Python
public DialogResult SelectDeviceDlg( 
   IntPtr owner, 
   WiaDeviceType deviceType, 
   WiaSelectSourceFlags flags 
) 
public: 
DialogResult SelectDeviceDlg(  
   IntPtr owner, 
   WiaDeviceType deviceType, 
   WiaSelectSourceFlags flags 
)  
def SelectDeviceDlg(self,owner,deviceType,flags): 

Parameters

owner
Window handle of your application window.

deviceType
Specifies which type of WIA device to use. Possible values are:

Value

Meaning

WiaDeviceType.Default Generic WIA device. During device enumerations, this constant is used to enumerate all WIA devices. This is the default value.
WiaDeviceType.Scanner The device is a scanner.
WiaDeviceType.DigitalCamera The device is a camera. Note that this type of device is not supported by Windows Vista and later.
WiaDeviceType.StreamingVideo The device contains streaming video. Note that this type of device is not supported by Windows Server 2003, Windows Vista, or later.

flags
Flag that determines certain actions of the WIA image acquisition selection dialog box. Possible values are:

Value

Meaning

WiaSelectSourceFlags.None Default behavior for the device image acquisition dialog box.
WiaSelectSourceFlags.NoDefault Display the dialog box even if there is only one matching device.

Return Value

One of the DialogResult values. If an error occurs, an exception is thrown.

Remarks

This function creates and displays the Select Device dialog box so the user can select a WIA device for image acquisition.

Particular types of devices may be displayed to the user by specifying the device types through the deviceType parameter.

If only one device meets the specification, the SelectDeviceDlg does not display the Select Device dialog box. Override this behavior and force the SelectDeviceDlg to display the Select Device dialog box by passing NoDefault as the value for the flags parameter.

Note:

WIA 2.0 does not support cameras or streaming video.

Note:

You do not need to call this method if you are using the high-level AcquireSimple method, since it handles session initialization, session end, and device selection automatically.

For more information, refer to How to Acquire from the WIA Source.

For more information, refer to Managing WIA Sources.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Wia; 
 
 
      
public void IsAvailableExample(IntPtr parent) 
{ 
   if (!WiaSession.IsAvailable(WiaVersion.Version1)) 
   { 
      Console.WriteLine("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) 
   { 
      Console.WriteLine("Error selecting WIA device."); 
      wiaSession.Shutdown(); 
      return; 
   } 
 
   // Initialize and fill the required fields from the WiaAcquireOptions structure 
   WiaAcquireOptions wiaAcquireOptions = WiaAcquireOptions.Empty; 
   wiaAcquireOptions.MemoryBufferSize = 32 * 1024; 
   wiaAcquireOptions.DoubleBuffer = true; 
   wiaSession.AcquireOptions = wiaAcquireOptions; 
 
   wiaSession.AcquireEvent += new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent); 
 
   wiaSession.Acquire(parent, null, WiaAcquireFlags.ShowUserInterface | WiaAcquireFlags.UseCommonUI); 
 
   wiaSession.AcquireEvent -= new EventHandler<WiaAcquireEventArgs>(wiaSession_AcquireEvent); 
   wiaSession.Shutdown(); 
} 
 
public void wiaSession_AcquireEvent(object sender, WiaAcquireEventArgs e) 
{ 
   Application.DoEvents(); 
 
   if ((e.Flags & WiaAcquiredPageFlags.StartOfPage) == WiaAcquiredPageFlags.StartOfPage) 
      Console.WriteLine("Beginning of data transfer."); 
   else if ((e.Flags & WiaAcquiredPageFlags.EndOfPage) == WiaAcquiredPageFlags.EndOfPage) 
      Console.WriteLine("End of data transfer."); 
 
   if (e.Image != null) 
   { 
      // You can load the image here. 
   } 
 
   e.Cancel = false; 
} 
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.Wia Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.