⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 call.bas

📁 三汇CTI示例程序源码
💻 BAS
📖 第 1 页 / 共 2 页
字号:
Attribute VB_Name = "Call"
Option Explicit
'Event struct
 Type EVENT_SET_INFO
    dwWorkMode As Long
    lpHandlerParam As Long
    dwOutCondition As Long
    dwOutParamVal As Long
    dwUser As Long
End Type

Public Declare Function SsmSetEvent Lib "SHP_A3.dll" (ByVal wEvent As Integer, _
                                                                                              ByVal nReference As Integer, _
                                                                                              ByVal bEnable As Boolean, _
                                                                                              ByVal pEventSet As Long) As Integer
                                                                                              
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" _
                                            (ByVal lpPrevWndFunc As Long, _
                                            ByVal hwnd As Long, ByVal Msg As Long, _
                                            ByVal wParam As Long, ByVal lParam As Long) As Long
        
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" _
                                            (ByVal hwnd As Long, _
                                            ByVal nIndex As Long, _
                                            ByVal dwNewLong As Long) As Long
                                            
Public Const GWL_WNDPROC = -4

Public Type CH_INFO
    nEnCalled As Integer         'whether enable call in or not
    nStep As Integer             'Channel state
    szCallerId As String * 20    'Calling party number
    szDtmf  As String            'Received DTMF
    nTimer As Integer            'Timer
