📄 call.bas
字号:
Attribute VB_Name = "Call"
Option Explicit
'******************************************************************************************************************
'********************************************** Declare Start **************************************************
'******************************************************************************************************************
'enum CH_STATE
Const TRK_IDLE = 0 'Idle state
Const TRK_RING = 1 'Ringing state
Const TRK_ACTIVE = 2 'Active state
Const TRK_OUTLINE = 3 'Outline state
'enum CH_LISTEN
Const UNLISTEN = 4 'Unlisten
Const LISTEN = 5 'Listen
'enmu CH_RECORD
Const UNRECORD = 6 'Unrecord
Const RECORD = 7 'Record
'enmu CH_DIRECTION
Const UNKNOWN = 8 'Unknown
Const UP = 9 'Call out
Const DOWN = 10 'Call in
Type TRUNK_STRUCT 'Channel structure
Step As Integer 'Channel state
Islisten As Integer 'Listen state
Isrecord As Integer 'Record state
pCallerId As String * 10 'Pho Num
Lcd As String * 20 'LCD info
Dir As Integer 'Call dir
volume As Integer 'Vol
pErrMsg As String * 200 'Wrong info
dwTimeOutCounter As Long 'Time
lineState As Long 'Step channel state
End Type
'Declare Function of Microsoft Windows
Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" ( _
ByVal hWnd As Long, _
ByVal nIndex 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 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
'Declare public variable
Public prevWndProc As Long 'Used by CallWindowProc function that Pointer to the previous window procedure.
Public Const WM_USER = &H400 'Message numbers(0 through WM_USER–1) are defined by the system
Public Const GWL_WNDPROC = (-4) 'Used by GetWindowLong function,which's action that retrieves the address of the window procedure, or a handle representing the address of the window procedure.
Public nTotalCh As Integer 'Total of channel
Public ATrkCh(0 To 100) As TRUNK_STRUCT 'Array of TRUNK_STRUCT's type
Public EVENT_SET_INF As EVENT_SET_INFO_STRUCT 'Event structure
Public ListenChannel As Integer 'Listen channel
Public UsefulChannel As Integer 'Useful channel
'********************************************************************************************************************
'********************************************** Declare End **************************************************
'********************************************************************************************************************
Public Function NewWndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim nEvent As Long 'Event code
Dim ch As Long 'Channel
Dim reChkRecToFile As Integer 'Record state
Dim recFile As String 'Record file name
If (Msg > WM_USER) Then 'Deal with custom's message,system message is send to CallWindowProc function
nEvent = Msg - WM_USER
ch = wParam
ATrkCh(ch).lineState = lParam And &HFFFF&
Select Case ATrkCh(ch).Step 'Judge state
'{
Case TRK_IDLE: 'Idle state
'{
Select Case nEvent 'Judge event
'{
Case E_CHG_ChState:
'{
Select Case ATrkCh(ch).lineState 'Judge event's reference
'{
Case S_CALL_STANDBY:
'{
'}
'break
Case S_CALL_RINGING:
'{
ATrkCh(ch).Dir = DOWN
ATrkCh(ch).Step = TRK_RING
'}
'break
Case S_DTRC_ACTIVE:
'{
recFile = "Test" + Str(ch)
If SsmRecToFile(ch, recFile, -1, 0, &HFFFFFFFF, 0, 0) = -1 Then 'Start the file sound recording task on the designates channel. -1:error
AppErrorHandler (ch)
End If
If DTRGetLCDStr(ch, ATrkCh(ch).Lcd) = -1 Then 'Obtains the current display information of LCD from recorded the telephone. -1:error
AppErrorHandler (ch)
End If
ATrkCh(ch).Step = TRK_ACTIVE
ATrkCh(ch).Isrecord = RECORD
ATrkCh(ch).Dir = UP
'}
'break
Case S_CALL_OFFLINE:
'{
ATrkCh(ch).Step = TRK_OUTLINE
'}
'break
'default:
'break
'}
End Select 'ATrkCh(ch).lineState No3
'}
'break
'default:
'break
'}
End Select 'nEvent No2
'}
'break
Case TRK_RING:
'{
Select Case nEvent
'{
Case E_CHG_ChState:
'{
Select Case ATrkCh(ch).lineState
'{
Case S_CALL_STANDBY:
'{
ATrkCh(ch).Step = TRK_IDLE
'}
'break
Case S_CALL_RINGING:
'{
'}
'break
Case S_DTRC_ACTIVE:
'{
ATrkCh(ch).Step = TRK_ACTIVE
recFile = "Test" + Str(ch)
If SsmRecToFile(ch, recFile, -1, 0, &HFFFFFFFF, 0, 0) = -1 Then 'Start the file sound recording task on the designates channel. -1:error
AppErrorHandler (ch)
End If
ATrkCh(ch).Isrecord = RECORD
If DTRGetLCDStr(ch, ATrkCh(ch).Lcd) = -1 Then 'Obtains the current display information of LCD from recorded the telephone. -1:error
AppErrorHandler (ch)
End If
'}
'break
Case S_CALL_OFFLINE:
'{
ATrkCh(ch).Step = TRK_OUTLINE
'}
'break
'default:
'break
'}
End Select 'ATrkCh(ch).lineState No3
'}
'break
'default:
'break
'}
End Select 'nEvent No2
'}
'break
Case TRK_ACTIVE:
'{
Select Case nEvent
'{
Case E_CHG_ChState:
'{
Select Case ATrkCh(ch).lineState
'{
Case S_CALL_STANDBY:
'{
ATrkCh(ch).Step = TRK_IDLE
ATrkCh(ch).Isrecord = UNRECORD
reChkRecToFile = SsmChkRecToFile(ch) 'Obtains the situation of the file sound recording task. -1:error
If reChkRecToFile = -1 Then
AppErrorHandler (ch)
End If
If reChkRecToFile = 1 Then '1:Recording
If SsmStopRecToFile(ch) = -1 Then 'Stop the file sound recording task. -1:error
AppErrorHandler (ch)
End If
End If
If ATrkCh(ch).Dir = DOWN Then
If SsmGetCallerId(ch, ATrkCh(ch).pCallerId) = -1 Then 'Get the calling pho Num. -1:error
AppErrorHandler (ch)
End If
ElseIf ATrkCh(ch).Dir = UP Then
If SsmGetPhoNumStr(ch, ATrkCh(ch).pCallerId) = -1 Then 'Get the called pho Num. -1:error
AppErrorHandler (ch)
End If
End If
'}
'break
Case S_CALL_RINGING:
'{
'}
'break
Case S_DTRC_ACTIVE:
'{
'}
'break
Case S_CALL_OFFLINE:
'{
ATrkCh(ch).Step = TRK_OUTLINE
ATrkCh(ch).Isrecord = UNRECORD
reChkRecToFile = SsmChkRecToFile(ch) 'Obtains the situation of the file sound recording task. -1:error
If reChkRecToFile = -1 Then
AppErrorHandler (ch)
End If
If reChkRecToFile = 1 Then '1:Recording
If SsmStopRecToFile(ch) = -1 Then 'Stop the file sound recording task. -1:error
AppErrorHandler (ch)
End If
End If
'}
'break
'default:
'break
'}
End Select 'ATrkCh(ch).lineState No3
'}
'break
Case E_RCV_DTR_DISPLAY:
'{
If DTRGetLCDStr(ch, ATrkCh(ch).Lcd) = -1 Then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -