Platforms to show: All Mac Windows Linux Cross-Platform

/Win/WIA/List devices


Required plugins for this example: MBS Win Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Win/WIA/List devices

This example is the version from Sun, 17th Mar 2012.

Project "List devices.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Löschen"
Const kFileQuit = "Beenden"
Const kFileQuitShortcut = ""
EventHandler Sub Open() if not TargetWin32 then MsgBox "This project needs Windows." end if End EventHandler
End Class
Class Window1 Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
EventHandler Sub ExpandRow(row As Integer) dim p as WIAPropertyStorageMBS = List.Celltag(row, 0) dim count as integer if p<>Nil then // we look on all children dim e as WIAPropertyEnumeratorMBS = p.Enumerate if e<>Nil then dim n as WIAPropertyMBS = e.NextItem while n<>Nil count=count+1 if count>30 then // limit the properties to the first 30 items Return end if // get property value dim name as string = n.Name if lenb(name)>0 then List.AddRow name // a property with name List.Cell(List.LastIndex,1)=p.Read(name) else List.AddRow str(n.ID) // and one with only an ID List.Cell(List.LastIndex,1)=p.Read(n.id) end if n = e.NextItem wend end if end if End EventHandler
End Control
Control StaticText1 Inherits Label
ControlInstance StaticText1 Inherits Label
End Control
Control PushButton1 Inherits PushButton
ControlInstance PushButton1 Inherits PushButton
EventHandler Sub Action() dim DeviceDescription, DeviceName as string dim DeviceID as string // show dialog to select a device dim it as WIAItemMBS = DeviceManager2.SelectDeviceDialog(self, DeviceManager2.kDeviceTypeDefault, DeviceManager1.kSelectDeviceNoDefault, DeviceID) // if we got something, we pick the device name and description if it<>Nil then dim p as WIAPropertyStorageMBS = it.PropertyStorage DeviceName = p.Read(p.kDevicePropertyDevNameString) DeviceDescription = p.Read(p.kDevicePropertyDevDescString) end if if len(DeviceID)>0 then MsgBox "You selected a device"+EndOfLine+EndOfLine+DeviceID+EndOfLine+DeviceName+EndOfLine+DeviceDescription end if End EventHandler
End Control
Control PushButton2 Inherits PushButton
ControlInstance PushButton2 Inherits PushButton
EventHandler Sub Action() dim DeviceDescription, DeviceName as string dim DeviceID as string // show dialog to select a device dim it as WIAItemMBS = DeviceManager1.SelectDeviceDialog(self, DeviceManager1.kDeviceTypeDefault, DeviceManager1.kSelectDeviceNoDefault, DeviceID) // if we got something, we pick the device name and description if it<>Nil then dim p as WIAPropertyStorageMBS = it.PropertyStorage DeviceName = p.Read(p.kDevicePropertyDevNameString) DeviceDescription = p.Read(p.kDevicePropertyDevDescString) end if if len(DeviceID)>0 then MsgBox "You selected a device"+EndOfLine+EndOfLine+DeviceID+EndOfLine+DeviceName+EndOfLine+DeviceDescription end if End EventHandler
End Control
EventHandler Sub Open() DeviceManager1 = new WIADeviceManager1MBS // Enumerate all local devices dim e as WIADeviceInfoEnumeratorMBS = DeviceManager1.EnumDeviceInfo(DeviceManager1.kEnumLocal) if e<>Nil then dim p as WIAPropertyStorageMBS = e.NextItem while p<>Nil // display the name of the device List.AddFolder p.Read(p.kDevicePropertyDevNameString) List.CellTag(List.LastIndex,0)=p p = e.NextItem wend end if DeviceManager2 = new WIADeviceManager2MBS // Enumerate all local devices e = DeviceManager2.EnumDeviceInfo(DeviceManager2.kEnumLocal) if e<>Nil then dim p as WIAPropertyStorageMBS = e.NextItem while p<>Nil // display the name of the device List.AddFolder p.Read(p.kDevicePropertyDevNameString) List.CellTag(List.LastIndex,0)=p p = e.NextItem wend end if End EventHandler
Property DeviceManager1 As WIADeviceManager1MBS
Property DeviceManager2 As WIADeviceManager2MBS
End Class
MenuBar MenuBar1
MenuItem FileMenu = "&Ablage"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Bearbeiten"
MenuItem EditUndo = "&Rückgängig"
MenuItem UntitledMenu1 = "-"
MenuItem EditCut = "&Ausschneiden"
MenuItem EditCopy = "&Kopieren"
MenuItem EditPaste = "&Einfügen"
MenuItem EditClear = "#App.kEditClear"
MenuItem UntitledMenu0 = "-"
MenuItem EditSelectAll = "&Alles auswählen"
End MenuBar
End Project

See also:

The items on this page are in the following plugins: MBS Win Plugin.


The biggest plugin in space...