Private Const WM_USER As Short = &H400S
Private Const WS_CHILD As Integer = &H40000000
Private Const WS_VISIBLE As Integer = &H10000000
Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_USER + 10
Private Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_USER + 11
Private Const WM_CAP_SET_PREVIEW As Integer = WM_USER + 50
Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_USER + 52
'API funkcije
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Short, ByVal lParam As String) As Integer
Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer
';;;;;;;;;;;;;;
Dim bSnima As Boolean = False
Private hHwnd As Integer
Private lwndC As Integer
Private FPS As Integer = 15
Private Visina As Integer = 343
Private Sirina As Integer = 360
Private Uredaj As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
If bSnima Then
Prestani()
Application.DoEvents()
Else
PostaviCam(Me.Handle.ToInt32)
End If
End Sub
Private Function Postavi() As Boolean
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, CShort(Uredaj), CType(0, String)) = 1 Then
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, CShort(FPS), CType(0, String))
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, CType(0, String))
bSnima = True
Return True
Else
bSnima = False
Return False
End If
End Function
Public Function Prestani() As Boolean
If bSnima Then
Prestani = CBool(SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, 0, CType(0, String)))
bSnima = False
End If
End Function
Public Sub PostaviCam(ByVal parentH As Integer)
If bSnima = True Then
MessageBox.Show("Kamera je vec ukljucena")
Exit Sub
Else
hHwnd = capCreateCaptureWindowA(Uredaj, WS_VISIBLE Or WS_CHILD, 0, 0, Sirina, CShort(Visina), parentH, 0)
If Postavi() = False Then
MessageBox.Show("Pojavila se greska")
End If
End If
End Sub
Please SUBSCRIBE to get new articles directly into your Email inbox!
Private Const WS_CHILD As Integer = &H40000000
Private Const WS_VISIBLE As Integer = &H10000000
Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_USER + 10
Private Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_USER + 11
Private Const WM_CAP_SET_PREVIEW As Integer = WM_USER + 50
Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_USER + 52
'API funkcije
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Short, ByVal lParam As String) As Integer
Private Declare Function capCreateCaptureWindowA Lib "avicap32.dll" (ByVal lpszWindowName As String, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Short, ByVal hWndParent As Integer, ByVal nID As Integer) As Integer
';;;;;;;;;;;;;;
Dim bSnima As Boolean = False
Private hHwnd As Integer
Private lwndC As Integer
Private FPS As Integer = 15
Private Visina As Integer = 343
Private Sirina As Integer = 360
Private Uredaj As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
If bSnima Then
Prestani()
Application.DoEvents()
Else
PostaviCam(Me.Handle.ToInt32)
End If
End Sub
Private Function Postavi() As Boolean
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, CShort(Uredaj), CType(0, String)) = 1 Then
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, CShort(FPS), CType(0, String))
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, 1, CType(0, String))
bSnima = True
Return True
Else
bSnima = False
Return False
End If
End Function
Public Function Prestani() As Boolean
If bSnima Then
Prestani = CBool(SendMessage(hHwnd, WM_CAP_DRIVER_DISCONNECT, 0, CType(0, String)))
bSnima = False
End If
End Function
Public Sub PostaviCam(ByVal parentH As Integer)
If bSnima = True Then
MessageBox.Show("Kamera je vec ukljucena")
Exit Sub
Else
hHwnd = capCreateCaptureWindowA(Uredaj, WS_VISIBLE Or WS_CHILD, 0, 0, Sirina, CShort(Visina), parentH, 0)
If Postavi() = False Then
MessageBox.Show("Pojavila se greska")
End If
End If
End Sub
Please SUBSCRIBE to get new articles directly into your Email inbox!
تعليقات
إرسال تعليق