📄 call.vb
字号:
Public Class Form1
Inherits System.Windows.Forms.Form
Public ChInfo(1000) As CH_INFO
Public nMaxCh As Short 'maximum channel
#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 ChGrid As AxMSFlexGridLib.AxMSFlexGrid
Friend WithEvents Button1 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.ChGrid = New AxMSFlexGridLib.AxMSFlexGrid
Me.Button1 = New System.Windows.Forms.Button
CType(Me.ChGrid, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ChGrid
'
Me.ChGrid.Location = New System.Drawing.Point(16, 16)
Me.ChGrid.Name = "ChGrid"
Me.ChGrid.OcxState = CType(resources.GetObject("ChGrid.OcxState"), System.Windows.Forms.AxHost.State)
Me.ChGrid.Size = New System.Drawing.Size(432, 272)
Me.ChGrid.TabIndex = 0
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(352, 304)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(88, 23)
Me.Button1.TabIndex = 1
Me.Button1.Text = "Quit"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(480, 340)
Me.ControlBox = False
Me.Controls.Add(Me.Button1)
Me.Controls.Add(Me.ChGrid)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.ChGrid, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
SsmCloseCti() 'Close board driver
Me.Close()
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim i As Short
Dim EventSet As EVENT_SET_INFO
If InitCtiBoard() Then
'Set event-driven mode
EventSet.dwWorkMode = 3
EventSet.lpHandlerParam = Me.Handle.ToInt32
If (SsmSetEvent(-1, -1, True, EventSet) = -1) Then
MsgBox("Fail to call SsmSetEvent")
End If
Call InitCircuitListCtrl()
Call UpdateCircuitListCtrl()
End If
End Sub
Function InitCtiBoard() As Boolean
Dim ErrMsg As String
Dim szConfig As String
Dim szIndex As String
Dim i As Short
Dim nDirection As Int32
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
SsmGetLastErrMsg(ErrMsg)
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
'ENG:Enable automatic call progress
If (nDirection = 0 Or nDirection = 2) Then 'enable call in
ChInfo(i).nStep = TrkChState.TRK_IDLE
ChInfo(i).nEnCalled = True
ChInfo(i).nTimer = -1
ChInfo(i).szCallerId = New System.Text.StringBuilder(20)
End If
End If
Next i
InitCtiBoard = True
End If
End If
End Function
Public Sub InitCircuitListCtrl()
Dim i As Short
Me.ChGrid.Cols = 4
Me.ChGrid.Row = 0
Me.ChGrid.Col = 0
Me.ChGrid.Text = "Ch"
Me.ChGrid.Col = 1
Me.ChGrid.Text = "ChState"
Me.ChGrid.Col = 2
Me.ChGrid.Text = "CallerId"
Me.ChGrid.Col = 3
Me.ChGrid.Text = "DTMF"
Me.ChGrid.set_ColWidth(0, 45 * 12)
Me.ChGrid.set_ColWidth(1, 190 * 12)
Me.ChGrid.set_ColWidth(2, 150 * 12)
Me.ChGrid.set_ColWidth(3, 150 * 12)
Me.ChGrid.Rows = 1
For i = 0 To nMaxCh - 1
If ChInfo(i).nEnCalled Then Me.ChGrid.AddItem((Str(i)))
Next i
End Sub
Public Sub UpdateCircuitListCtrl()
Dim szNewStat As String
Dim szOldStat As String
Dim i As Short
Dim nIndex As Short
nIndex = 0
For i = 0 To nMaxCh - 1
If ChInfo(i).nEnCalled Then
Select Case (ChInfo(i).nStep)
Case TrkChState.TRK_IDLE
szNewStat = "Idle"
Case TrkChState.TRK_WAIT_CONNECT
szNewStat = "Connecting…"
Case TrkChState.TRK_CHECK_PLAY_WELCOME
szNewStat = "Playing welcome"
Case TrkChState.TRK_CHECK_PLAY_SELECT
szNewStat = "Waiting for select"
Case TrkChState.TRK_CHECK_REC_START
szNewStat = "Waiting for starting"
Case TrkChState.TRK_CHECK_REC_END
szNewStat = "Recording"
Case TrkChState.TRK_CHECK_PLAY_RECORD
szNewStat = "Playing record"
Case TrkChState.TRK_CHECK_PLAY_BYEBYE
szNewStat = "Playing Byebye"
End Select
szOldStat = Me.ChGrid.get_TextMatrix(nIndex + 1, 1)
If (szOldStat <> szNewStat) Then
Me.ChGrid.set_TextMatrix(nIndex + 1, 1, szNewStat)
End If
szOldStat = Me.ChGrid.get_TextMatrix(nIndex + 1, 2)
If (szOldStat <> ChInfo(i).szCallerId.ToString()) Then
Me.ChGrid.set_TextMatrix(nIndex + 1, 2, ChInfo(i).szCallerId.ToString())
End If
szOldStat = Me.ChGrid.get_TextMatrix(nIndex + 1, 3)
If (szOldStat <> ChInfo(i).szDtmf) Then
Me.ChGrid.set_TextMatrix(nIndex + 1, 3, ChInfo(i).szDtmf)
End If
nIndex = nIndex + 1
End If
Next i
End Sub
Protected Overrides Sub WndProc(ByRef uMsg As Message)
Dim nCh As Int32
Dim i As Int32
Dim nEventCode As Int32
Dim nNewState As Int32
Dim cNewDtmf As String
Dim WM_USER As Int32 = &H400
'Adopt windows message mechanism
' windows message code:event code + &H400(WM_USER)
If (uMsg.Msg > WM_USER) Then
nEventCode = uMsg.Msg - WM_USER
Select Case nEventCode
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -