Selecting ltmmCaptureCtrl Renderers Example for Visual Basic
The following code demonstrates how to enumerate and select ltmmCaptureCtrl renderers:
Sub EnumerateRenderers(Renderers As ltmmRenderers, List As ListBox)
' Build the renderers list box
Dim Selected As Long
Selected = -1
List.Clear
For i = 0 To (Renderers.Count - 1)
List.AddItem Renderers.Item(i).FriendlyName
List.ItemData(List.NewIndex) = i
If Renderers.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 RefreshRenderers(Renderers As ltmmRenderers, List As ListBox)
Dim Selected As Long
Dim SelectedName As String
' save the currently selected renderer's name
Selected = Renderers.Selection
If Selected >= 0 Then
SelectedName = Renderers.Item(Selected).Name
End If
' refresh the renderer collection
Renderers.Refresh
' if there was a previously selected renderer, reselect it
If Selected >= 0 Then
Renderers.Selection = Renderers.Find(SelectedName)
End If
' rebuild the listbox
EnumerateRenderers Renderers, List
End Sub
Sub SelectRenderer(Renderers As ltmmRenderers, List As ListBox)
' select the highlighted renderer
Renderers.Selection = List.ItemData(List.ListIndex)
End Sub
Private Sub cmdAudioRefresh_Click()
' refresh audio renderers
RefreshRenderers ltmmCaptureCtrl1.AudioRenderers, lstAudioRenderers
End Sub
Private Sub Form_Load()
' build the audio renderer list
EnumerateRenderers ltmmCaptureCtrl1.AudioRenderers, lstAudioRenderers
End Sub
Private Sub lstAudioRenderers_Click()
' select the audio renderer
SelectRenderer ltmmCaptureCtrl1.AudioRenderers, lstAudioRenderers
End Sub