Advanced Capture Application Example for Visual Basic

The following code demonstrates most of the methods and properties available in the ltmmCaptureCtrl object:

' memory target
Dim arr() As Byte
' form resize lock
Dim FormResizeLock As Integer


' declarations for clipboard functions
Const CF_DIB = 8
Private Declare Function OpenClipboard Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function CloseClipboard Lib "user32" () As Long
Private Declare Function SetClipboardData Lib "user32" (ByVal wFormat As Long, ByVal hMem As Long) As Long
Private Declare Function EmptyClipboard Lib "user32" () As Long
Sub FreeTarget()
    ' realease any capture interest in the target
    If ltmmCaptureCtrl1.TargetType = ltmmCapture_Target_Array Then
        ltmmCaptureCtrl1.ResetTarget
        ReDim arr(0)
    Else
        ltmmCaptureCtrl1.ResetTarget
    End If
End Sub

Private Sub capture_Click ()
' remove comment to debug
'    MsgBox "Click fired"
End Sub

Private Sub capture_MediaEvent (ByVal EventCode As Long, ByVal Param1 As Long, ByVal Param2 As Long)
   Select Case EventCode
       Case ltmmEC_DVD_DOMAIN_CHANGE
           statusbar.Panels(1).Text  = "The DVD domain is changed"
       Case ltmmEC_DVD_TITLE_CHANGE
           statusbar.Panels(1).Text = "The DVD current title The name for a group of related video files (called "Chapters") on your DVD. For example, for a DVD called "My Summer Vacation," you might have the titles "Water Skiing," "New Friends," and "Hiking." For each of those titles, you might have one or more different video files. number is changed"
End Select

Private Sub capture_Complete ()
    If ltmmCaptureCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
        ltmmCaptureCtrl1.TargetVCRControl.Stop
    End If
    statusbar.Panels(1).Text = "Complete"
End Sub

Private Sub capture_DblClick ()
' remove comment to debug
'    MsgBox "DblClick fired"
End Sub

Private Sub capture_ErrorAbort (ByVal ErrorCode As Long)
    If ltmmCaptureCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
        ltmmCaptureCtrl1.TargetVCRControl.Stop
    End If
    statusbar.Panels(1).Text = "Aborted"
    MsgBox "Capture Aborted. Error " & CStr(ErrorCode)
End Sub

Private Sub capture_KeyDown (KeyCode As Integer, ShiftState As Integer)
    If (KeyCode = &H1B And ltmmCaptureCtrl1.FullScreenMode) Then
        ltmmCaptureCtrl1.FullScreenMode = False
    End If
End Sub

Private Sub capture_KeyPress (KeyAscii As Integer)
' remove comment to debug
'    MsgBox "KeyPress fired - KeyAscii = " & CStr(KeyAscii)
End Sub

Private Sub capture_KeyUp (KeyCode As Integer, ShiftState As Integer)
' remove comment to debug
'    MsgBox "KeyUp fired - KeyCode = " & CStr(KeyCode) & " ShiftState = " & CStr(ShiftState)
End Sub

Private Sub capture_MouseDown (Button As Integer, Shift As Integer, X As Single, Y As Single)
    ' invoke capture properties if clicked within video
    If Button = 1 And Not ltmmCaptureCtrl1.FullScreenMode Then
        If X >= ltmmCaptureCtrl1.VideoWindowLeft And X < (ltmmCaptureCtrl1.VideoWindowLeft + ltmmCaptureCtrl1.VideoWindowWidth) And Y >= ltmmCaptureCtrl1.VideoWindowTop And Y < (ltmmCaptureCtrl1.VideoWindowTop + ltmmCaptureCtrl1.VideoWindowHeight) Then
            If ltmmCaptureCtrl1.State <> ltmmCapture_State_Running Then
                ltmmCaptureCtrl1.ShowDialog ltmmCapture_Dlg_Capture, hwnd
            End If
        End If


    End If

End Sub

