Option Explicit
Private Declare Function timeGetTime Lib "winmm.dll" () As Long 'for slowing down GUI only
Public WithEvents tapiline As CvbTAPILine
Private ReallyExit As Boolean
Dim FirstLoad As Boolean
Private Function Init() As Boolean
Init = True
Exit Function
Fehler:
End Function
Private Sub Form_Load()
Dim success As Boolean
Dim line As Long
Me.Show
FirstLoad = True
Init
Set tapiline = New CvbTAPILine
tapiline.LowAPI = &H10003 ' 1.3 = &H00010003
tapiline.HiAPI = &H30000 ' 3.0 = &H00030000
success = tapiline.Create
End Sub
Private Sub weiter_Click()
RufAn (5565)
End Sub
Private Sub RufAn(ByVal PhoneNummber As String)
On Error Resume Next
Dim success As Boolean
If PhoneNummber = "" Then Exit Sub
If Not tapiline.Idle Then Exit Sub
weiter.Enabled = False
success = tapiline.OpenLine
If success <> True Then
MsgBox "TAPI ERROR " & vbCrLf & tapiline.ErrorString(tapiline.LastError), vbCritical, MsgBoxTxt
weiter.Enabled = True
Exit Sub
End If
tapiline.TransformPhoneNumber (5565)
success = tapiline.MakeCallAsynch(5565#)
If success <> True Then
Call tapiline.CloseLine
MsgBox "Error #" & tapiline.LastError & vbCrLf & _
tapiline.ErrorString(tapiline.LastError), vbInformation, MsgBoxTxt
weiter.Enabled = True
Exit Sub
End If
End Sub
Private Sub cmdDialProps_Click()
Dim success As Boolean
success = tapiline.DialingPropertiesDialog(Me.hWnd, txtPhoneNumber)
If success <> True Then
MsgBox tapiline.ErrorString(tapiline.LastError), vbCritical, MsgBoxTxt
End If
End Sub
Private Sub cmdExit_Click()
If MsgBox("Wirklich beenden?", vbQuestion + vbYesNo, MsgBoxTxt) = vbNo Then Exit Sub
Unload Me
End Sub
Private Sub timer1_timer()
Dim success As Boolean
success = tapiline.DropCallAsynch
If success <> True Then
MsgBox "Error #" & tapiline.LastError & vbCrLf & tapiline.ErrorString(tapiline.LastError), vbCritical, MsgBoxTxt
End If
End Sub
Private Sub tapiline_DropCallResult(ByVal errorCode As Long)
If errorCode = TAPI_SUCCESS Then
lstCallProgress.AddItem "Call Dropped: " & txtPhoneNumber.Text
lstCallProgress.TopIndex = lstCallProgress.ListCount - 1
Else
lstCallProgress.AddItem "Call Drop Error: " & tapiline.ErrorString(errorCode)
lstCallProgress.TopIndex = lstCallProgress.ListCount - 1
End If
End Sub
Private Sub tapiline_Disconnected()
cmdHangUp.Enabled = False
End Sub
Private Sub tapiline_Idle()
cmdHangUp.Enabled = False
weiter.Enabled = True
End Sub
Sub Pause(ByVal mSecs As Long, Optional bYield As Boolean = True)
Dim StartTime As Long
StartTime = timeGetTime()
Do While timeGetTime < StartTime + mSecs
If bYield Then
DoEvents
End If
Loop
End Sub