End Type

    Const TRK_IDLE = 0                      'Idle state
    Const TRK_WAIT_CONNECT = 1              'Waiting for connect
    Const TRK_CHECK_PLAY_WELCOME = 2        'Play "Welcome"
    Const TRK_CHECK_PLAY_SELECT = 3         'Selecting……
    Const TRK_CHECK_REC_START = 4           'Start recording
    Const TRK_CHECK_REC_END = 5             'Recording……
    Const TRK_CHECK_PLAY_RECORD = 6         'Play record
    Const TRK_CHECK_PLAY_BYEBYE = 7         'Byebye
                                                                                                                                                        
    Public ChInfo(0 To 1000) As CH_INFO
    Public nMaxCh As Integer                'Maximum number of the channels
    Public lpPrevWndProc As Long
    Public gHW As Long
    Const WM_USER = &H400
    Const E_CHG_RcvDTMF = &HC
    Const E_CHG_ChState = &H18
    Const E_SYS_TIMEOUT = &H30
    Const E_PROC_PlayEnd = &HF
    Const E_PROC_RecordEnd = &H13
    'Initialize board
    Function InitCtiBoard() As Boolean
    Dim ErrMsg As String * 260
    Dim szConfig As String * 260
    Dim szIndex As String * 260
    Dim i As Integer
    Dim nDirection As Long
    
    szConfig = App.Path + "\ShConfig.ini" + Chr(0)
    szIndex = App.Path + "\ShIndex.ini" + Chr(0)
    'Load configuration file and initialize system
    If (SsmStartCti(szConfig, szIndex) <> 0) Then
        SsmGetLastErrMsg (ErrMsg)       'Get error message
        MsgBox (ErrMsg)
        InitCtiBoard = False
    Else
        
    'Judge if the number of initialized boards is the same as
    '         that of boards specified in the configuration file
        If (SsmGetMaxUsableBoard() <> SsmGetMaxCfgBoard()) Then
            SsmGetLastErrMsg (ErrMsg)       ' Get error message
            MsgBox (ErrMsg)
            InitCtiBoard = False
        Else
            'Get the maximum number of the monitored circuits
            nMaxCh = SsmGetMaxCh()
            If (nMaxCh = -1) Then
                MsgBox ("Fail to call SsmGetMaxCh")
            End If
    
            For i = 0 To nMaxCh - 1
                ChInfo(i).nEnCalled = False
                If SsmGetAutoCallDirection(i, nDirection) = 1 Then 'Enable automatic call progress
                    If (nDirection = 0 Or nDirection = 2) Then   'enable call in
                          ChInfo(i).nStep = TRK_IDLE
                          ChInfo(i).nEnCalled = True
                          ChInfo(i).nTimer = -1
                          ChInfo(i).szCallerId = ""
                    End If
                End If
                
            Next i
            
            InitCtiBoard = True
        End If
    End If
    End Function
    Public Sub InitCircuitListCtrl()
    Dim i%
    MainForm.ChGrid.Cols = 4
    MainForm.ChGrid.Row = 0
    
    MainForm.ChGrid.Col = 0
    MainForm.ChGrid.Text = "Ch"
    
    MainForm.ChGrid.Col = 1
    MainForm.ChGrid.Text = "ChState"
    
    MainForm.ChGrid.Col = 2
    MainForm.ChGrid.Text = "CallerId"
    
    MainForm.ChGrid.Col = 3
    MainForm.ChGrid.Text = "DTMF"
           
    MainForm.ChGrid.ColWidth(0) = 40 * 12
    MainForm.ChGrid.ColWidth(1) = 178 * 12
    MainForm.ChGrid.ColWidth(2) = 100 * 12
    MainForm.ChGrid.ColWidth(3) = 150 * 12
     
    MainForm.ChGrid.Rows = 1
    For i = 0 To nMaxCh - 1
        If ChInfo(i).nEnCalled Then MainForm.ChGrid.AddItem (Str(i))
    Next i

    End Sub
    Public Sub UpdateCircuitListCtrl()
        Dim szNewStat As String * 100
        Dim szOldStat As String * 100
        Dim i As Integer
        Dim nIndex%
        
        nIndex = 0
        
        For i = 0 To nMaxCh - 1
            If ChInfo(i).nEnCalled Then
            Select Case (ChInfo(i).nStep)
                Case TRK_IDLE
                    szNewStat = "Idle"
                Case TRK_WAIT_CONNECT
                    szNewStat = "Connecting…"
                Case TRK_CHECK_PLAY_WELCOME
                    szNewStat = "Playing welcome"
                Case TRK_CHECK_PLAY_SELECT
                    szNewStat = "Waiting for select"
                Case TRK_CHECK_REC_START
                    szNewStat = "Waiting for starting"
                Case TRK_CHECK_REC_END
                    szNewStat = "Recording"
                Case TRK_CHECK_PLAY_RECORD
                    szNewStat = "Playing record"
                Case TRK_CHECK_PLAY_BYEBYE
                    szNewStat = "Playing Byebye"
                    
            End Select
            
            szOldStat = MainForm.ChGrid.TextMatrix(nIndex + 1, 1)
            If (szOldStat <> szNewStat) Then
                MainForm.ChGrid.TextMatrix(nIndex + 1, 1) = szNewStat
            End If
            
            szOldStat = MainForm.ChGrid.TextMatrix(nIndex + 1, 2)
            If (szOldStat <> ChInfo(i).szCallerId) Then
                MainForm.ChGrid.TextMatrix(nIndex + 1, 2) = ChInfo(i).szCallerId
            End If
                        
            szOldStat = MainForm.ChGrid.TextMatrix(nIndex + 1, 3)
            If (szOldStat <> ChInfo(i).szDtmf) Then
                MainForm.ChGrid.TextMatrix(nIndex + 1, 3) = ChInfo(i).szDtmf
            End If
            
            nIndex = nIndex + 1
            End If
        Next i
    End Sub
    
    Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, _
                                           ByVal wParam As Long, ByVal lParam As Long) As Long
    Dim nCh As Integer
    Dim i%
    Dim nEventCode, nNewState As Integer
    Dim cNewDtmf As String
    
    'Adopt windows message mechanism
    'windows message code:event code + &H400(WM_USER)
    If (uMsg > WM_USER) Then
        nEventCode = uMsg - WM_USER
        Select Case nEventCode
        Case E_CHG_ChState
            nCh = wParam
            nNewState = CInt(lParam And &HFFFF&)    'New state
            Select Case nNewState
            Case S_CALL_RINGING
                If ChInfo(nCh).nStep = TRK_IDLE Then
                    If SsmPickup(nCh) = -1 Then
                        MsgBox ("Fail to call SsmPickup")
                    End If
                    If SsmClearRxDtmfBuf(nCh) = -1 Then     'Clear received DTMF buffer
                        MsgBox ("Fail to call SsmClearRxDtmfBuf")
                    End If
                    ChInfo(nCh).szDtmf = ""
                    ChInfo(nCh).nStep = TRK_WAIT_CONNECT
                End If
            
            Case S_CALL_TALKING
                If ChInfo(nCh).nStep = TRK_WAIT_CONNECT Then
                    SsmClearFileList (nCh)
                    ChInfo(nCh).szCallerId = ""
                    If SsmGetCallerId(nCh, ChInfo(nCh).szCallerId) = -1 Then

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -