VERSION 5.00 Begin VB.Form Form1 Caption = "Form1" ClientHeight = 10545 ClientLeft = 60 ClientTop = 345 ClientWidth = 9540 LinkTopic = "Form1" ScaleHeight = 703 ScaleMode = 3 'Pixel ScaleWidth = 636 StartUpPosition = 3 'Windows Default Begin VB.PictureBox pctLeft Height = 3675 Left = 60 ScaleHeight = 3615 ScaleWidth = 4815 TabIndex = 11 Top = 5460 Width = 4875 End Begin VB.CommandButton cmdCapCaptureL Caption = "Capture" Height = 315 Left = 1920 TabIndex = 10 Top = 5100 Width = 915 End Begin VB.CommandButton cmdCapDisplayL Caption = "Display" Height = 315 Left = 1620 TabIndex = 9 Top = 1020 Width = 735 End Begin VB.CommandButton cmdDestroyCapWindowL Caption = "Destroy" Height = 315 Left = 4020 TabIndex = 8 Top = 1020 Width = 735 End Begin VB.CommandButton cmdCreateCapWindowL Caption = "Create" Height = 315 Left = 3360 TabIndex = 7 Top = 1020 Width = 615 End Begin VB.ComboBox cmbDeviceR Height = 315 Left = 5040 Style = 2 'Dropdown List TabIndex = 6 Top = 660 Width = 4695 End Begin VB.CommandButton cmdCapFormatL Caption = "Format" Height = 315 Left = 840 TabIndex = 5 Top = 1020 Width = 735 End Begin VB.CommandButton cmdCapSourceL Caption = "Source" Height = 315 Left = 60 TabIndex = 4 Top = 1020 Width = 735 End Begin VB.TextBox txtLog Height = 5055 Left = 6360 MultiLine = -1 'True TabIndex = 3 Top = 1560 Width = 2895 End Begin VB.ComboBox cmbDeviceL Height = 315 Left = 60 Style = 2 'Dropdown List TabIndex = 2 Top = 660 Width = 4695 End Begin VB.Timer tmrMain Interval = 1000 Left = 3600 Top = 240 End Begin VB.CommandButton cmdStop Caption = "Stop" Enabled = 0 'False Height = 255 Left = 1440 TabIndex = 1 Top = 360 Width = 735 End Begin VB.CommandButton cmdStart Caption = "start" Height = 255 Left = 660 TabIndex = 0 Top = 360 Width = 735 End Begin VB.Shape shpCapL Height = 3675 Left = 60 Top = 1380 Width = 4875 End End Attribute VB_Name = "Form1" Attribute VB_GlobalNameSpace = False Attribute VB_Creatable = False Attribute VB_PredeclaredId = True Attribute VB_Exposed = False Dim lwndcL As Long ' window handle for left preview Dim lwndcR As Long ' window handle for right preview Private Sub Form_Load() Dim lpszName As String * 100 Dim lpszVer As String * 100 Dim i As Integer Dim lResult As Long ' Get a list of all the installed drivers and put them in the combos i = 0 Do lResult = capGetDriverDescriptionA(i, lpszName, 100, lpszVer, 100) ' Retrieves driver info If lResult Then cmbDeviceL.AddItem lpszName cmbDeviceR.AddItem lpszName i = i + 1 End If Loop Until lResult = False End Sub Private Sub cmdCreateCapWindowL_Click() ' Dim lpszName As String * 100 ' Dim lpszVer As String * 100 Dim Caps As CAPDRIVERCAPS ' Create Capture Window ' capGetDriverDescriptionA cmbDeviceL.ListIndex, lpszName, 100, lpszVer, 100 '// Retrieves driver info lwndcL = capCreateCaptureWindowA("Left Camera", WS_CAPTION Or WS_THICKFRAME Or WS_VISIBLE Or WS_CHILD, shpCapL.Left, shpCapL.Top, 160, 120, Me.hWnd, 0) SetWindowText lwndcL, "Left Camera" ' Set the video stream callback function ' capSetCallbackOnStatus lwndcL, AddressOf CapStatusCallbackL ' capSetCallbackOnError lwndcL, AddressOf CapErrorCallbackL ' Connect the capture window to the driver If capDriverConnect(lwndcL, cmbDeviceL.ListIndex) Then ' Only do the following if the connect was successful.if it fails, the error will be reported in the call back function. capDriverGetCaps lwndcL, VarPtr(Caps), Len(Caps) If Caps.fHasDlgVideoSource = 0 Then cmdCapSourceL.Enabled = False If Caps.fHasDlgVideoFormat = 0 Then cmdCapFormatL.Enabled = False If Caps.fHasDlgVideoDisplay = 0 Then cmdCapDisplayL.Enabled = False capPreviewRate lwndcL, 66 ' Set the preview rate in milliseconds capPreview lwndcL, True ' Start previewing the image from the camera ResizeCaptureWindow lwndcL ' Resize the capture window to show the whole image End If End Sub Private Sub cmdDestroyCapWindowL_Click() ' Disable all callbacks capSetCallbackOnError lwndcL, vbNull capSetCallbackOnStatus lwndcL, vbNull capSetCallbackOnYield lwndcL, vbNull capSetCallbackOnFrame lwndcL, vbNull capSetCallbackOnVideoStream lwndcL, vbNull capSetCallbackOnWaveStream lwndcL, vbNull capSetCallbackOnCapControl lwndcL, vbNull End Sub 'Private Sub cmbDeviceL_Change() ' Dim sTitle As String ' Dim Caps As CAPDRIVERCAPS ' ' If cmboSource.ListIndex <> -1 Then ' '// Connect the capture window to the driver ' If capDriverConnect(lwndcL, cmboSource.ListIndex) Then ' '// Get the capabilities of the capture driver ' capDriverGetCaps lwndcL, VarPtr(Caps), Len(Caps) ' ' '// If the capture driver does not support a dialog, grey it out ' '// in the menu bar. ' frmMain.mnuSource.Enabled = Caps.fHasDlgVideoSource ' frmMain.mnuFormat.Enabled = Caps.fHasDlgVideoFormat ' frmMain.mnuDisplay.Enabled = Caps.fHasDlgVideoDisplay ' ' sTitle = cmboSource.Text ' ' SetWindowText lwndcL, sTitle ' ResizeCaptureWindow lwndcL ' End If ' End If 'End Sub Private Sub cmdCapDisplayL_Click() capDlgVideoDisplay lwndcL End Sub Private Sub cmdCapFormatL_Click() capDlgVideoFormat lwndcL ResizeCaptureWindow lwndcL End Sub Private Sub cmdCapSourceL_Click() capDlgVideoSource lwndcL End Sub Private Sub cmdCapCaptureL_Click() 'capEditCopy lwndcL capFileSaveDIB lwndcL, "cap_left.bmp" ' now load it into the picture pctLeft.Picture = LoadPicture("cap_left.bmp") End Sub Private Sub cmdStart_Click() cmdStart.Enabled = False cmdStop.Enabled = True 'Setup a capture window (You can replace "WebcamCapture" with watever you want) ' mCapHwnd = capCreateCaptureWindowA("WebcamCapture", 0, 0, 0, 320, 240, Me.hWnd, 0) 'Connect to capture device ' DoEvents: SendMessage mCapHwnd, CONNECT, 0, 0 tmrMain.Enabled = True End Sub Private Sub cmdStop_Click() cmdStart.Enabled = True cmdStop.Enabled = False tmrMain.Enabled = False 'Make sure to disconnect from capture source!!! DoEvents: SendMessage mCapHwnd, DISCONNECT, 0, 0 End Sub Private Sub tmrMain_Timer() On Error Resume Next 'Get Current Frame SendMessage mCapHwnd, GET_FRAME, 0, 0 'Copy Current Frame to ClipBoard SendMessage mCapHwnd, COPY, 0, 0 'Put ClipBoard's Data to picOutput picOutput.Picture = Clipboard.GetData 'Clear ClipBoard Clipboard.Clear End Sub