Академический Документы
Профессиональный Документы
Культура Документы
End Sub
'Open View
Private Sub OpenPreviewWindow()
On Error Resume Next
'
' Open Preview window in picturebox
'
hHwnd = capCreateCaptureWindowA(iDevice, WS_VISIBLE Or WS_CHILD, 0,
0, 640, _
480, pview.Handle.ToInt32, 0)
'
' Connect to device
'
If SendMessage(hHwnd, WM_CAP_DRIVER_CONNECT, iDevice, 0) Then
'
'Set the preview scale
'
SendMessage(hHwnd, WM_CAP_SET_SCALE, True, 0)
'
'Set the preview rate in milliseconds
'
SendMessage(hHwnd, WM_CAP_SET_PREVIEWRATE, 66, 0)
'
'Start previewing the image from the camera
'
SendMessage(hHwnd, WM_CAP_SET_PREVIEW, True, 0)
'
' Resize window to fit in picturebox
'
SetWindowPos(hHwnd, HWND_BOTTOM, 0, 0, pview.Width, pview.Height,
_
SWP_NOMOVE Or SWP_NOZORDER)
btncapture.Enabled = False
BtnSave.Enabled = True
btnstop.Enabled = True
Else
'
' Error connecting to device close window
'
DestroyWindow(hHwnd)
btncapture.Enabled = True
BtnSave.Enabled = False
btnstop.Enabled = False
pview.Image = Nothing
pview.SizeMode = PictureBoxSizeMode.StretchImage
pview.BackColor = Color.Black
pview.BackgroundImage = Nothing
pview.BackgroundImageLayout = ImageLayout.None
pview.Refresh()
End If
End Sub
'
' close window
'
DestroyWindow(hHwnd)
btncapture.Enabled = True
BtnSave.Enabled = False
btnstop.Enabled = False
pview.Image = Nothing
pview.SizeMode = PictureBoxSizeMode.StretchImage
pview.BackColor = Color.Black
pview.BackgroundImage = Nothing
pview.BackgroundImageLayout = ImageLayout.None
pview.Refresh()
End Sub
btncapture.Enabled = True
BtnSave.Enabled = False
btnstop.Enabled = False
'Load Device List
Call LoadDeviceList()
End Sub
Private Sub cameraform_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
On Error Resume Next
'Load Object Value TO Default
ClearAllObject()
End Sub
Private Sub btncapture_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btncapture.Click
On Error Resume Next
iDevice = lst1.SelectedIndex
OpenPreviewWindow()
End Sub
End Class