首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > VB Dotnet >

VB.NET通过调用摄像头或数码相机拍照并保存照片解决方法

2012-02-28 
VB.NET通过调用摄像头或数码相机拍照并保存照片开发环境:VS 2005(WINForm)要实现的功能:在窗体上添加一个P

VB.NET通过调用摄像头或数码相机拍照并保存照片
开发环境:VS 2005(WINForm)
要实现的功能:
  在窗体上添加一个PictureBox控件或其他控件,在此控件上能够看到通过摄像头或数据相机动态拍摄的视频,当按一下窗体上另外一个Button控件后,保存图片到指定路径。
最好是不要用第三方控件,直接用API或系统自身的方法。谢谢!
 

[解决办法]
mark and up
[解决办法]
我也来学习下
[解决办法]
只做过在原有摄像头软件基础上修改,抓图很容易
没有软件,自己写接收摄像头数据不知道怎么搞,学习下
[解决办法]
学习学习 我是菜鸟!
[解决办法]
me.picturebox1.image.save(“c:\a.ipg”)

[解决办法]
我也想知道
[解决办法]

VB.NET code
Imports SystemImports System.Runtime.InteropServicesImports System.DrawingImports System.Drawing.ImagingPublic Class Cam    Private Const WM_USER As Integer = &H400    Private Const WS_CHILD As Integer = &H40000000    Private Const WS_VISIBLE As Integer = &H10000000    Private Const WM_CAP_START As Integer = WM_USER    Private Const WM_CAP_STOP As Integer = WM_CAP_START + 68    Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP_START + 10    Private Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP_START + 11    Private Const WM_CAP_SAVEDIB As Integer = WM_CAP_START + 25    Private Const WM_CAP_GRAB_FRAME As Integer = WM_CAP_START + 60    Private Const WM_CAP_SEQUENCE As Integer = WM_CAP_START + 62    Private Const WM_CAP_FILE_SET_CAPTURE_FILEA As Integer = WM_CAP_START + 20    Private Const WM_CAP_SEQUENCE_NOFILE As Integer = WM_CAP_START + 63    Private Const WM_CAP_SET_OVERLAY As Integer = WM_CAP_START + 51    Private Const WM_CAP_SET_PREVIEW As Integer = WM_CAP_START + 50    Private Const WM_CAP_SET_CALLBACK_VIDEOSTREAM As Integer = WM_CAP_START + 6    Private Const WM_CAP_SET_CALLBACK_ERROR As Integer = WM_CAP_START + 2    Private Const WM_CAP_SET_CALLBACK_STATUSA As Integer = WM_CAP_START + 3    Private Const WM_CAP_SET_CALLBACK_FRAME As Integer = WM_CAP_START + 5    Private Const WM_CAP_SET_SCALE As Integer = WM_CAP_START + 53    Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP_START + 52    Public Const WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1    Public Const WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3    Public Const WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4    Public Const WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7    Public Const WM_CAP_GET_USER_DATA = WM_CAP_START + 8    Public Const WM_CAP_SET_USER_DATA = WM_CAP_START + 9    Public Const WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12    Public Const WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13    Public Const WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14    Public Const WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20    Public Const WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21    Public Const WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22    Public Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23    Public Const WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24    Public Const WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25    Public Const WM_CAP_EDIT_COPY = WM_CAP_START + 30    Public Const WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35    Public Const WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36    Public Const WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41    Public Const WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42    Public Const WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43    Public Const WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44    Public Const WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45    Public Const WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46    Public Const WM_CAP_GET_STATUS = WM_CAP_START + 54    Public Const WM_CAP_SET_SCROLL = WM_CAP_START + 55    Public Const WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61    Public Const WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64    Public Const WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65    Public Const WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66    Public Const WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67    Public Const WM_CAP_ABORT = WM_CAP_START + 69    Public Const WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70    Public Const WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71    Public Const WM_CAP_SINGLE_FRAME = WM_CAP_START + 72    Public Const WM_CAP_PAL_OPEN = WM_CAP_START + 80    Public Const WM_CAP_PAL_SAVE = WM_CAP_START + 81    Public Const WM_CAP_PAL_PASTE = WM_CAP_START + 82    Public Const WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83    Public Const WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84    '// Following added post VFW 1.1    Public Const WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85    '// Defines end of the message range    Public Const WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL    Private hWndC As IntPtr    Private bStat As Boolean = False    Private mControlPtr As IntPtr    Private mWidth As Integer    Private mHeight As Integer    Private mLeft As Integer    Private mTop As Integer    <DllImport("avicap32.dll")> _    Private Shared Function capCreateCaptureWindowA(ByVal lpszWindowName() As Byte, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hWndParent As IntPtr, ByVal nID As Integer) As IntPtr    End Function    <DllImport("avicap32.dll")> _    Private Shared Function capGetVideoFormat(ByVal hWnd As IntPtr, ByVal psVideoFormat As IntPtr, ByVal wSize As Integer) As Integer    End Function    <DllImport("User32.dll")> _    Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Boolean    End Function    Function capDlgVideoFormat() As Boolean        capDlgVideoFormat = SendMessage(hWndC, WM_CAP_DLG_VIDEOFORMAT, 0, 0)    End Function    Function capDlgVideoSource() As Boolean        capDlgVideoSource = SendMessage(hWndC, WM_CAP_DLG_VIDEOSOURCE, 0, 0)    End Function    Function capDlgVideoDisplay() As Boolean        capDlgVideoDisplay = SendMessage(hWndC, WM_CAP_DLG_VIDEODISPLAY, 0, 0)    End Function    Function capDlgVideoCompression() As Boolean        capDlgVideoCompression = SendMessage(hWndC, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)    End Function 


[解决办法]
接上面

VB.NET code
 
[code=VB.NET]Imports System
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class Cam

  Private Const WM_USER As Integer = &H400
  Private Const WS_CHILD As Integer = &H40000000
  Private Const WS_VISIBLE As Integer = &H10000000
  Private Const WM_CAP_START As Integer = WM_USER
  Private Const WM_CAP_STOP As Integer = WM_CAP_START + 68
  Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP_START + 10
  Private Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP_START + 11
  Private Const WM_CAP_SAVEDIB As Integer = WM_CAP_START + 25
  Private Const WM_CAP_GRAB_FRAME As Integer = WM_CAP_START + 60
  Private Const WM_CAP_SEQUENCE As Integer = WM_CAP_START + 62
  Private Const WM_CAP_FILE_SET_CAPTURE_FILEA As Integer = WM_CAP_START + 20
  Private Const WM_CAP_SEQUENCE_NOFILE As Integer = WM_CAP_START + 63
  Private Const WM_CAP_SET_OVERLAY As Integer = WM_CAP_START + 51
  Private Const WM_CAP_SET_PREVIEW As Integer = WM_CAP_START + 50
  Private Const WM_CAP_SET_CALLBACK_VIDEOSTREAM As Integer = WM_CAP_START + 6
  Private Const WM_CAP_SET_CALLBACK_ERROR As Integer = WM_CAP_START + 2
  Private Const WM_CAP_SET_CALLBACK_STATUSA As Integer = WM_CAP_START + 3
  Private Const WM_CAP_SET_CALLBACK_FRAME As Integer = WM_CAP_START + 5
  Private Const WM_CAP_SET_SCALE As Integer = WM_CAP_START + 53
  Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP_START + 52

  Public Const WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1

  Public Const WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3
  Public Const WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4
  Public Const WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7
  Public Const WM_CAP_GET_USER_DATA = WM_CAP_START + 8
  Public Const WM_CAP_SET_USER_DATA = WM_CAP_START + 9

  Public Const WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12
  Public Const WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13
  Public Const WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14

  Public Const WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20
  Public Const WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21
  Public Const WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22
  Public Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
  Public Const WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24
  Public Const WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25

  Public Const WM_CAP_EDIT_COPY = WM_CAP_START + 30

  Public Const WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35
  Public Const WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36

  Public Const WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41
  Public Const WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42
  Public Const WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43
  Public Const WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44
  Public Const WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45
  Public Const WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46

  Public Const WM_CAP_GET_STATUS = WM_CAP_START + 54
  Public Const WM_CAP_SET_SCROLL = WM_CAP_START + 55

  Public Const WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61

  Public Const WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64
  Public Const WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65
  Public Const WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66
  Public Const WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67


  Public Const WM_CAP_ABORT = WM_CAP_START + 69

  Public Const WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70
  Public Const WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71
  Public Const WM_CAP_SINGLE_FRAME = WM_CAP_START + 72

  Public Const WM_CAP_PAL_OPEN = WM_CAP_START + 80
  Public Const WM_CAP_PAL_SAVE = WM_CAP_START + 81
  Public Const WM_CAP_PAL_PASTE = WM_CAP_START + 82
  Public Const WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83
  Public Const WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84

  '// Following added post VFW 1.1
  Public Const WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85

  '// Defines end of the message range
  Public Const WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL

  Private hWndC As IntPtr
  Private bStat As Boolean = False

  Private mControlPtr As IntPtr
  Private mWidth As Integer
  Private mHeight As Integer
  Private mLeft As Integer
  Private mTop As Integer

  <DllImport("avicap32.dll")> _
  Private Shared Function capCreateCaptureWindowA(ByVal lpszWindowName() As Byte, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hWndParent As IntPtr, ByVal nID As Integer) As IntPtr
  End Function

  <DllImport("avicap32.dll")> _
  Private Shared Function capGetVideoFormat(ByVal hWnd As IntPtr, ByVal psVideoFormat As IntPtr, ByVal wSize As Integer) As Integer
  End Function

  <DllImport("User32.dll")> _
  Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Boolean
  End Function

  Function capDlgVideoFormat() As Boolean
    capDlgVideoFormat = SendMessage(hWndC, WM_CAP_DLG_VIDEOFORMAT, 0, 0)
  End Function

  Function capDlgVideoSource() As Boolean
    capDlgVideoSource = SendMessage(hWndC, WM_CAP_DLG_VIDEOSOURCE, 0, 0)
  End Function

  Function capDlgVideoDisplay() As Boolean
    capDlgVideoDisplay = SendMessage(hWndC, WM_CAP_DLG_VIDEODISPLAY, 0, 0)
  End Function

  Function capDlgVideoCompression() As Boolean
    capDlgVideoCompression = SendMessage(hWndC, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)
  End Function

 


