Wednesday, October 14, 2020

Simple Web Cam Capture Form With Visual Basic

 

 


SIMPLE PROJECT WEB CAM CAPTURE WITH FORM VISUAL BASIC

 

1. Design Form Capture Web Cam Visual Basic


 

2. Source Code FrmCam

 Option Explicit
Dim hCap As Long

Private Sub CmdClose_Click()
Dim temp As Long
temp = SendMessage(hCap, WM_CAP_DRIVER_DISCONNECT, 0&, 0&)
Unload Me
End Sub

Private Sub CmdMulai_Click()
hCap = capCreateCaptureWindow("Take a Camera Shot" _
, WS_CHILD Or WS_VISIBLE, 0, 0, gbrWebcam.Width _
, gbrWebcam.Height, gbrWebcam.hWnd, 0)
If hCap <> 0 Then
Call SendMessage(hCap, WM_CAP_DRIVER_CONNECT, 0, 0)
Call SendMessage(hCap, WM_CAP_SET_PREVIEWRATE, 66, 0&)
Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(True), 0&)
End If
End Sub

Private Sub CmdSetting_Click()
Dim temp As Long
temp = SendMessage(hCap, WM_CAP_DLG_VIDEOFORMAT, 0&, 0&)
End Sub

Private Sub CmdSimpan_Click()
Dim sFileName As String
Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(False), 0&)
With CDialog
.CancelError = True
.Flags = cdlOFNPathMustExist Or cdlOFNOverwritePrompt
.Filter = "JPEG Picture(*.jpg)|*.jpg|All Files|*.*"
.ShowSave
sFileName = .FileName
End With
Call SendMessage(hCap, WM_CAP_FILE_SAVEDIB, 0&, ByVal CStr(sFileName))
DoFinally:
Call SendMessage(hCap, WM_CAP_SET_PREVIEW, CLng(True), 0&)
End Sub
 

3. Source Module

 Option Explicit

Public Const WS_CHILD As Long = &H40000000
Public Const WS_VISIBLE As Long = &H10000000
Public Const WM_USER As Long = &H400
Public Const WM_CAP_START As Long = WM_USER
Public Const WM_CAP_DRIVER_CONNECT As Long = WM_CAP_START + 10
Public Const WM_CAP_DRIVER_DISCONNECT As Long = WM_CAP_START + 11
Public Const WM_CAP_SET_PREVIEW As Long = WM_CAP_START + 50
Public Const WM_CAP_SET_PREVIEWRATE As Long = WM_CAP_START + 52
Public Const WM_CAP_DLG_VIDEOFORMAT As Long = WM_CAP_START + 41
Public Const WM_CAP_FILE_SAVEDIB As Long = WM_CAP_START + 25
Public Declare Function capCreateCaptureWindow _
Lib "avicap32.dll" Alias "capCreateCaptureWindowA" _
(ByVal lpszWindowName As String, ByVal dwStyle As Long _
, ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long _
, ByVal nHeight As Long, ByVal hwndParent As Long _
, ByVal nID As Long) As Long
Public Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long _
, ByVal wParam As Long, ByRef lParam As Any) As Long






No comments:

Post a Comment

Free Templates Source Code Simple Project Java ZK Framework

  Free Templates Source Code Simple Project Java ZK Framework   ZK Framework aims to combine the simplicity and security from its server-cen...