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

📄 form1.vb

📁 三汇CTI示例程序源码
💻 VB
📖 第 1 页 / 共 2 页
字号:
Public Enum EnumRecDir

    CALL_IN_RECORD  'Incoming call recording
    CALL_OUT_RECORD 'Outgoing call recording
    MIX_RECORD      'Mix-record of incoming/outgoing call 
End Enum

'User-defined circuit status
Public Enum EnumCicState

    CIRCUIT_IDLE        'Idle state
    CIRCUIT_RCV_PHONUM  'State of receiving phone number
    CIRCUIT_RINGING     'State of ringing
    CIRCUIT_TALKING     'State of talking
End Enum

Public Structure CIC_STRUCT

    Public nCicState As Int32                       'State of monitored circuits
    Public szCallerId As System.Text.StringBuilder  'Calling party number
    Public szCalleeId As System.Text.StringBuilder  'Called party number
    Public szCallInDtmf As String                   'DTMF received on the incoming channel
    Public szCallOutDtmf As String                  'DTMF received on the outgoing channel
    Public wRecDirection As Int16                   'Recording direction
    Public nCallInCh As Int32                       'Incoming channel
    Public nCallOutCh As Int32                      'Outgoing channel
    Public nCallInIndex As Int32                    'Used to denote which number is the DTMF received on the incoming channel
    Public nCallOutIndex As Int32                   'Used to denote which number is the DTMF received on the outgoing channel
End Structure

Public Structure EVENT_SET_INFO
    Public dwWorkMode As Int32
    Public lpHandlerParam As IntPtr
    Public dwOutCondition As Int32
    Public dwOutParamVal As Int32
    Public dwUser As Int32
