www.pudn.com > sdk3000demo.rar > ModuleGlobal.bas, change:2005-03-22,size:5618b


Attribute VB_Name = "moduleGlobal" 
Option Explicit 
 
'连接用到的全局变量 
Public g_bConnected As Boolean 
Public g_nCapWidth As Long 
Public g_nCapHeight As Long 
Public g_nPlayState As Long '0:未连接 1:播放 2:暂停 3:停止 
 
'动态检测用到的全局变量 
Public g_bInput As Boolean 
Public g_bMove As Boolean 
 
'循环抓拍用到的全局变量 
Public g_nCycNum As Long    '每几帧抓一帧 
Public g_strCircularSnapDir As String 
Public g_bCircularSource(5) As Boolean 
Public g_bCircularSnapBmp As Boolean 
Public g_nPersist As Long 
Public g_nCapSourceCount As Long '要抓照的通道数量,若为1则连续拍. 
Public g_bContinuous As Boolean '是否在连续拍 
 
Public g_nSource As Long    '当前要抓的通道,从0开始 
Public g_nPic As Long   '用于跳过不想抓的帧,只要开始赋初值0就行了,以后自动赋值 
Public g_nCircularPicCount As Long '当前抓的是第几张图,从1开始,每次抓前赋初值. 
 
'捕获参数设置用到的全局变量 
Public g_strVideoPath As String 
Public g_strPicturePath As String 
Public g_bBmp As Boolean 
Public g_nCurComp As Long 
Public g_bRecAudio As Boolean 
 
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long 
Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) 
Public Declare Function SetTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long, ByVal uElapse As Long, ByVal lpTimerFunc As Long) As Long 
Public Declare Function KillTimer Lib "user32" (ByVal hwnd As Long, ByVal nIDEvent As Long) As Long 
Public Declare Function XD_ShowVCMDialog Lib "TXvidDll" (ByVal hwnd As Long) As Long 
 
Public Type BrowseInfo 
     hwndOwner As Long 
     pIDLRoot As Long 
     pszDisplayName As Long 
     lpszTitle As Long 
     ulFlags As Long 
     lpfnCallback As Long 
     lParam As Long 
     iImage As Long 
End Type 
 
Public Const BIF_RETURNONLYFSDIRS = 1 
Public Const MAX_PATH = 260 
 
Public Declare Sub CoTaskMemFree Lib "ole32.dll" (ByVal hMem As Long) 
Public Declare Function lstrcat Lib "kernel32" Alias "lstrcatA" (ByVal lpString1 As String, ByVal lpString2 As String) As Long 
Public Declare Function SHBrowseForFolder Lib "shell32" (lpbi As BrowseInfo) As Long 
Public Declare Function SHGetPathFromIDList Lib "shell32" (ByVal pidList As Long, ByVal lpBuffer As String) As Long 
 
 
Public Function BrowseForFolder(hwndOwner As Long, sPrompt As String) As String 
      
    '定义变量 
     Dim iNull As Integer 
     Dim lpIDList As Long 
     Dim lResult As Long 
     Dim sPath As String 
     Dim udtBI As BrowseInfo 
 
    '初始化..... 
     With udtBI 
        .hwndOwner = hwndOwner 
        .lpszTitle = lstrcat(sPrompt, "") 
        .ulFlags = BIF_RETURNONLYFSDIRS 
     End With 
 
    '调用API 
     lpIDList = SHBrowseForFolder(udtBI) 
    '得到返回结果 
    If lpIDList Then 
        sPath = String$(MAX_PATH, 0) 
        lResult = SHGetPathFromIDList(lpIDList, sPath) 
        Call CoTaskMemFree(lpIDList) 
        iNull = InStr(sPath, vbNullChar) 
        If iNull Then sPath = Left$(sPath, iNull - 1) 
     End If 
     BrowseForFolder = sPath 
 
End Function 
 
 
 
 
Public Sub MyPrcIoAlertCallBack(ByVal lnCardID As Long) 
 
    If g_bInput = False Then 
        g_bInput = True 
        MsgBox ("IO input") 
    End If 
     
End Sub 
 
Public Sub MyPrcCbMotionDetect(ByVal lnCardID As Long, ByVal bMove As Long, ByVal Reserved As Long) 
 
    If Not g_bMove Then 
        g_bMove = True 
         
        MsgBox ("动态检测成功,抓拍到: " + g_strPicturePath + "motion.bmp") 
        Call formMain.SDK30001.SaveImageToBmp(g_strPicturePath + "motion.bmp", 1, False) 
         
    End If 
     
End Sub 
 
 
Public Sub MyPrcPic(ByVal lnCardID As Long, ByVal pBuf As Long, ByVal lnWidth As Long, ByVal lnHeight As Long, ByVal lnBiCount As Long) 
 
    If g_bContinuous Then 
        Exit Sub 
    End If 
 
    If g_nCapSourceCount = 1 And g_nCycNum = 1 Then 
        g_bContinuous = True 
     
        Dim strFile As String 
        If g_bCircularSnapBmp Then 
            strFile = g_strCircularSnapDir + "Video" + CStr(g_nSource + 1) + "_Bmp" 
            Call formMain.SDK30001.SaveImageToBmp(strFile, g_nPersist * 25, False) 
        Else 
            strFile = g_strCircularSnapDir + "Video" + CStr(g_nSource + 1) + "_Jpg" 
            Call formMain.SDK30001.SaveImageToJpg(strFile, 100, g_nPersist * 25, False) 
        End If 
     
        Exit Sub 
    End If 
 
    g_nPic = (g_nPic + 1) Mod g_nCycNum 
    If g_nPic <> 0 Then 
        Exit Sub 
    End If 
     
    If g_bCircularSnapBmp Then 
        strFile = g_strCircularSnapDir + "Video" + CStr(g_nSource + 1) + "_Bmp" + CStr(g_nCircularPicCount) + ".bmp" 
        Call formMain.SDK30001.SaveImageToBmp(strFile, 1, False) 
    Else 
        strFile = g_strCircularSnapDir + "Video" + CStr(g_nSource + 1) + "_Jpg" + CStr(g_nCircularPicCount) + ".jpeg" 
        Call formMain.SDK30001.SaveImageToJpg(strFile, 100, 1, False) 
    End If 
     
    g_nCircularPicCount = g_nCircularPicCount + 1 
     
    Dim vs As Long 
    Dim i As Long 
    For i = (g_nSource + 1) To 10 
        vs = (i Mod 5) 
        If g_bCircularSource(vs) Then 
            formMain.SDK30001.VideoSource = vs 
            g_nSource = vs 
            Exit For 
        End If 
    Next i 
 
End Sub 
 
Public Sub formCapPic_OnTimer(ByVal hwnd As Long, ByVal uMsg As Long, ByVal idEvent As Long, ByVal dwTime As Long) 
 
    Call KillTimer(formCapPic.hwnd, 1) 
    Call formMain.SDK30001.DisableCapSourceStream 
    formMain.SDK30001.VideoSource = formCapPic.m_nCurVideo 
    Call MsgBox("循环抓拍完成!") 
     
End Sub