Using ltmmCaptureCtrl to Perform Simple Still Image Capture (Visual Basic)

1.

Start with the project that you created in My First Capture.

2.

Add a Button control to your form, and name it as follows:

 

Name

Caption

 

btnGetFreeDIB

Get and Free Captured Bitmap

3.

Add the following to the declarations procedure of the general object in your main form:

Private Declare Function GlobalFree Lib "kernel32" (ByVal hMem As Long) As Long

4.

Update the btnStartCapture_Click Sub to be as follows:

Private Sub btnStartCapture_Click()
   ltmmCaptureCtrl1.StartCapture ltmmCapture_Mode_Still
End Sub

5.

Handle the btnGetFreeDIB Click event, and code btnGetFreeDIB_Click Sub as follows:

Private Sub btnGetFreeDIB_Click()
   Dim hDIB As Long

   hDIB = ltmmCaptureCtrl1.GetStillDIB (100) 
   If (hDIB <> 0) Then
      MsgBox "Operation done successfully"
      GlobalFree hDIB
   End If
End Sub

6.

Run your program to test it.