He usando un Timer, un Picture y dos Button para este ejemplo.
Nota: No lo documento suficientemente porque no se podría redundar en una exposición tan magistral como la anterior.
Cualquier sugerencia que optimize este code es bienvenida.
Private Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias "capCreateCaptureWindowA" (ByVal lpszWindowName As String, ByVal dwStyle As Long, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hwndParent As Long, ByVal nID As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function DestroyWindow Lib "user32" (ByVal hndw As Long) As Boolean
Private Const CONNECT As Long = 1034
Private Const DISCONNECT As Long = 1035
Private Const GET_FRAME As Long = 1084
Private Const COPY As Long = 1054
Private hWndCap As Long
Private Sub START_WEBCAM_Button1_Click()
hWndCap = capCreateCaptureWindow("WebcamCapture", 0, 0, 0, 160, 120, Me.hwnd, 0)
DoEvents
SendMessage hWndCap, CONNECT, 0, 0
Timer1.Enabled = True
End Sub
Private Sub STOP_WEBCAM_Button2_Click()
DoEvents: SendMessage hWndCap, DISCONNECT, 0, 0
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
'Obtiene frames para Picture1
SendMessage hWndCap, GET_FRAME, 0, 0
SendMessage hWndCap, COPY, 0, 0
Picture1.Picture = Clipboard.GetData
Clipboard.Clear
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
Timer1.Interval = 1
End Sub
Private Sub Form_Unload(Cancel As Integer)
DestroyWindow hWndCap
End Sub
A los interesandos en este hilo:
Publiquen code para transmitir los frames capturados de una forma óptima aunque se tratase de conexiones de 56Kb