Hi JHPJHP,
As my program works if I initiate another program like MS-Camera to get the driver working first, I get 100% success so I did not use the VfW libs. I'm concerned using compiled codes for future development. Thanks for your replies.
Anyway, let's throw the code in for discussion. For the program to work, run MS-Camera first, then tun this. The screen turns green on my PC. After that close MS-Camera and control will then be passed to the program.
Code: Select all
Prototype.i PxCapCreateCaptureWindow(lpszWindowName.s, dwStyle.l, x.l, y.l, nWidth.l, nHeight.l, hWndParent.l, nId.l)
Prototype.b PxCapGetDriverDescription(wIndex.w, *lpszName, cbName.l, *lpszVer, cbVer.l)
Global var_avicap32_lib
var_avicap32_lib = OpenLibrary(#PB_Any, "avicap32.dll")
If var_avicap32_lib
CompilerIf #PB_Compiler_Unicode
Global capCreateCaptureWindow.PxCapCreateCaptureWindow = GetFunction(var_avicap32_lib, "capCreateCaptureWindowW")
Global capGetDriverDescription.PxCapGetDriverDescription = GetFunction(var_avicap32_lib, "capGetDriverDescriptionW")
CompilerElse
Global capCreateCaptureWindow.PxCapCreateCaptureWindow = GetFunction(var_avicap32_lib, "capCreateCaptureWindowA")
Global capGetDriverDescription.PxCapGetDriverDescription = GetFunction(var_avicap32_lib, "capGetDriverDescriptionA")
CompilerEndIf
EndIf
Procedure capDriverConnect(lwnd.l, nDevice.l = 0)
ProcedureReturn SendMessage_(lwnd, #WM_CAP_DRIVER_CONNECT, nDevice, 0)
EndProcedure
Procedure capSetPreview(lwnd.l, lTrue.l = #True)
ProcedureReturn SendMessage_(lwnd, #WM_CAP_SET_PREVIEW, lTrue, 0)
EndProcedure
Procedure capSetPreviewRate(lwnd.l, wMS.l)
ProcedureReturn SendMessage_(lwnd, #WM_CAP_SET_PREVIEWRATE, wMS, 0)
EndProcedure
#CAM_W = 640
#CAM_H = 480
OpenWindow(0, 0, 0, #CAM_W, #CAM_H, "Camera")
cam_handle = capCreateCaptureWindow("Camera", #WS_CHILD | #WS_VISIBLE, 0, 0, #CAM_W, #CAM_H, WindowID(0), 0)
Debug cam_handle
Debug capDriverConnect(cam_handle, 0)
Debug capSetPreview(cam_handle, #True)
Debug capSetPreviewRate(cam_handle, 30)
Repeat: Until WaitWindowEvent() = #PB_Event_CloseWindow