摄像头问题(小弟初接触vb)
Const WS_CHILD = &H40000000
Const WS_VISIBLE = &H10000000
Const WM_CAP_START = &H400
Const WM_CAP_STOP = WM_CAP_START + 68
Const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10
Const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11
......
Private Declare Function SendMessage& Lib "user32 " Alias "SendMessageA " (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any)
Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll " (lpszWindowName As String, dwStyle As Long, x As Integer, y As Integer, nWidth As Integer, nHeight As Integer, ParentWin As Long, nID As Integer) As Long
......
Private Sub Command1_Click()
hWndC = capCreateCaptureWindowA( "windows ", WS_VISIBLE + WS_CHILD, Frame1.Left, Frame1.Top, Frame1.Width, Frame1.Height, Form1.hwnd, 0)
If hWndC > 0 Then
.....
endif
End Sub
为什么 hWndC 的值为0
[解决办法]
把:
hWndC = capCreateCaptureWindowA( "windows ", WS_VISIBLE + WS_CHILD, Frame1.Left, Frame1.Top, Frame1.Width, Frame1.Height, Form1.hwnd, 0)
修改成:
hWndC = capCreateCaptureWindowA(byval "windows ", WS_VISIBLE + WS_CHILD, Frame1.Left, Frame1.Top, Frame1.Width, Frame1.Height, Form1.hwnd, 0)