The following example shows how to enumerate and select ltmmConvertCtrl object target devices.
Sub EnumerateTargetDevices(TargetDevices As ltmmTargetDevices, List As ListBox)
' Build the devices list box
Dim Selected As Long
Selected = -1
List.Clear
For i = 0 To (TargetDevices.Count - 1)
List.AddItem TargetDevices.Item (i).FriendlyName
List.ItemData(List.NewIndex) = i
If TargetDevices.Item(i).Selected Then
Selected = i
End If
Next
' highlight the current selection
For i = 0 To (List.ListCount - 1)
If List.ItemData(i) = Selected Then
List.Selected(i) = True
End If
Next
End Sub
Sub RefreshTargetDevices(TargetDevices As ltmmTargetDevices, List As ListBox)
Dim Selected As Long
Dim SelectedName As String
' save the currently selected device's name
Selected = TargetDevices.Selection
If Selected >= 0 Then
SelectedName = TargetDevices.Item (Selected).Name
End If
' refresh the device collection
TargetDevices.Refresh
' if there was a previously selected device, reselect it
If Selected >= 0 Then
TargetDevices.Selection = TargetDevices.Find (SelectedName)
End If
' rebuild the listbox
EnumerateTargetDevices TargetDevices, List
End Sub
Sub SelectTargetDevice(TargetDevices As ltmmTargetDevices, List As ListBox)
' select the highlighted device
TargetDevices.Selection = List.ItemData(List.ListIndex)
End Sub
Private Sub cmdTargetRefresh_Click()
' refresh target devices
RefreshTargetDevices ltmmConvertCtrl1.TargetDevices, lstTargetDevices
End Sub
Private Sub Form_Load()
' build the target device list
EnumerateTargetDevices ltmmConvertCtrl1.TargetDevices, lstTargetDevices
End Sub
Private Sub lstTargetDevices_Click()
' select the target device
SelectTargetDevice ltmmConvertCtrl1.TargetDevices, lstTargetDevices
End Sub