The following code demonstrates how to enumerate and select ltmmPlayCtrl processors:
Sub BuildRegisteredList(Processors As ltmmProcessors, List As ListBox)
' rebuild the registered processor listbox
List.Clear
For i = 0 To (Processors.Count - 1)
List.AddItem Processors.Item (i).FriendlyName
List.ItemData(List.NewIndex) = i
Next
End Sub
Sub BuildSelectedList(Processors As ltmmProcessors, List As ListBox)
' rebuild the selected processor listbox
List.Clear
For i = 0 To (Processors.Count - 1)
List.AddItem Processors.Item (i).FriendlyName
Next
List.AddItem ""
List.Selected(List.ListCount - 1) = True
End Sub
Sub AddProcessor(prcRegistered As ltmmProcessors, lstRegistered As ListBox, prcSelected As ltmmProcessors, lstSelected As ListBox)
' inserts the highlighted registered processor into the selected processor list
prcSelected.Add prcRegistered.Item(lstRegistered.ItemData(lstRegistered.ListIndex)), lstSelected.ListIndex
lstSelected.AddItem lstRegistered.List(lstRegistered.ListIndex), lstSelected.ListIndex
End Sub
Sub RemoveAllProcessors(Processors As ltmmProcessors, List As ListBox)
' removes all of the selected processors
Processors.RemoveAll
BuildSelectedList Processors, List
End Sub
Sub RemoveProcessor(Processors As ltmmProcessors, List As ListBox)
' removes the highlighted selected processors
Dim Index As Integer
Index = List.ListIndex
Processors.Remove Index
List.RemoveItem Index
List.Selected(Index) = True
End Sub
Sub RefreshProcessors(Processors As ltmmProcessors, List As ListBox)
' refreshes the registered processor collection
Dim Index As Integer
Dim Selected As String
Dim Found As Long
Index = List.ListIndex
If Index >= 0 Then
' save the currently selected item for later search
Selected = Processors.Item (List.ItemData(Index)).Name
End If
Processors.Refresh
BuildRegisteredList Processors, List
If Index >= 0 Then
' reselect the processor
Found = Processors.Find (Selected)
If Found >= 0 Then
For i = 0 To (List.ListCount - 1)
If List.ItemData(i) = Found Then
List.Selected(i) = True
Exit For
End If
Next
End If
End If
End Sub
Sub ProcessorProperties(Processors As ltmmProcessors, List As ListBox)
' show the selected processors properties dialog box
Processors.Item (List.ListIndex).ShowDialog ltmmProcessor_Dlg_Properties, hWnd
End Sub
Sub RegisteredIndexChanged(Processors As ltmmProcessors, List As ListBox, cmdAdd As CommandButton)
' enable buttons based on the current state of the registered processor listbox
Dim Index As Integer
Index = List.ListIndex
If Index >= 0 Then
cmdAdd.Enabled = True
Else
cmdAdd.Enabled = False
End If
End Sub
Sub SelectedIndexChanged(Processors As ltmmProcessors, List As ListBox, cmdRemove As CommandButton, cmdRemoveAll As CommandButton, cmdProperties As CommandButton)
' enable buttons based on the current state of the selected processor listbox
Dim Index As Integer
Index = List.ListIndex
If Index >= 0 And Index < (List.ListCount - 1) Then
cmdRemove.Enabled = True
cmdProperties.Enabled = Processors.Item (Index).HasDialog (ltmmProcessors_Dlg_Properties)
Else
cmdRemove.Enabled = False
cmdProperties.Enabled = False
End If
cmdRemoveAll.Enabled = (List.ListCount > 1)
End Sub
Private Sub cmdAudioAdd_Click()
' add audio processor
AddProcessor ltmmPlayCtrl1.AudioProcessors, lstAudioRegistered, ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected, cmdAudioRemove, cmdAudioRemoveAll, cmdAudioProperties
End Sub
Private Sub cmdAudioProperties_Click()
' show audio properties
ProcessorProperties ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected
End Sub
Private Sub cmdAudioRefresh_Click()
' refresh audio processors
RefreshProcessors ltmmPlayCtrl1.AudioProcessors, lstAudioRegistered
RegisteredIndexChanged ltmmPlayCtrl1.AudioProcessors, lstAudioRegistered, cmdAudioAdd
End Sub
Private Sub cmdAudioRemove_Click()
' remove audio processor
RemoveProcessor ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected, cmdAudioRemove, cmdAudioRemoveAll, cmdAudioProperties
End Sub
Private Sub cmdAudioRemoveAll_Click()
' remove all audio processors
RemoveAllProcessors ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected, cmdAudioRemove, cmdAudioRemoveAll, cmdAudioProperties
End Sub
Private Sub cmdVideoAdd_Click()
' add video processor
AddProcessor ltmmPlayCtrl1.VideoProcessors, lstVideoRegistered, ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected, cmdVideoRemove, cmdVideoRemoveAll, cmdVideoProperties
End Sub
Private Sub cmdVideoProperties_Click()
' show video properties
ProcessorProperties ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected
End Sub
Private Sub cmdVideoRefresh_Click()
' refresh video processors
RefreshProcessors ltmmPlayCtrl1.VideoProcessors, lstVideoRegistered
RegisteredIndexChanged ltmmPlayCtrl1.VideoProcessors, lstVideoRegistered, cmdVideoAdd
End Sub
Private Sub cmdVideoRemove_Click()
' remove video processor
RemoveProcessor ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected, cmdVideoRemove, cmdVideoRemoveAll, cmdVideoProperties
End Sub
Private Sub cmdVideoRemoveAll_Click()
' remove all video processors
RemoveAllProcessors ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected, cmdVideoRemove, cmdVideoRemoveAll, cmdVideoProperties
End Sub
Private Sub Form_Load()
' build audio processor lists
BuildRegisteredList ltmmPlayCtrl1.AudioProcessors, lstAudioRegistered
RegisteredIndexChanged ltmmPlayCtrl1.AudioProcessors, lstAudioRegistered, cmdAudioAdd
BuildSelectedList ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected, cmdAudioRemove, cmdAudioRemoveAll, cmdAudioProperties
' build video processor lists
BuildRegisteredList ltmmPlayCtrl1.VideoProcessors, lstVideoRegistered
RegisteredIndexChanged ltmmPlayCtrl1.VideoProcessors, lstVideoRegistered, cmdVideoAdd
BuildSelectedList ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected
SelectedIndexChanged ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected, cmdVideoRemove, cmdVideoRemoveAll, cmdVideoProperties
End Sub
Private Sub lstAudioRegistered_Click()
' update audio buttons
RegisteredIndexChanged ltmmPlayCtrl1.AudioProcessors, lstAudioRegistered, cmdAudioAdd
End Sub
Private Sub lstAudioSelected_Click()
' update audio buttons
SelectedIndexChanged ltmmPlayCtrl1.SelectedAudioProcessors, lstAudioSelected, cmdAudioRemove, cmdAudioRemoveAll, cmdAudioProperties
End Sub
Private Sub lstVideoRegistered_Click()
' update video buttons
RegisteredIndexChanged ltmmPlayCtrl1.VideoProcessors, lstVideoRegistered, cmdVideoAdd
End Sub
Private Sub lstVideoSelected_Click()
' update video buttons
SelectedIndexChanged ltmmPlayCtrl1.SelectedVideoProcessors, lstVideoSelected, cmdVideoRemove, cmdVideoRemoveAll, cmdVideoProperties
End Sub