Thanks for the program @LangueR ,
The program doesn’t work on my Windows Book, and I modified some of the code, and its getting closer. Here is the modification from WindowMain.BtnConnect.Action:
Sub Action() Handles Action
pCaptureDevice = WindowSelectDevice.getResult
Soft Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (lpszWindowName As Integer,dwStyle As Integer,x As Integer,y As Integer,nWidth As Integer,nHeight As Integer,hWndParent As Integer,nID As Integer)As Integer
Soft Declare Function SendMessage Lib "user32" alias "SendMessageA"(hwnd As Integer,wMsg As Integer,wParam As Integer,lParam As Integer)As Integer
If pCaptureWindow <> 0 Then
Call SendMessage(pCaptureWindow,WM_CAP_DRIVER_DISCONNECT,pCaptureDevice,0)
End If
Const WS_CHILD As Integer = &H40000000
Const WS_VISIBLE As Integer = &H10000000
pCaptureWindow=capCreateCaptureWindowA(pCaptureDevice,BITOR(WS_VISIBLE,WS_CHILD),0,0,canvas1.Width,canvas1.Height,canvas1.handle,0)
If SendMessage (pCaptureWindow,WM_CAP_DRIVER_CONNECT,pCaptureDevice,0)=1 Then //always sends zero
Call SendMessage (pCaptureWindow,WM_CAP_SET_SCALE,1,0)
Call SendMessage (pCaptureWindow,WM_CAP_SET_PREVIEWRATE,60,0)
Call SendMessage (pCaptureWindow,WM_CAP_SET_PREVIEW,1,0)
Call SendMessage (pCaptureWindow,WM_CAP_DLG_VIDEOFORMAT,1,0)
Me.Enabled = False
BtnDisconnect.Enabled = True
BtnCapturePicture.Enabled = True
System.DebugLog "Connected"
Else
System.DebugLog "Error connecting"
End If
End Sub
I placed the SendMessage … WM_CAP_DRIVER_CONNECT into an If-Else statement and it is always returning zero. If it connects then the returned value should be 1. Here is a link to WM_CAP_DRIVER_CONNECT information:
WM_CAP_DRIVER_CONNECT
I haven’t figured it out yet, and ran out of time, and I thought that I would share this with everyone. My Surface Book has a front and rear facing camera. Pressing the Start webcam… pushbutton displays the Select Capture Device window, and I select the only option of Microsoft WDM Image Capture (Win32). AFter pressing the OK button, then I get another window which is the Video Source and I am able to select one of two choices: 1) Microsoft Camera Front, 2) Microsoft Camera Rear. I select the front camera and Canvas1 is black and the System.DebugLog “Error connecting” message is shown in the IDE.
The driver is not connecting for some reason.