Private Sub capture_MouseMove (Button As Integer, Shift As Integer, X As Single, Y As Single)
' remove comment to debug
'    MsgBox "MouseMove fired - Button = " & CStr(Button) & " Shift = " & CStr(Shift) & " X = " & CStr(X) & " Y = " & CStr(Y)
End Sub

Private Sub capture_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
' remove comment to debug
'    MsgBox "MouseUp fired - Button = " & CStr(Button) & " Shift = " & CStr(Shift) & " X = " & CStr(X) & " Y = " & CStr(Y)
End Sub

Private Sub capture_Progress (ByVal Time As Long)
    statusbar.Panels(2).Text = "Dropped " + CStr(ltmmCaptureCtrl1.NumDropped)
    statusbar.Panels(3).Text = "Not Dropped " + CStr(ltmmCaptureCtrl1.NumNotDropped)
    statusbar.Panels(4).Text = "Frm. Size " + CStr(ltmmCaptureCtrl1.AverageFrameSize)
    If (ltmmCaptureCtrl1.Mode = ltmmCapture_Mode_Still Or ltmmCaptureCtrl1.Mode = ltmmCapture_Mode_ManualFrames) Then
        statusbar.Panels(5).Text = ""
    Else
        statusbar.Panels(5).Text = CStr(ltmmCaptureCtrl1.CaptureTime)
    End If
End Sub

Private Sub capture_Resize ()
   ' if not in the form resize event, then size the form to the control
   If FormResizeLock = 0 Then
' remove comment to debug
'       MsgBox "Resize fired - ScaleLeft = " & CStr(ltmmCaptureCtrl1.ScaleLeft) & " ScaleTop = " & CStr(ltmmCaptureCtrl1.ScaleTop) & " ScaleWidth = " & CStr(ltmmCaptureCtrl1.ScaleWidth) & " ScaleHeight = " & CStr(ltmmCaptureCtrl1.ScaleHeight)
       Move Left, Top, ltmmCaptureCtrl1.VideoWindowWidth + (Width - ScaleWidth), ltmmCaptureCtrl1.VideoWindowHeight + (Height - ScaleHeight) + statusbar.Height
   End If
End Sub

Private Sub capture_Started ()
    If ltmmCaptureCtrl1.Mode = ltmmCapture_Mode_Still Then
        Caption = "[still]"
    Else
        If ltmmCaptureCtrl1.TargetType = ltmmCapture_Target_Array Then
            Caption = "[array]"
        ElseIf ltmmCaptureCtrl1.TargetType = ltmmCapture_Target_Device Then
            Caption = "[device]"
        Else
            Caption = "[" & ltmmCaptureCtrl1.TargetFile & "]"
        End If
    End If

    statusbar.Panels(1).Text = "Started"
End Sub

Private Sub Form_Load()
    ' set up a custom cursor
    ltmmCaptureCtrl1.MouseIcon = LoadPicture("c:\icons\capture.ico")
    ltmmCaptureCtrl1.MousePointer = ltmmCustom
    ' match the form scale mode
    ltmmCaptureCtrl1.ScaleMode = ScaleMode
    ' enable automatic resizing of the control
    ltmmCaptureCtrl1.AutoSize = True
    ' set the preview source to video only
    ltmmCaptureCtrl1.PreviewSource = ltmmCapture_Preview_Video
    ltmmCaptureCtrl1.Preview = True
    ' disable close captioning
    ltmmCaptureCtrl1.CloseCaptioning = False
    ' set frame delay to 1 second
    ltmmCaptureCtrl1.FrameDelay = 1#
    ' assign target file
    ltmmCaptureCtrl1.TargetFile = "c:\target.avi"
    ' select the LEAD video compressor
    ltmmCaptureCtrl1.VideoCompressors.Selection = ltmmCaptureCtrl1.VideoCompressors.Find ("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD MCMP/MJPEG Codec A COmpressor Also known as an encoder, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder. combined with a DECompressor, or encoder Also known as compressor, this is a module or algorithm to compress data. Playing that data back requires a decompressor, or decoder. and a decoder Also known as a decompressor, this is a module or algorithm to decompress data., which allows you to both compress and decompress that same data. (2.0)")
    'select the MP3 audio compressor
    ltmmCaptureCtrl1.AudioCompressors.Selection = ltmmCaptureCtrl1.AudioCompressors.Find ("@device:cm:{33D9A761-90C8-11D0-BD43-00A0C911CE86}\85MPEG Layer-3")

    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_Avi
    ltmmCaptureCtrl1.AllocTarget 10
    ' select the first audio device
    ltmmCaptureCtrl1.AudioDevices.Selection = 0
    ' select the first video device
    ltmmCaptureCtrl1.VideoDevices.Selection = 0
    ' snap window to video
    Move Left, Top, ltmmCaptureCtrl1.VideoWidth + (Width - ScaleWidth), ltmmCaptureCtrl1.VideoHeight + (Height - ScaleHeight) + statusbar.Height
