📄 frmmain.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form frmMain
Caption = "telmate_v6_demo"
ClientHeight = 7785
ClientLeft = 60
ClientTop = 450
ClientWidth = 8325
LinkTopic = "Form1"
ScaleHeight = 7785
ScaleWidth = 8325
StartUpPosition = 3 'Windows Default
Begin VB.CommandButton hangupctrl
Caption = "系统挂机"
Height = 495
Left = 3720
TabIndex = 20
Top = 6360
Width = 1455
End
Begin VB.CommandButton offhookctrl
Caption = "系统摘机"
Height = 495
Left = 3720
TabIndex = 19
Top = 5520
Width = 1455
End
Begin VB.CommandButton enabletel
Caption = "电话机器可用"
Height = 495
Left = 2040
TabIndex = 18
Top = 6360
Width = 1335
End
Begin VB.CommandButton disabletel
Caption = "电话机器不可用"
Height = 495
Left = 2040
TabIndex = 17
Top = 5520
Width = 1575
End
Begin VB.CommandButton closemic
Caption = "mic不可用"
Height = 495
Left = 120
TabIndex = 16
Top = 6360
Width = 1455
End
Begin VB.CommandButton openmic
Caption = "mic可用"
Height = 495
Left = 120
TabIndex = 15
Top = 5520
Width = 1575
End
Begin MSComDlg.CommonDialog FileDlg
Left = 7200
Top = 120
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Timer Timer1
Interval = 50
Left = 7800
Top = 120
End
Begin VB.Frame Frame5
Caption = "录音"
Height = 1455
Left = 5520
TabIndex = 9
Top = 3960
Width = 2655
Begin VB.CommandButton cmdSaveFile
Caption = "输出到文件"
Height = 300
Left = 360
TabIndex = 14
Top = 840
Width = 1935
End
Begin VB.OptionButton optRecMic
Caption = "麦克风"
Height = 255
Left = 1560
TabIndex = 13
Top = 360
Width = 855
End
Begin VB.OptionButton optLineRec
Caption = "电话线"
Height = 255
Left = 240
TabIndex = 12
Top = 360
Value = -1 'True
Width = 855
End
End
Begin VB.Frame Frame4
Caption = "放音"
Height = 975
Left = 2760
TabIndex = 8
Top = 3960
Width = 2655
Begin VB.CommandButton cmdPlayFile
Caption = "播放文件"
Height = 300
Left = 360
TabIndex = 11
Top = 360
Width = 1815
End
End
Begin VB.Frame Frame3
Caption = "控制"
Height = 975
Left = 120
TabIndex = 7
Top = 3960
Width = 2535
Begin VB.CommandButton cmdReinit
Caption = "重新初始化"
Height = 300
Left = 360
TabIndex = 10
Top = 360
Width = 1455
End
End
Begin VB.Frame Frame1
Caption = "拨号"
Height = 855
Left = 120
TabIndex = 1
Top = 2040
Width = 8055
Begin VB.CommandButton cmdDial
Caption = "拨号"
Height = 300
Left = 6120
TabIndex = 6
Top = 360
Width = 855
End
Begin VB.ComboBox cboSpeed
Height = 315
ItemData = "frmMain.frx":0000
Left = 4080
List = "frmMain.frx":0002
TabIndex = 5
Top = 360
Width = 1575
End
Begin VB.TextBox txtNumber
Height = 285
Left = 960
TabIndex = 3
Top = 360
Width = 2295
End
Begin VB.Label Label2
Caption = "速度:"
Height = 255
Left = 3480
TabIndex = 4
Top = 360
Width = 735
End
Begin VB.Label Label1
Caption = "号码:"
Height = 255
Left = 240
TabIndex = 2
Top = 360
Width = 615
End
End
Begin VB.ListBox lstMessage
Height = 1815
Left = 120
TabIndex = 0
Top = 120
Width = 8055
End
End
Attribute VB_Name = "frmMain"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private bOpen As Boolean
Private e As TEvent
Private nPlayDevID As Long
Private nRecDevID As Long
Private Sub ShowMsg(msg As String)
lstMessage.AddItem msg
End Sub
Private Sub OpenDevice()
If TV_Initialize() Then
ShowMsg "初始化设备成功"
bOpen = True
Else
ShowMsg "初始化设备失败"
bOpen = False
End If
End Sub
Private Sub ReOpenDevice()
If TV_ReInit() Then
ShowMsg "重新初始化设备成功"
bOpen = True
Else
ShowMsg "重新初始化设备失败"
bOpen = False
End If
End Sub
Private Sub CloseDevice()
' If bOpen Then
TV_Disable
ShowMsg "设备已关闭"
bOpen = False
' End If
End Sub
Private Sub offhook()
If bOpen Then
TV_OffHookCtrl
Sleep 500 ' 摘机时间,可调节
ShowMsg "摘机"
Else
ShowMsg "设备没打开"
End If
End Sub
Private Sub hangup()
If bOpen Then
TV_HangUpCtrl
ShowMsg "挂机"
Else
ShowMsg "设备没打开"
End If
End Sub
Private Sub Dial(num As String, ByVal speed As Integer)
If bOpen Then
TV_SetSendDTMFSpeed speed
TV_StartDial num, True
ShowMsg "拨号: " + num + " 速度: " + Str(speed)
Else
ShowMsg "设备没有打开"
End If
End Sub
Private Sub StopDial()
TV_StopDial
End Sub
Private Sub cboSpeed_Change()
If Not IsNumeric(cboSpeed.Text) Then
cboSpeed.Text = ""
ShowMsg "输入速度不正确"
End If
End Sub
Private Sub closemic_Click()
TV_EnableMic (False)
End Sub
Private Sub cmdDial_Click()
Dim num As String
Dim speed As Integer
If cmdDial.Caption = "拨号" Then
num = txtNumber.Text
speed = Int(cboSpeed.Text) ' speed
If num = "" Then
ShowMsg "号码为空"
Else
offhook ' 摘机
Dial num, speed '拨号
cmdDial.Caption = "停止拨号"
End If
Else
StopDial
hangup '挂机
cmdDial.Caption = "拨号"
End If
End Sub
Private Sub cmdPlayFile_Click()
' Dim nDevID As Integer
If bOpen = False Then Exit Sub '
If cmdPlayFile.Caption = "播放文件" Then
FileDlg.ShowOpen
If FileDlg.FileName <> "" Then
nPlayDevID = TV_StartPlayFile(FileDlg.FileName, 0, 0, True, True, True, 0)
If nPlayDevID = -1 Then
ShowMsg "播放出错"
Else
cmdPlayFile.Caption = "停止播放"
ShowMsg "开始播放文件"
End If
End If
Else
TV_StopPlayFile nPlayDevID
cmdPlayFile.Caption = "播放文件"
ShowMsg "停止播放文件"
End If
End Sub
Private Sub cmdSaveFile_Click()
If cmdSaveFile.Caption = "输出到文件" Then
FileDlg.ShowOpen
If FileDlg.FileName <> "" Then
If optLineRec.Value Then
' Line
offhook '先摘机
nRecDevID = TV_StartRecordFile(FileDlg.FileName, 0, 0)
Else
' Mic
nRecDevID = TV_StartRecordFile(FileDlg.FileName, 0, 0)
End If
cmdSaveFile.Caption = "停止录音"
End If
Else
If optLineRec.Value Then
hangup
TV_StopRecordFile nRecDevID, False
Else
TV_StopRecordFile nRecDevID, False
End If
cmdSaveFile.Caption = "输出到文件"
End If
End Sub
Private Sub disabletel_Click()
TV_EnableRing (False)
End Sub
Private Sub enabletel_Click()
TV_EnableRing (True)
End Sub
Private Sub Form_Load()
Dim i As Integer
For i = 1 To 10
' set speed level
cboSpeed.AddItem Str(i * 50)
Next i
cboSpeed.ListIndex = 2
OpenDevice ' 打开设备
End Sub
Private Sub Form_Unload(Cancel As Integer)
CloseDevice ' 关闭设备
End Sub
Private Sub cmdReinit_Click()
ReOpenDevice
End Sub
Private Sub hangupctrl_Click()
TV_HangUpCtrl
End Sub
Private Sub offhookctrl_Click()
TV_OffHookCtrl
End Sub
Private Sub openmic_Click()
TV_EnableMic (True)
End Sub
Private Sub Timer1_Timer()
'If TV_GetEvent(CHN, e) > 0 Then
Dim buf As String * MaxDataLen
Dim lEventType As Long
Dim lResult As Long
'If TV_GetEvent(e) > 0 Then
If TV_GetEventEx(lEventType, lResult, buf, MaxDataLen) > 0 Then
'Select Case e.EventType
Select Case lEventType
Case TEvent_GetDTMF: '接收来电号码
'ShowMsg (e.Data.buf)
ShowMsg (buf)
Case TEvent_GetFsk:
'ShowMsg (e.Data.buf)
ShowMsg (buf)
Case TEvent_MicIn:
ShowMsg ("麦克风插入") '
Case TEvent_MicOut:
ShowMsg ("麦克风拔出")
Case TEvent_OffHook:
ShowMsg ("呼叫方摘机")
Case TEvent_Ring:
ShowMsg ("来电响铃")
Case TEvent_DialEnd:
ShowMsg ("拨号结束")
Case TEvent_Busy:
ShowMsg ("忙音")
Case TEvent_PlayEnd:
ShowMsg ("播放完毕")
Case TEvent_HangUp:
ShowMsg ("对方挂机")
Case TEvent_InterHangUp:
ShowMsg ("本地话机挂机")
Case TEvent_InterOffHook:
ShowMsg ("本地话机摘机")
Case TEvent_Nobody:
ShowMsg ("无人接听")
Case TEvent_GetChar: '通话中接收按键号码
'ShowMsg ("取得DTMF码 " + e.Data.buf)
ShowMsg ("取得DTMF码 " + buf)
Case TEvent_GetInterChar:
ShowMsg ("本地话机拨号")
Case TEvent_TelCallOut:
ShowMsg ("本地话机拨号后听到回铃")
Case TEvent_PlugOut:
ShowMsg ("设备被拔掉")
Case TEvent_PlugIn:
ShowMsg ("设备被插入")
End Select
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -