Selecting ltmmCaptureCtrl Compressors Example for Visual Basic
The following code demonstrates how to enumerate and select ltmmCaptureCtrl compressors:
Sub EnumerateCompressors(Compressors As ltmmCompressors, List As ListBox)
' Build the compressors list box
Dim Selected As Long
Selected = -1
List.Clear
For i = 0 To (Compressors.Count - 1)
List.AddItem Compressors.Item (i).FriendlyName
List.ItemData(List.NewIndex) = i
If Compressors.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 RefreshCompressors(Compressors As ltmmCompressors, List As ListBox)
Dim Selected As Long
Dim SelectedName As String
' save the currently selected compressor's name
Selected = Compressors.Selection
If Selected >= 0 Then
SelectedName = Compressors.Item (Selected).Name
End If
' refresh the compressor collection
Compressors.Refresh
' if there was a previously selected compressor, reselect it
If Selected >= 0 Then
Compressors.Selection = Compressors.Find(SelectedName)
End If
' rebuild the listbox
EnumerateCompressors Compressors, List
End Sub
Sub SelectCompressor(Compressors As ltmmCompressors, List As ListBox)
' select the highlighted compressor
Compressors.Selection = List.ItemData(List.ListIndex)
End Sub
Private Sub cmdAudioRefresh_Click()
' refresh audio compressors
RefreshCompressors ltmmCaptureCtrl1.AudioCompressors, lstAudioCompressors
End Sub
Private Sub cmdVideoRefresh_Click()
' refresh video compressors
RefreshCompressors ltmmCaptureCtrl1.VideoCompressors, lstVideoCompressors
End Sub
Private Sub Form_Load()
' build the audio compressor list
EnumerateCompressors ltmmCaptureCtrl1.AudioCompressors, lstAudioCompressors
' build the video compressor list
EnumerateCompressors ltmmCaptureCtrl1.VideoCompressors, lstVideoCompressors
End Sub
Private Sub lstAudioCompressors_Click()
' select the audio compressor
SelectCompressor ltmmCaptureCtrl1.AudioCompressors, lstAudioCompressors
End Sub
Private Sub lstVideoCompressors_Click()
' select the video compressor
SelectCompressor ltmmCaptureCtrl1.VideoCompressors, lstVideoCompressors
End Sub