End Sub

Private Sub Form_Resize()
    ' resize the preview window
    FormResizeLock = FormResizeLock + 1
    Dim cy As Integer
    If ScaleHeight >= statusbar.Height Then
        cy = ScaleHeight - statusbar.Height
    Else
        cy = 0
    End If
    ltmmCaptureCtrl1.Move ScaleLeft, ScaleTop, ScaleWidth, cy
    FormResizeLock = FormResizeLock – 1
End Sub

Private Sub mnuAudio005Seconds_Click()
    ' set audio buffering to 0.05 seconds
    ltmmCaptureCtrl1.AudioBufferSize = 0.05
End Sub

Private Sub mnuAudio05Seconds_Click()
    ' set audio buffering to 0.5 seconds
    ltmmCaptureCtrl1.AudioBufferSize = 0.5
End Sub

Private Sub mnuAudioProcessors_Click()
    ' audio processors
    ltmmCaptureCtrl1.ShowDialog ltmmCapture_Dlg_AudioProcessors, hwnd
End Sub

Private Sub mnuCaptureAutoFrames_Click()
    ' capture automatic frame sequence
    ltmmCaptureCtrl1.ReadyCapture ltmmCapture_Mode_AutoFrames
    If ltmmCaptureCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
        ltmmCaptureCtrl1.TargetVCRControl.Record
    End If
    ltmmCaptureCtrl1.StartCapture ltmmCapture_Mode_AutoFrames
End Sub

Private Sub mnuCaptureDIB_Click()
    ' capture DIB and copy it to the clipboard
    Dim hdib As Long
    hdib = ltmmCaptureCtrl1.CaptureDIB
    OpenClipboard hwnd
    EmptyClipboard
    SetClipboardData CF_DIB, hdib
    CloseClipboard

End Sub

Private Sub mnuCaptureManualFrames_Click()
    ' capture manual frame sequence
    ltmmCaptureCtrl1.ReadyCapture ltmmCapture_Mode_ManualFrames
    If ltmmCaptureCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
        ltmmCaptureCtrl1.TargetVCRControl.Record
    End If
    ltmmCaptureCtrl1.StartCapture ltmmCapture_Mode_ManualFrames
    While MsgBox("Click 'ok' to capture a frame.", vbOKCancel) = vbOK
       ltmmCaptureCtrl1.CaptureFrame
    Wend
    ltmmCaptureCtrl1.StopCapture
End Sub

Private Sub mnuCapturePicture_Click()
    ' capture Picture and copy it to the clipboard
    Clipboard.Clear
    Clipboard.SetData ltmmCaptureCtrl1.CapturePicture ()
End Sub

Private Sub mnuCaptureProperties_Click()
    ' show capture properties dialog
    ltmmCaptureCtrl1.ShowDialog ltmmCapture_Dlg_Capture, hwnd
End Sub

Private Sub mnuCloseCaptioning_Click()
    ' toggle close captioning
    ltmmCaptureCtrl1.ToggleCloseCaptioning
End Sub

Private Sub mnuControl_Click()
    Dim active As Boolean
    
    active = (ltmmCaptureCtrl1.State = ltmmCapture_State_Pending Or ltmmCaptureCtrl1.State = ltmmCapture_State_Running Or ltmmCaptureCtrl1.State = ltmmCapture_State_Paused)

    ' enable stop if active
    mnuStopCapture.Enabled = active

    ' enable run if paused or pending
    mnuRun.Enabled = (ltmmCaptureCtrl1.State = ltmmCapture_State_Paused Or ltmmCaptureCtrl1.State = ltmmCapture_State_Pending)

    ' enable paused if running
    mnuPause.Enabled = (ltmmCaptureCtrl1.State = ltmmCapture_State_Running)

    ' determine if capture properties are available
    mnuCaptureProperties.Enabled = ltmmCaptureCtrl1.HasDialog (ltmmCapture_Dlg_Capture)

    ' can perform normal capture?
    mnuStartCapture.Enabled = ltmmCaptureCtrl1.IsModeAvailable (ltmmCapture_Mode_VideoOrAudio)


    ' can perform auto frame capture?
    mnuCaptureAutoFrames.Enabled = ltmmCaptureCtrl1.IsModeAvailable(ltmmCapture_Mode_AutoFrames)


    ' can perform manual frame capture?
    mnuCaptureManualFrames.Enabled = ltmmCaptureCtrl1.IsModeAvailable(ltmmCapture_Mode_ManualFrames)

    'can perform still image capture?
    mnuCaptureDIB.Enabled = ltmmCaptureCtrl1.IsModeAvailable(ltmmCapture_Mode_Still)
    mnuCapturePicture.Enabled = ltmmCaptureCtrl1.IsModeAvailable(ltmmCapture_Mode_Still)
    mnuGetStillDIB.Enabled = ltmmCaptureCtrl1.IsModeAvailable(ltmmCapture_Mode_Still)
    mnuGetStillPicture.Enabled = ltmmCaptureCtrl1.IsModeAvailable (ltmmCapture_Mode_Still)

    ' check the current video size mode
    mnuFitToWindow.Checked = (ltmmCaptureCtrl1.VideoWindowSizeMode = ltmmFit)
    mnuStretchToWindow.Checked = (ltmmCaptureCtrl1.VideoWindowSizeMode = ltmmStretch)

    ' check preview
    mnuPreview.Checked = ltmmCaptureCtrl1.Preview
    mnuPreview.Enabled = Not active

    ' check preview audio
    mnuPreviewVideoAndAudio.Checked = (ltmmCaptureCtrl1.PreviewSource = ltmmCapture_Preview_VideoAndAudio)
    mnuPreviewVideoAndAudio.Enabled = Not active


    ' check close captioning
    mnuCloseCaptioning.Checked = ltmmCaptureCtrl1.CloseCaptioning
    mnuCloseCaptioning.Enabled = (active And ltmmCaptureCtrl1.CloseCaptionAvailable)

    ' check master stream
    mnuMasterNone.Checked = (ltmmCaptureCtrl1.MasterStream = ltmmCapture_MasterStream_None)
    mnuMasterAudio.Checked = (ltmmCaptureCtrl1.MasterStream = ltmmCapture_MasterStream_Audio)
    mnuMasterVideo.Checked = (ltmmCaptureCtrl1.MasterStream = ltmmCapture_MasterStream_Video)

    mnuMasterNone.Enabled = Not active
    mnuMasterAudio.Enabled = Not active
    mnuMasterVideo.Enabled = Not active

    ' check frame rate
    mnuRateDefault.Checked = Not ltmmCaptureCtrl1.UseFrameRate
    mnuRate15.Checked = (ltmmCaptureCtrl1.UseFrameRate And Abs(ltmmCaptureCtrl1.FrameRate - 15#) < 0.1)
    mnuRate30.Checked = (ltmmCaptureCtrl1.UseFrameRate And Abs(ltmmCaptureCtrl1.FrameRate - 30#) < 0.1)

    mnuRateDefault.Enabled = Not active
    mnuRate15.Enabled = Not active
    mnuRate30.Enabled = Not active

    ' check time limit
    mnuTimeLimitNone.Checked = Not ltmmCaptureCtrl1.UseTimeLimit
    mnuTimeLimit15.Checked = (ltmmCaptureCtrl1.UseTimeLimit And Abs(ltmmCaptureCtrl1.TimeLimit - 15#) < 0.1)
    mnuTimeLimit30.Checked = (ltmmCaptureCtrl1.UseTimeLimit And Abs(ltmmCaptureCtrl1.TimeLimit - 30#) < 0.1)

    mnuTimeLimitNone.Enabled = Not active
    mnuTimeLimit15.Enabled = Not active
    mnuTimeLimit30.Enabled = Not active

    ' check frame delay
    mnuFrameDelay1.Checked = (Abs(ltmmCaptureCtrl1.FrameDelay - 1#) < 0.1)
    mnuFrameDelay5.Checked = (Abs(ltmmCaptureCtrl1.FrameDelay - 5#) < 0.1)

    mnuFrameDelay1.Enabled = Not active
    mnuFrameDelay5.Enabled = Not active

    ' check target
    mnuTargetFile.Checked = (ltmmCaptureCtrl1.TargetType = ltmmCapture_Target_File)
    mnuTargetArray.Checked = (ltmmCaptureCtrl1.TargetType = ltmmCapture_Target_Array)
    mnuTargetDevice.Checked = (ltmmCaptureCtrl1.TargetType = ltmmCapture_Target_Device)

    mnuTargetFile.Enabled = Not active
    mnuTargetArray.Enabled = Not active
    mnuTargetDevice.Enabled = (ltmmCaptureCtrl1.Targetdevices.Count <> 0 And Not active)


    mnuTargetFormatAVI.Checked = (ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_Avi)
    mnuTargetFormatWAVE.Checked = (ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_WAVE)
    mnuTargetFormatMPEG1Audio.Checked = (ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_MPEG1Audio)

    mnuTargetFormatAVI.Enabled = (ltmmCaptureCtrl1.TargetType <> ltmmCapture_Target_Device And Not active)
    mnuTargetFormatWAVE.Enabled = (ltmmCaptureCtrl1.TargetType <> ltmmCapture_Target_Device And Not active)
    mnuTargetFormatMPEG1Audio.Enabled = (ltmmCaptureCtrl1.TargetType <> ltmmCapture_Target_Device And Not active)

    ' check preview processors
    mnuPreviewProcessors.Checked = (ltmmCaptureCtrl1.PreviewTap = ltmmCapture_PreviewTap_Processors)

    ' check property preview
    mnuPropertiesPreview.Checked = ltmmCaptureCtrl1.ShowDialog Preview

    ' check audio buffering
    mnuAudio05Seconds.Checked = (Abs(ltmmCaptureCtrl1.AudioBufferSize - 0.5) < 0.001)
    mnuAudio005Seconds.Checked = (Abs(ltmmCaptureCtrl1.AudioBufferSize - 0.05) < 0.001)

    ' enable vcr controls
    mnuVCRPlay.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_Play)
    mnuVCRStop.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_Stop)
    mnuVCRPause.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_Pause)
    mnuVCRFastForward.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_FastForward)
    mnuVCRRewind.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_Rewind)
    mnuVCRFastestForward.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_FastestForward)
    mnuVCRFastestReverse.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_FastestReverse)
    mnuVCRSlowestForward.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_SlowestForward)
    mnuVCRSlowestReverse.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_SlowestReverse)
    mnuVCRSeekStart.Enabled = False
    On Error Resume Next
    mnuVCRSeekStart.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_Camera And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.ReadTimecode <> 0)

    mnuVCRRecord.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_Record)
    mnuVCRPauseRecording.Enabled = (ltmmCaptureCtrl1.CaptureVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.MediaType <> ltmmVCRControl_MediaType_NotPresent And ltmmCaptureCtrl1.CaptureVCRControl.Mode <> ltmmVCRControl_Mode_PauseRecording)
End Sub

Private Sub mnuCopyTarget_Click()
    ltmmCaptureCtrl1.CopyTarget "c:\targetcopy.avi", False
End Sub

Private Sub mnuFitToWindow_Click()
    ' fit video to window
    ltmmCaptureCtrl1.VideoWindowSizeMode = ltmmFit
End Sub

Private Sub mnuFrameDelay1_Click()
    ' set the automatic sequence frame delay to 1 second
    ltmmCaptureCtrl1.FrameDelay = 1
End Sub

Private Sub mnuFrameDelay5_Click()
    ' set the automatic sequence frame delay to 5 seconds
    ltmmCaptureCtrl1.FrameDelay = 5
End Sub

Private Sub mnuFullScreen_Click()
    ' toggle full screen mode
    ltmmCaptureCtrl1.ToggleFullScreenMode
End Sub

Private Sub mnuGetStillPicture_Click()
    ' alternate method of capturing a Picture
    ltmmCaptureCtrl1.StartCapture ltmmCapture_Mode_Still
    Clipboard.Clear
    Clipboard.SetData ltmmCaptureCtrl1.GetStillPicture (5000)
    ltmmCaptureCtrl1.StopCapture

End Sub

Private Sub mnuMasterAudio_Click()
    ' set master stream to audio
    ltmmCaptureCtrl1.MasterStream = ltmmCapture_MasterStream_Audio
End Sub

Private Sub mnuMasterNone_Click()
    ' set master stream to none
    ltmmCaptureCtrl1.MasterStream = ltmmCapture_MasterStream_None
End Sub

Private Sub mnuMasterVideo_Click()
    ' set master stream to video
    ltmmCaptureCtrl1.MasterStream = ltmmCapture_MasterStream_Video
End Sub

Private Sub mnuPause_Click()
    'pause capture
    ltmmCaptureCtrl1.PauseCapture
End Sub

Private Sub mnuPreview_Click()
    ' toggle preview
    ltmmCaptureCtrl1.TogglePreview
End Sub

Private Sub mnuPreviewProcessors_Click()
    ' toggle preview processors
    If ltmmCaptureCtrl1.PreviewTap = ltmmCapture_PreviewTap_Processors Then
        ltmmCaptureCtrl1.PreviewTap = ltmmCapture_PreviewTap_Source
    Else
        ltmmCaptureCtrl1.PreviewTap = ltmmCapture_PreviewTap_Processors
    End If
End Sub

Private Sub mnuPreviewVideoAndAudio_Click()
    ' toggle audio preview
    If ltmmCaptureCtrl1.PreviewSource = ltmmCapture_Preview_VideoAndAudio Then
        ltmmCaptureCtrl1.PreviewSource = ltmmCapture_Preview_Video
    Else
        ltmmCaptureCtrl1.PreviewSource = ltmmCapture_Preview_VideoAndAudio
    End If

End Sub

Private Sub mnuPropertiesPreview_Click()
    ' toggle preview during property edits
    ltmmCaptureCtrl1.ShowDialogPreview = Not ltmmCaptureCtrl1.ShowDialogPreview
End Sub

Private Sub mnuRate15_Click()
    ' set the frame rate to 15 frames per second
    ltmmCaptureCtrl1.FrameRate = 15
    ltmmCaptureCtrl1.UseFrameRate = True
End Sub

Private Sub mnuRate30_Click()
    ' set the frame rate to 30 frames per second
    ltmmCaptureCtrl1.FrameRate = 30
    ltmmCaptureCtrl1.UseFrameRate = True
End Sub

Private Sub mnuRateDefault_Click()
    ' set the frame to the default setting
    ltmmCaptureCtrl1.UseFrameRate = False
End Sub

Private Sub mnuRun_Click()
    ' Run Capture
    ltmmCaptureCtrl1.RunCapture
End Sub

Private Sub mnuStartCapture_Click()
    ' ready normal capture mode
    ltmmCaptureCtrl1.ReadyCapture ltmmCapture_Mode_VideoOrAudio

    If ltmmCaptureCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
        ltmmCaptureCtrl1.TargetVCRControl.Record
    End If
' uncomment the following line to view the graph in DirectShow GraphEdit
'   ltmmCaptureCtrl1.EditGraph

    If MsgBox("Ready to capture. Press 'ok' to start.", vbOKCancel) = vbOK Then
        ' start capture
        ltmmCaptureCtrl1.StartCapture ltmmCaptureMode_VideoOrAudio
    Else
        ltmmCaptureCtrl1.StopCapture
        If ltmmCaptureCtrl1.TargetVCRControl.DeviceType <> ltmmVCRControl_DeviceType_NotPresent Then
            ltmmCaptureCtrl1.TargetVCRControl.Stop
        End If
    End If
End Sub

Private Sub mnuGetStillDIB_Click()
    Dim hdib As Long
    ' alternate method of capturing a DIB
    ltmmCaptureCtrl1.StartCapture ltmmCapture_Mode_Still
    hdib = ltmmCaptureCtrl1.GetStillDIB (5000)
    OpenClipboard hwnd
    EmptyClipboard
    SetClipboardData CF_DIB, hdib
    CloseClipboard
    ltmmCaptureCtrl1.StopCapture

End Sub

Private Sub mnuStopCapture_Click()
    ' stop capturing
    ltmmCaptureCtrl1.StopCapture
End Sub

Private Sub mnuStretchToWindow_Click()
    ' stretch video to window
    ltmmCaptureCtrl1.VideoWindowSizeMode = ltmmStretch
End Sub

Private Sub mnuTargetArray_Click()
    ' assign array as target
    FreeTarget

    ltmmCaptureCtrl1.VideoCompressors.Selection = ltmmCaptureCtrl1.VideoCompressors.Find ("device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD MCMP/MJPEG Codec (2.0)")
    ltmmCaptureCtrl1.AudioCompressors.Selection = ltmmCaptureCtrl1.AudioCompressors.Find ("@device:cm:{33D9A761-90C8-11D0-BD43-00A0C911CE86}\85MPEG Layer-3")
    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_Avi

    ReDim arr(0)
    ltmmCaptureCtrl1.TargetArray = arr
End Sub

Private Sub mnuTargetDevice_Click()
    ' assign a DV target
    FreeTarget
    ltmmCaptureCtrl1.VideoCompressors.Selection = -1
    ltmmCaptureCtrl1.AudioCompressors.Selection = -1
    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_dvsd
    ltmmCaptureCtrl1.TargetDevices.Selection = 0
End Sub

Private Sub mnuTargetFile_Click()
    ' assign a file as the output
    FreeTarget

    ltmmCaptureCtrl1.VideoCompressors.Selection = ltmmCaptureCtrl1.VideoCompressors.Find ("@device:sw:{33D9A760-90C8-11D0-BD43-00A0C911CE86}\LEAD MCMP/MJPEG Codec (2.0)")
    ltmmCaptureCtrl1.AudioCompressors.Selection = ltmmCaptureCtrl1.AudioCompressors.Find ("@device:cm:{33D9A761-90C8-11D0-BD43-00A0C911CE86}\85MPEG Layer-3")
    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_Avi

    If ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_Avi Then
        ltmmCaptureCtrl1.TargetFile = "c:\target.avi"
    ElseIf ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_WAVE Then
        ltmmCaptureCtrl1.TargetFile = "c:\target.wav"
    ElseIf ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_MPEG1Audio Then
        ltmmCaptureCtrl1.TargetFile = "c:\target.mp3"
    End If
    ' preallocate to 10 MB
    ltmmCaptureCtrl1.AllocTarget 10
End Sub

Private Sub mnuTargetFormatAVI_Click()
    ' set output format to AVI
    If ltmmCaptureCtrl1.TargetType = ltmmCapture_Type_File Then
        FreeTarget
        ltmmCaptureCtrl1.TargetFile = "c:\target.avi"
        ltmmCaptureCtrl1.AllocTarget 10
    End If
    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_Avi
End Sub

Private Sub mnuTargetFormatMPEG1Audio_Click()
    ' set output format to MPEG1Audio
    If ltmmCaptureCtrl1.TargetType = ltmmCapture_Type_File Then
        FreeTarget
        ltmmCaptureCtrl1.TargetFile = "c:\target.mp3"
        ltmmCaptureCtrl1.AllocTarget 10
    End If
    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_MPEG1Audio

End Sub

Private Sub mnuTargetFormatWAVE_Click()
    ' set output format to WAVE
    If ltmmCaptureCtrl1.TargetType = ltmmCapture_Type_File Then
        FreeTarget
        ltmmCaptureCtrl1.TargetFile = "c:\target.wav"
        ltmmCaptureCtrl1.AllocTarget 10
    End If
    ltmmCaptureCtrl1.TargetFormat = ltmmCapture_TargetFormat_WAVE

End Sub

Private Sub mnuTimeLimit15_Click()
    ' set the time limit to 15 seconds
    ltmmCaptureCtrl1.TimeLimit = 15
    ltmmCaptureCtrl1.UseTimeLimit = True
End Sub

Private Sub mnuTimeLimit30_Click()
    ' set the time limit to 30 seconds
    ltmmCaptureCtrl1.TimeLimit = 30
    ltmmCaptureCtrl1.UseTimeLimit = True
End Sub

Private Sub mnuTimeLimitNone_Click()
    ' disable the time limit
    ltmmCaptureCtrl1.UseTimeLimit = False
End Sub

Private Sub mnuVCRFastestForward_Click()
    ' vcr fastest forward
    ltmmCaptureCtrl1.CaptureVCRControl.FastestForward
End Sub

Private Sub mnuVCRFastestReverse_Click()
    ' vcr fastest reverse
    ltmmCaptureCtrl1.CaptureVCRControl.FastestReverse
End Sub

Private Sub mnuVCRFastForward_Click()
    ' vcr fast forward
    ltmmCaptureCtrl1.CaptureVCRControl.FastestForward
End Sub

Private Sub mnuVCRPause_Click()
    ' vcr pause
    ltmmCaptureCtrl1.CaptureVCRControl.Pause
End Sub

Private Sub mnuVCRPauseRecording_Click()
    ' vcr pause recording
    ltmmCaptureCtrl1.CaptureVCRControl.PauseRecording
End Sub

Private Sub mnuVCRPlay_Click()
    ' vcr play
    ltmmCaptureCtrl1.CaptureVCRControl.Play
End Sub

Private Sub mnuVCRRecord_Click()
    ' vcr record
    ltmmCaptureCtrl1.CaptureVCRControl.Record
End Sub

Private Sub mnuVCRRewind_Click()
    ' vcr rewind
    ltmmCaptureCtrl1.CaptureVCRControl.Rewind
End Sub

Private Sub mnuVCRSeekStart_Click()
    ' seek timecode 0
    ltmmCaptureCtrl1.CaptureVCRControl.SeekTimecode 0
End Sub

Private Sub mnuVCRSlowestForward_Click()
    ' vcr slowest forward
    ltmmCaptureCtrl1.CaptureVCRControl.SlowestForward
End Sub

Private Sub mnuVCRSlowestReverse_Click()
    ' vcr slowest reverse
    ltmmCaptureCtrl1.CaptureVCRControl.SlowestReverse
End Sub

Private Sub mnuVCRStop_Click()
    ' vcr stop
    ltmmCaptureCtrl1.CaptureVCRControl.Stop
End Sub

Private Sub mnuVideoProcessors_Click()
    ' video processors
    ltmmCaptureCtrl1.ShowDialog ltmmCapture_Dlg_VideoProcessors, hwnd
End Sub