End Structure

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写 dispose 以清理组件列表。
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Windows 窗体设计器所必需的
    Private components As System.ComponentModel.IContainer

    '注意: 以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器修改此过程。
    '不要使用代码编辑器修改它。
    Friend WithEvents m_CicList As AxMSFlexGridLib.AxMSFlexGrid
    Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
    Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
    Friend WithEvents m_bCallFnMode_Cic As System.Windows.Forms.RadioButton
    Friend WithEvents m_bCallFnMode_Ch As System.Windows.Forms.RadioButton
    Friend WithEvents m_bRecFormat_In As System.Windows.Forms.RadioButton
    Friend WithEvents m_bRecFormat_Out As System.Windows.Forms.RadioButton
    Friend WithEvents m_cmbCic As System.Windows.Forms.ComboBox
    Friend WithEvents m_bRecFormat_Mix As System.Windows.Forms.RadioButton
    Friend WithEvents Label1 As System.Windows.Forms.Label
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.m_CicList = New AxMSFlexGridLib.AxMSFlexGrid
        Me.GroupBox1 = New System.Windows.Forms.GroupBox
        Me.m_bCallFnMode_Ch = New System.Windows.Forms.RadioButton
        Me.m_bCallFnMode_Cic = New System.Windows.Forms.RadioButton
        Me.GroupBox2 = New System.Windows.Forms.GroupBox
        Me.Label1 = New System.Windows.Forms.Label
        Me.m_bRecFormat_Mix = New System.Windows.Forms.RadioButton
        Me.m_cmbCic = New System.Windows.Forms.ComboBox
        Me.m_bRecFormat_Out = New System.Windows.Forms.RadioButton
        Me.m_bRecFormat_In = New System.Windows.Forms.RadioButton
        CType(Me.m_CicList, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.GroupBox1.SuspendLayout()
        Me.GroupBox2.SuspendLayout()
        Me.SuspendLayout()
        '
        'm_CicList
        '
        Me.m_CicList.Location = New System.Drawing.Point(16, 24)
        Me.m_CicList.Name = "m_CicList"
        Me.m_CicList.OcxState = CType(resources.GetObject("m_CicList.OcxState"), System.Windows.Forms.AxHost.State)
        Me.m_CicList.Size = New System.Drawing.Size(664, 160)
        Me.m_CicList.TabIndex = 0
        '
        'GroupBox1
        '
        Me.GroupBox1.Controls.Add(Me.m_bCallFnMode_Ch)
        Me.GroupBox1.Controls.Add(Me.m_bCallFnMode_Cic)
        Me.GroupBox1.Location = New System.Drawing.Point(32, 208)
        Me.GroupBox1.Name = "GroupBox1"
        Me.GroupBox1.Size = New System.Drawing.Size(256, 152)
        Me.GroupBox1.TabIndex = 1
        Me.GroupBox1.TabStop = False
        Me.GroupBox1.Text = "Function For Recording Mode"
        '
        'm_bCallFnMode_Ch
        '
        Me.m_bCallFnMode_Ch.Location = New System.Drawing.Point(24, 88)
        Me.m_bCallFnMode_Ch.Name = "m_bCallFnMode_Ch"
        Me.m_bCallFnMode_Ch.Size = New System.Drawing.Size(192, 32)
        Me.m_bCallFnMode_Ch.TabIndex = 1
        Me.m_bCallFnMode_Ch.Text = "Call the function with channel number as its parameter"
        '
        'm_bCallFnMode_Cic
        '
        Me.m_bCallFnMode_Cic.Location = New System.Drawing.Point(24, 32)
        Me.m_bCallFnMode_Cic.Name = "m_bCallFnMode_Cic"
        Me.m_bCallFnMode_Cic.Size = New System.Drawing.Size(192, 32)
        Me.m_bCallFnMode_Cic.TabIndex = 0
        Me.m_bCallFnMode_Cic.Text = "Call the function with circuit number as its parameter"
        '
        'GroupBox2
        '
        Me.GroupBox2.Controls.Add(Me.Label1)
        Me.GroupBox2.Controls.Add(Me.m_bRecFormat_Mix)
        Me.GroupBox2.Controls.Add(Me.m_cmbCic)
        Me.GroupBox2.Controls.Add(Me.m_bRecFormat_Out)
        Me.GroupBox2.Controls.Add(Me.m_bRecFormat_In)
        Me.GroupBox2.Location = New System.Drawing.Point(304, 208)
        Me.GroupBox2.Name = "GroupBox2"
        Me.GroupBox2.Size = New System.Drawing.Size(360, 152)
        Me.GroupBox2.TabIndex = 2
        Me.GroupBox2.TabStop = False
        Me.GroupBox2.Text = "Record Mode Setting"
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(16, 64)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(24, 16)
        Me.Label1.TabIndex = 4
        Me.Label1.Text = "CIC"
        '
        'm_bRecFormat_Mix
        '
        Me.m_bRecFormat_Mix.Location = New System.Drawing.Point(136, 96)
        Me.m_bRecFormat_Mix.Name = "m_bRecFormat_Mix"
        Me.m_bRecFormat_Mix.Size = New System.Drawing.Size(208, 32)
        Me.m_bRecFormat_Mix.TabIndex = 3
        Me.m_bRecFormat_Mix.Text = "Mix the recording of incoming and outgoing channels"
        '
        'm_cmbCic
        '
        Me.m_cmbCic.Location = New System.Drawing.Point(48, 64)
        Me.m_cmbCic.Name = "m_cmbCic"
        Me.m_cmbCic.Size = New System.Drawing.Size(64, 20)
        Me.m_cmbCic.TabIndex = 2
        '
        'm_bRecFormat_Out
        '
        Me.m_bRecFormat_Out.Location = New System.Drawing.Point(136, 64)
        Me.m_bRecFormat_Out.Name = "m_bRecFormat_Out"
        Me.m_bRecFormat_Out.Size = New System.Drawing.Size(208, 24)
        Me.m_bRecFormat_Out.TabIndex = 1
        Me.m_bRecFormat_Out.Text = "Record only outgoing channels"
        '
        'm_bRecFormat_In
        '
        Me.m_bRecFormat_In.Location = New System.Drawing.Point(136, 32)
        Me.m_bRecFormat_In.Name = "m_bRecFormat_In"
        Me.m_bRecFormat_In.Size = New System.Drawing.Size(208, 24)
        Me.m_bRecFormat_In.TabIndex = 0
        Me.m_bRecFormat_In.Text = "Record only incoming channels"
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(696, 386)
        Me.Controls.Add(Me.GroupBox2)
        Me.Controls.Add(Me.GroupBox1)
        Me.Controls.Add(Me.m_CicList)
        Me.Name = "Form1"
        Me.Text = "Recorder_DTP"
        CType(Me.m_CicList, System.ComponentModel.ISupportInitialize).EndInit()
        Me.GroupBox1.ResumeLayout(False)
        Me.GroupBox2.ResumeLayout(False)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Dim CicState(1000) As CIC_STRUCT
    Dim nMaxCic As Int32
    Public Const WM_USER As Int32 = &H400
    Dim m_nCallFnMode As Int32

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        If (InitCtiBoard() = False) Then
            Dispose(True)
        End If
        'Set event-driven mode
        Dim EventSet As EVENT_SET_INFO
        EventSet.dwWorkMode = ShMsg.EVENT_MESSAGE
        EventSet.lpHandlerParam = Me.Handle
        If (SsmSetEvent(-1, -1, True, EventSet) = -1) Then
            MessageBox.Show("Fail to call SsmSetEvent")
        End If

        If (SsmSetEvent(ShEvent.E_CHG_SpyState, -1, True, EventSet) = -1) Then
            MessageBox.Show("Fail to call SsmSetEvent when setting E_CHG_SpyState")
        End If

        m_bCallFnMode_Cic.Checked = True
        m_bRecFormat_Mix.Checked = True

        InitCircuitListCtrl()  'initialize list
        UpdateCircuitListCtrl() 'update list	

    End Sub

    Private Sub Form1_Closed(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Closed
        SsmCloseCti()

    End Sub
    'Initialize board
    Function InitCtiBoard() As Boolean
        Dim nCheck As Int32
        Dim nChk As Int32
        Dim szConfig As String
        Dim szIndex As String
        Dim i As Int32

        Dim strbErrMsg As New System.Text.StringBuilder(500)

        szConfig = System.IO.Directory.GetCurrentDirectory() + "\ShConfig.ini"
        szIndex = System.IO.Directory.GetCurrentDirectory() + "\ShIndex.ini"
        'load configuration file and initialize system
        If SsmStartCti(szConfig, szIndex) <> 0 Then
            'get initialization error message
            SsmGetLastErrMsg(strbErrMsg)
            MsgBox(strbErrMsg.ToString())
            Return False
        End If
        'Judge if the number of initialized boards is the same as
        '		   that of boards specified in the configuration file
        If SsmGetMaxUsableBoard() <> SsmGetMaxCfgBoard() Then
            SsmGetLastErrMsg(strbErrMsg)
            MsgBox(strbErrMsg.ToString())
            Return False
        End If


        'Get the maximum number of the monitored circuits
        nMaxCic = SpyGetMaxCic()
        If (nMaxCic = -1) Then

            MessageBox.Show("Fail to call SpyGetMaxCic")
        End If


        Dim str As String
        For i = 0 To nMaxCic - 1

            CicState(1).szCallInDtmf = ""
            CicState(i).szCallOutDtmf = ""
            CicState(i).szCallerId = New System.Text.StringBuilder(20)  '""
            CicState(i).szCalleeId = New System.Text.StringBuilder(20)  '""
            CicState(i).nCicState = EnumCicState.CIRCUIT_IDLE
            CicState(i).nCallInIndex = 0
            CicState(i).nCallOutIndex = 0
            CicState(i).wRecDirection = EnumRecDir.MIX_RECORD
            CicState(i).nCallInCh = -1
            CicState(i).nCallOutCh = -1

            m_cmbCic.Items.Add(i.ToString())
        Next i

        Return True
    End Function

    'Initialize list
    Sub InitCircuitListCtrl()

        Dim i As Int32

        m_CicList.Cols = 6
        m_CicList.Row = 0

        m_CicList.Col = 0
        m_CicList.Text = "Cic"

        m_CicList.Col = 1
        m_CicList.Text = "CicState"

        m_CicList.Col = 2
        m_CicList.Text = "CallerId"

        m_CicList.Col = 3
        m_CicList.Text = "CalleeId"

        m_CicList.Col = 4
        m_CicList.Text = "InComingCh:DTMF"

        m_CicList.Col = 5
        m_CicList.Text = "OutgoingCh:DTMF"

        m_CicList.set_ColWidth(0, 40 * 17)
        m_CicList.set_ColWidth(1, 100 * 17)
        m_CicList.set_ColWidth(2, 100 * 17)
        m_CicList.set_ColWidth(3, 100 * 17)
        m_CicList.set_ColWidth(4, 120 * 17)
        m_CicList.set_ColWidth(5, 120 * 17)

        m_CicList.Rows = 1

        For i = 0 To nMaxCic - 1
            m_CicList.AddItem(i.ToString(), i + 1)
        Next i
    End Sub

⌨️ 快捷键说明

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