|
|
|
在ifix上实现视频监控录制 |
|
|
这其中用到了相关控件是从网上下载,附件里有。如有问题请联系qq:407622496
相关的代码:
Private Sub cmdCapture_Click()
Call ezVidCap1.CaptureVideo
End Sub
Private Sub cmdSaveDIB_Click() '保存位图
Dim filename As String
hwnd = FindWindow(vbNullString, "")
If VBGetSaveFileName(filename, filter:="Bitmap文件 (*.bmp)|*.bmp", InitDir:=Application.Path, DlgTitle:="保存为图片", DefaultExt:="bmp", Owner:=hwnd) Then
On Error Resume Next
Call ezVidCap1.SaveDIB(filename)
If Err Then
MsgBox Err.Description, vbInformation, Application.Title
' Err.Description为错误信息; vbInformation 显示“通知消息”图标;Application.Title为标题栏名字
End If
End If
End Sub
Private Sub Command2_Click() '保存视频
Dim filename As String
hwnd = FindWindow(vbNullString, "")
If VBGetSaveFileNamePreview(filename, FileMustExist:=False, filter:="AVI文件 (*.avi)|*.avi", InitDir:=Application.Path, DlgTitle:="保存视频文件", DefaultExt:="avi", Owner:=hwnd) Then
On Error Resume Next
Call ezVidCap1.SaveAs(filename)
If Err Then ' Err.Description为错误信息; vbInformation 显示“通知消息”图标;Application.Title为标题栏名字
MsgBox Err.Description, vbInformation, Application.Title
End If
End If
End Sub
Private Function FilterLookup(ByVal sFilters As String) As String
Dim iStart As Long, iEnd As Long, s As String
iStart = 1
If sFilters = vbNullChar Then Exit Function
iEnd = InStr(iStart, sFilters, vbNullChar)
If iEnd = 0 Then Exit Function
iEnd = InStr(iEnd + 1, sFilters, vbNullChar)
If iEnd Then
s = Mid$(sFilters, iStart, iEnd - iStart)
Else
s = Mid$(sFilters, iStart)
End If
FilterLookup = s
End Function
Public Function VBGetSaveFileName(filename As String, Optional FileTitle As String, Optional OverWritePrompt As Boolean = True, Optional filter As String = "All (*.*)| *.*", Optional FilterIndex As Long = 1, Optional InitDir As String = "", Optional DlgTitle As String = "", Optional DefaultExt As String = "", Optional Owner As Long = -1, Optional Flags As Long) As Boolean
Dim opfile As OPENFILENAME, s As String
With opfile
.lStructSize = Len(opfile)
.Flags = (-OverWritePrompt * OFN_OVERWRITEPROMPT) Or OFN_HIDEREADONLY
If Owner <> -1 Then
.hwndOwner = Owner
.lpstrInitialDir = InitDir
.lpstrDefExt = DefaultExt
.lpstrTitle = DlgTitle
End If
Dim ch As String, I As Integer
For I = 1 To Len(filter)
ch = Mid$(filter, I, 1)
If ch = "|" Or ch = ":" Then
s = s & vbNullChar
Else
s = s & ch
End If
Next
s = s & vbNullChar & vbNullChar
.lpstrFilter = s
s = filename & String$(MAX_PATH - Len(filename), 0)
.lpstrFile = s
.nMaxFile = MAX_PATH
s = FileTitle & String$(MAX_FILE - Len(FileTitle), 0)
.lpstrFileTitle = s
.nMaxFileTitle = MAX_FILE
If GetSaveFileName(opfile) Then
VBGetSaveFileName = True
filename = Left$(.lpstrFile, InStr(.lpstrFile, vbNullChar) - 1)
FileTitle = Left$(.lpstrFileTitle, InStr(.lpstrFileTitle, vbNullChar) - 1)
Flags = .Flags
filter = FilterLookup(.lpstrFilter)
Else
VBGetSaveFileName = False
filename = vbNullChar
FileTitle = vbNullChar
Flags = 0
FilterIndex = 0
filter = vbNullChar
End If
End With
End Function
Public Function VBGetSaveFileNamePreview(filename As String, Optional FileTitle As String = "", Optional FileMustExist As Boolean = True, Optional MultiSelect As Boolean = False, Optional ReadOnly As Boolean = False, Optional HideReadOnly As Boolean = False, Optional filter As String = "All (*.*)| *.*", Optional FilterIndex As Long = 1, Optional InitDir As String = "", Optional DlgTitle As String = "", Optional DefaultExt As String = "", Optional Owner As Long = -1, Optional Flags As Long = 0) As Boolean
Dim opfile As OPENFILENAME, s As String, afFlags As Long
With opfile
.lStructSize = Len(opfile) '获取结构长度
.Flags = (-FileMustExist * OFN_FILEMUSTEXIST) Or (-MultiSelect * OFN_ALLOWMULTISELECT) Or (-ReadOnly * OFN_READONLY) Or (-HideReadOnly * OFN_HIDEREADONLY)
'文件夹必须存在 允许多选 只读 隐藏只读复选框
If Owner <> -1 Then
.hwndOwner = Owner
.lpstrInitialDir = InitDir
.lpstrDefExt = DefaultExt
.lpstrTitle = DlgTitle
End If
Dim ch As String, I As Integer
For I = 1 To Len(filter)
ch = Mid$(filter, I, 1)
If ch = "|" Or ch = ":" Then
s = s & vbNullChar
Else
s = s & ch
End If
Next
s = s & vbNullChar & vbNullChar
.lpstrFilter = s
s = filename & String$(MAX_PATH - Len(filename), 0)
.lpstrFile = s
.nMaxFile = MAX_PATH
s = FileTitle & String$(MAX_FILE - Len(FileTitle), 0)
.lpstrFileTitle = s
.nMaxFileTitle = MAX_FILE
If GetSaveFileNamePreview(opfile) Then
VBGetSaveFileNamePreview = True
filename = Left$(.lpstrFile, InStr(.lpstrFile, vbNullChar) - 1)
FileTitle = Left$(.lpstrFileTitle, InStr(.lpstrFileTitle, vbNullChar) - 1)
Flags = .Flags
filter = FilterLookup(.lpstrFilter)
If (.Flags And OFN_READONLY) Then ReadOnly = True
Else
VBGetSaveFileNamePreview = False
filename = vbNullChar
FileTitle = vbNullChar
Flags = 0
FilterIndex = -1
filter = vbNullChar
End If
End With
End Function |
|
|
|
相关技术论文: |
|
|