Selecting ltmmCaptureCtrl Object Sizes Example for Visual Basic

The following example shows how to enumerate and select ltmmCaptureCtrl object sizes.

Sub EnumerateCaptureSizes(CaptureSizes As ltmmCaptureSizes, List As ListBox)
    ' Build the devices list box
    Dim Selected As Long
    Selected = -1
    List.Clear
    For i = 0 To (CaptureSizes.Count - 1)
        List.AddItem CStr(CaptureSizes.Item (i).Width) & " x " & CStr(CaptureSizes.Item(i).Height)
        List.ItemData(List.NewIndex) = i
        If CaptureSizes.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 SelectCaptureSize(CaptureSizes As ltmmCaptureSizes, List As ListBox)
    ' select the highlighted device
    CaptureSizes.Selection = List.ItemData(List.ListIndex)
End Sub
Private Sub Form_Load()
    ' build the target device list
    ltmmCaptureCtrl1.VideoDevices.Selection = 0
    i = ltmmCaptureCtrl1.VideoCaptureSizes.Find (320, 240)
    If (i <> -1) Then
        ltmmCaptureCtrl1.VideoCaptureSizes.Selection = i
    End If
    EnumerateCaptureSizes ltmmCaptureCtrl1.VideoCaptureSizes, lstCaptureSizes
End Sub

Private Sub lstCaptureSizes_Click()
    ' select the target device
    SelectCaptureSize ltmmCaptureCtrl1.VideoCaptureSizes, lstCaptureSizes
End Sub