[/code]
[解决办法]
上面的重複了,這個才是
VB.NET code
    '/// <summary>    '/// 初始化摄像头    '/// </summary>    '/// <param name="handle">控件的句柄</param>    '/// <param name="left">开始显示的左边距</param>    '/// <param name="top">开始显示的上边距</param>    '/// <param name="width">要显示的宽度</param>    '/// <param name="height">要显示的长度</param>    Public Sub New(ByVal handle As IntPtr, ByVal left As Integer, ByVal top As Integer, ByVal width As Integer, ByVal height As Integer)        mControlPtr = handle        mWidth = width        mHeight = height        mLeft = left        mTop = top    End Sub    '/// <summary>    '/// 开始显示图像    '/// </summary>    Public Sub Start()        If bStat Then            Return        End If        bStat = True        Dim lpszName(99) As Byte        hWndC = capCreateCaptureWindowA(lpszName, WS_CHILD Or WS_VISIBLE, mLeft, mTop, mWidth, mHeight, mControlPtr, 0)        If hWndC.ToInt32() <> 0 Then            SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0)            SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0)            SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0)            SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0)            SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0)            SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0)            SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0)            SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0)        End If        Return    End Sub    '/// <summary>    '/// 停止显示    '/// </summary>    Public Sub [Stop]()        SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0)        bStat = False    End Sub    '/// <summary>    '/// 抓图    '/// </summary>    '/// <param name="path">要保存bmp文件的路径</param>    Public Sub GrabImage(ByVal path As String)        Dim hBmp As IntPtr = Marshal.StringToHGlobalAnsi(path)        SendMessage(hWndC, WM_CAP_SAVEDIB, 0, hBmp.ToInt64())    End Sub    '/// <summary>    '/// 录像    '/// </summary>    '/// <param name="path">要保存avi文件的路径</param>    Public Sub Kinescope(ByVal path As String)        Dim hBmp As IntPtr = Marshal.StringToHGlobalAnsi(path)        SendMessage(hWndC, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, hBmp.ToInt64())        SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0)    End Sub    '/// <summary>    '/// 停止录像    '/// </summary>    Public Sub StopKinescope()        SendMessage(hWndC, WM_CAP_STOP, 0, 0)    End SubEnd Class 


[解决办法]
前几天刚写了一个.
网上搜搜源码很多.
楼主想要,邮箱短消息给我.
[解决办法]
Imports System
Imports System.Runtime.InteropServices
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class Cam

Private Const WM_USER As Integer = &H400
Private Const WS_CHILD As Integer = &H40000000
Private Const WS_VISIBLE As Integer = &H10000000
Private Const WM_CAP_START As Integer = WM_USER
Private Const WM_CAP_STOP As Integer = WM_CAP_START + 68
Private Const WM_CAP_DRIVER_CONNECT As Integer = WM_CAP_START + 10
Private Const WM_CAP_DRIVER_DISCONNECT As Integer = WM_CAP_START + 11
Private Const WM_CAP_SAVEDIB As Integer = WM_CAP_START + 25
Private Const WM_CAP_GRAB_FRAME As Integer = WM_CAP_START + 60
Private Const WM_CAP_SEQUENCE As Integer = WM_CAP_START + 62
Private Const WM_CAP_FILE_SET_CAPTURE_FILEA As Integer = WM_CAP_START + 20
Private Const WM_CAP_SEQUENCE_NOFILE As Integer = WM_CAP_START + 63
Private Const WM_CAP_SET_OVERLAY As Integer = WM_CAP_START + 51
Private Const WM_CAP_SET_PREVIEW As Integer = WM_CAP_START + 50
Private Const WM_CAP_SET_CALLBACK_VIDEOSTREAM As Integer = WM_CAP_START + 6
Private Const WM_CAP_SET_CALLBACK_ERROR As Integer = WM_CAP_START + 2
Private Const WM_CAP_SET_CALLBACK_STATUSA As Integer = WM_CAP_START + 3
Private Const WM_CAP_SET_CALLBACK_FRAME As Integer = WM_CAP_START + 5
Private Const WM_CAP_SET_SCALE As Integer = WM_CAP_START + 53
Private Const WM_CAP_SET_PREVIEWRATE As Integer = WM_CAP_START + 52

Public Const WM_CAP_GET_CAPSTREAMPTR = WM_CAP_START + 1

Public Const WM_CAP_SET_CALLBACK_STATUS = WM_CAP_START + 3
Public Const WM_CAP_SET_CALLBACK_YIELD = WM_CAP_START + 4
Public Const WM_CAP_SET_CALLBACK_WAVESTREAM = WM_CAP_START + 7
Public Const WM_CAP_GET_USER_DATA = WM_CAP_START + 8
Public Const WM_CAP_SET_USER_DATA = WM_CAP_START + 9

Public Const WM_CAP_DRIVER_GET_NAME = WM_CAP_START + 12
Public Const WM_CAP_DRIVER_GET_VERSION = WM_CAP_START + 13
Public Const WM_CAP_DRIVER_GET_CAPS = WM_CAP_START + 14

Public Const WM_CAP_FILE_SET_CAPTURE_FILE = WM_CAP_START + 20
Public Const WM_CAP_FILE_GET_CAPTURE_FILE = WM_CAP_START + 21
Public Const WM_CAP_FILE_ALLOCATE = WM_CAP_START + 22
Public Const WM_CAP_FILE_SAVEAS = WM_CAP_START + 23
Public Const WM_CAP_FILE_SET_INFOCHUNK = WM_CAP_START + 24
Public Const WM_CAP_FILE_SAVEDIB = WM_CAP_START + 25

Public Const WM_CAP_EDIT_COPY = WM_CAP_START + 30

Public Const WM_CAP_SET_AUDIOFORMAT = WM_CAP_START + 35
Public Const WM_CAP_GET_AUDIOFORMAT = WM_CAP_START + 36

Public Const WM_CAP_DLG_VIDEOFORMAT = WM_CAP_START + 41
Public Const WM_CAP_DLG_VIDEOSOURCE = WM_CAP_START + 42
Public Const WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43
Public Const WM_CAP_GET_VIDEOFORMAT = WM_CAP_START + 44
Public Const WM_CAP_SET_VIDEOFORMAT = WM_CAP_START + 45
Public Const WM_CAP_DLG_VIDEOCOMPRESSION = WM_CAP_START + 46

Public Const WM_CAP_GET_STATUS = WM_CAP_START + 54
Public Const WM_CAP_SET_SCROLL = WM_CAP_START + 55

Public Const WM_CAP_GRAB_FRAME_NOSTOP = WM_CAP_START + 61

Public Const WM_CAP_SET_SEQUENCE_SETUP = WM_CAP_START + 64
Public Const WM_CAP_GET_SEQUENCE_SETUP = WM_CAP_START + 65
Public Const WM_CAP_SET_MCI_DEVICE = WM_CAP_START + 66
Public Const WM_CAP_GET_MCI_DEVICE = WM_CAP_START + 67
Public Const WM_CAP_ABORT = WM_CAP_START + 69

Public Const WM_CAP_SINGLE_FRAME_OPEN = WM_CAP_START + 70
Public Const WM_CAP_SINGLE_FRAME_CLOSE = WM_CAP_START + 71
Public Const WM_CAP_SINGLE_FRAME = WM_CAP_START + 72



Public Const WM_CAP_PAL_OPEN = WM_CAP_START + 80
Public Const WM_CAP_PAL_SAVE = WM_CAP_START + 81
Public Const WM_CAP_PAL_PASTE = WM_CAP_START + 82
Public Const WM_CAP_PAL_AUTOCREATE = WM_CAP_START + 83
Public Const WM_CAP_PAL_MANUALCREATE = WM_CAP_START + 84

'// Following added post VFW 1.1
Public Const WM_CAP_SET_CALLBACK_CAPCONTROL = WM_CAP_START + 85

'// Defines end of the message range
Public Const WM_CAP_END = WM_CAP_SET_CALLBACK_CAPCONTROL

Private hWndC As IntPtr
Private bStat As Boolean = False

Private mControlPtr As IntPtr
Private mWidth As Integer
Private mHeight As Integer
Private mLeft As Integer
Private mTop As Integer

<DllImport("avicap32.dll")> _
Private Shared Function capCreateCaptureWindowA(ByVal lpszWindowName() As Byte, ByVal dwStyle As Integer, ByVal x As Integer, ByVal y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hWndParent As IntPtr, ByVal nID As Integer) As IntPtr
End Function

<DllImport("avicap32.dll")> _
Private Shared Function capGetVideoFormat(ByVal hWnd As IntPtr, ByVal psVideoFormat As IntPtr, ByVal wSize As Integer) As Integer
End Function

<DllImport("User32.dll")> _
Private Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Long) As Boolean
End Function

Function capDlgVideoFormat() As Boolean
capDlgVideoFormat = SendMessage(hWndC, WM_CAP_DLG_VIDEOFORMAT, 0, 0)
End Function

Function capDlgVideoSource() As Boolean
capDlgVideoSource = SendMessage(hWndC, WM_CAP_DLG_VIDEOSOURCE, 0, 0)
End Function

Function capDlgVideoDisplay() As Boolean
capDlgVideoDisplay = SendMessage(hWndC, WM_CAP_DLG_VIDEODISPLAY, 0, 0)
End Function

Function capDlgVideoCompression() As Boolean
capDlgVideoCompression = SendMessage(hWndC, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0)
End Function

热点排行