以下测试可用
*--以下定义摄像头扩展应用:一般放到主程序或表单(集)的Load事件中
Public WM_CAP_DRIVER_DISCONNECT
Public hwndc,WM_CAP_SAVEDIB,WM_CAP_FILE_SET_CAPTURE_FILEA,WM_CAP_SEQUENCE,WM_CAP_STOP
Declare Integer capCreateCaptureWindowA In "AVICAP32.DLL" String lpszWindowName ,Integer dwStyle ,;
Integer x, Integer Y, Integer nWidth ,Integer nHeight,Integer ParentWin,Integer nId
Declare Integer SendMessage In "user32" Integer HWnd, Integer wmsg,Integer wpar1, Integer wpar2
Declare Integer SendMessage In "user32" As SendMessageA Integer HWnd, Integer wmsg,Integer wpar1,String wpar2
hwndc=0
*--定以上义摄像头扩展应用:一般放到主程序或表单(集)的Load事件中
*--显示:可以放到按钮或表单(集)的Init事件中,!!!
WM_USER = 1024
WM_CAP_START = WM_USER
WM_CAP_STOP = WM_CAP_START + 68
WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
WM_CAP_SAVEDIB = WM_CAP_START + 25
WM_CAP_GRAB_FRAME = WM_CAP_START + 60
WM_CAP_SEQUENCE = WM_CAP_START + 62
WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20
WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63
WM_CAP_SET_OVERLAY =WM_CAP_START+ 51
WM_CAP_SET_PREVIEW =WM_CAP_START+ 50
WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6
WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2
WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3
WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5
WM_CAP_SET_SCALE=WM_CAP_START+ 53
WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52
WM_CAP_SET_MCI_DEVICE=WM_CAP_START+ 66
&&//设置媒体控制接口
WM_CAP_DLG_VIDEOSOURCE =WM_CAP_START+ 42
&&1066 打开属性设置对话框,设置对比度、亮度等。(视频源对话框) 选择视频输入通道和视频图像的动态参数。
*第3、4个参数是定义显示位置,第5、6个参数是定义显示大小。
hWndC = capCreateCaptureWindowA('My Own Capture Window',1342177280,100,100,320,240,Thisform.HWnd ,0)
If hWndC<>0
SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)
&&设置回调视频流
SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0)
&&设置回调错误
SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)
&&设置回调状态,原始值为:0,0
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0)
&&驱动程序连接
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0)
&&驱动程序连接
SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0)
&&设置预览视频的缩放比例
SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0)
&&设置预览模式下图像的帧速度
SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0)
&&设置覆盖
SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0)
&&设置预览模式
SendMessage(hWndC, WM_CAP_SET_MCI_DEVICE, 1, 0)
&&设置媒体控制接口
ENDIF
*--关闭显示:
IF hWndC<>0
SendMessage(hWndC,WM_CAP_DRIVER_DISCONNECT, 0, 0)
hWndC=0
ENDIF