Hi I have a project that connects to a webcam.
When ever I click the save picture button i get a blank pic.
Can anyone help please.
Module:
Option Explicit
Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias _
"capCreateCaptureWindowA" ( _
ByVal a As String, ByVal b As Long, ByVal c As Integer, _
ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, _
ByVal g As Long, ByVal h As Integer) As Long
Form:
Option Explicit
Const ws_child As Long = &H40000000
Const ws_visible As Long = &H10000000
Const WM_USER = 1024
Const wm_cap_driver_connect = WM_USER + 10
Const wm_cap_set_preview = WM_USER + 50
Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52
Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11
Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41
Private hwdc As Long
Private startcap As Boolean
Private Sub cmdCapture_Click()
Dim temp As Long
hwdc = capCreateCaptureWindow("Dixanta Vision System", _
ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
If (hwdc <> 0) Then
temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
startcap = True
Else
MsgBox ("No Webcam found")
End If
End Sub
Private Sub cmdClose_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
startcap = False
End If
End Sub
Private Sub cmdSave_Click()
SavePicture Picture1.Image, "c:\Test.bmp"
MsgBox "Picture Saved as: c:\test.bmp"
End Sub
Private Sub cmdVideoFormat_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
Else
MsgBox "Please Connect First"
End If
End Sub
Form has the 4 buttons and 1 picture box
Thanks
When ever I click the save picture button i get a blank pic.
Can anyone help please.
Module:
Option Explicit
Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, _
ByVal lParam As Long) As Long
Declare Function capCreateCaptureWindow Lib "avicap32.dll" Alias _
"capCreateCaptureWindowA" ( _
ByVal a As String, ByVal b As Long, ByVal c As Integer, _
ByVal d As Integer, ByVal e As Integer, ByVal f As Integer, _
ByVal g As Long, ByVal h As Integer) As Long
Form:
Option Explicit
Const ws_child As Long = &H40000000
Const ws_visible As Long = &H10000000
Const WM_USER = 1024
Const wm_cap_driver_connect = WM_USER + 10
Const wm_cap_set_preview = WM_USER + 50
Const WM_CAP_SET_PREVIEWRATE = WM_USER + 52
Const WM_CAP_DRIVER_DISCONNECT As Long = WM_USER + 11
Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_USER + 41
Private hwdc As Long
Private startcap As Boolean
Private Sub cmdCapture_Click()
Dim temp As Long
hwdc = capCreateCaptureWindow("Dixanta Vision System", _
ws_child Or ws_visible, 0, 0, 320, 240, Picture1.hWnd, 0)
If (hwdc <> 0) Then
temp = SendMessage(hwdc, wm_cap_driver_connect, 0, 0)
temp = SendMessage(hwdc, wm_cap_set_preview, 1, 0)
temp = SendMessage(hwdc, WM_CAP_SET_PREVIEWRATE, 30, 0)
startcap = True
Else
MsgBox ("No Webcam found")
End If
End Sub
Private Sub cmdClose_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
startcap = False
End If
End Sub
Private Sub cmdSave_Click()
SavePicture Picture1.Image, "c:\Test.bmp"
MsgBox "Picture Saved as: c:\test.bmp"
End Sub
Private Sub cmdVideoFormat_Click()
Dim temp As Long
If startcap = True Then
temp = SendMessage(hwdc, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
Else
MsgBox "Please Connect First"
End If
End Sub
Form has the 4 buttons and 1 picture box
Thanks