ExceleTel Header Logo

 

menu_end_leftmenu_homemenu_aboutmenu_productsmenu_salesmenu_supportmenu_searchmenu_end_right

 

etPager Sample Program Source Code

NOTE: Source code in other development environments  provided with the appropriate zip file on the main page for this sample.  VB is shown here just as an example.

Private Function IsOnlyDataModem() As Boolean
Dim ModemMediaModes As Integer

    ' These are the minimal media modes expected for standard data modems
    ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE + LINEMEDIAMODE_DATAMODEM

    ' Check to see if the selected device is a modem and it is a voice modem
    If (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) And _
        ((etLine1.DeviceMediaModesAvailable And ModemMediaModes) = _
            ModemMediaModes) Then
        IsOnlyDataModem = True
    Else
        IsOnlyDataModem = False
    End If
End Function

Private Function IsVoiceModem() As Boolean
Dim ModemMediaModes As Integer
Dim VoiceModemMediaModes As Integer

    ' These are the minimal media modes expected for standard data modems
    ModemMediaModes = LINEMEDIAMODE_INTERACTIVEVOICE + LINEMEDIAMODE_DATAMODEM
    ' These are the minimal media modes expected for voice modems
    VoiceModemMediaModes = ModemMediaModes + LINEMEDIAMODE_UNKNOWN + _
                            LINEMEDIAMODE_AUTOMATEDVOICE

    ' Check to see if the selected device is a modem and it is a voice modem
    If (InStr(1, etLine1.TAPITSP, "Modem", 1) > 0) And _
        ((etLine1.DeviceMediaModesAvailable And VoiceModemMediaModes) >= _
            VoiceModemMediaModes) Then
        IsVoiceModem = True
    Else
        IsVoiceModem = False
    End If
End Function

Private Sub Hangup()
    ' Make sure that it is safe to hangup
    If (etLine1.CallCount > 0) And _
        (etLine1.CallHandle <> 0) And _
        (etLine1.CallState <> LINECALLSTATE_IDLE) Then
        ' Hangup the call
        etLine1.CallHangup
    End If
End Sub

Private Sub ComboDevice_Click()
    ' Disable the Dial button
    CommandDial.Enabled = False
    TextStatus.Text = "Device not active..."

    ' Set the TAPI Line device
    etLine1.DeviceName = ComboDevice.Text

    ' Check to see if the selected device is a Voice modem
    If IsVoiceModem Then
        MsgBox ("This device is a Voice Modem!" & vbCrLf & _
                "Use the etVoiceModemPager sample program.")
    Else
        ' Check to see if the selected device is a modem
        If IsOnlyDataModem Then
            MsgBox ("This device is Data Modem!" & vbCrLf & _
                    "Use the etDataModemDial sample program.")
        Else
            If (etLine1.AddressCapabilitiesCallFeatures And _
                LINECALLFEATURE_GENERATEDIGITS) = 0 Then
                MsgBox ("This device is does not support sending digits!")
            Else
                ' Active the TAPI Line device
                etLine1.DeviceActive = True

                If Not etLine1.DeviceActive Then
                    TextStatus.Text = "Error opening line device: " & _
                    etLine1.ErrorText
                Else
                    ' Enable the Dial button
                    CommandDial.Enabled = True
                    TextStatus.Text = "Idle"
                End If
            End If
        End If
    End If
End Sub

Private Sub CommandDial_Click()
    ' Clear the status
    TextStatus.Text = ""

    etLine1.CallPhoneNumber = TextPhoneNumber.Text

    If etLine1.CallPhoneNumber = "" Then
        ' No phone number found
        TextStatus.Text = "No phone number"
        ' Go on to the next call
        etLine1_OnIdle (etLine1.CallHandle)
    Else
        ' Disable the Dail button
        CommandDial.Enabled = False
        ' Dial
        etLine1.CallDial
        ' Check for errors
        If etLine1.ErrorNumber = 0 Then
            TextStatus.Text = "Dialing - " & etLine1.CallPhoneNumber
        Else
            TextStatus.Text = "Error Dialing - " & etLine1.ErrorText
            ' Enable the Dail button
            CommandDial.Enabled = True
        End If
    End If
End Sub

Private Sub etLine1_OnBusy(ByVal CallHandle As Long)
    TextStatus.Text = "Busy"
    Hangup
End Sub

Private Sub etLine1_OnConnected(ByVal CallHandle As Long)
    ' Send the DTMF tones for the Call Back Number
    TextStatus.Text = "Sending digits..."
    Call etLine1.CallSendDigits(TextCallBackNumber.Text, Val(TextDuration.Text))
End Sub

Private Sub etLine1_OnDigitsSent(ByVal CallHandle As Long)
    ' The digits have been sent
    TextStatus.Text = "Sending digits... Complete"
    Hangup
End Sub

Private Sub etLine1_OnDisconnected(ByVal CallHandle As Long)
    Hangup
End Sub

Private Sub etLine1_OnIdle(ByVal CallHandle As Long)
    ' The call is complete
    TextStatus.Text = "Idle"
    ' Enable the Dial button
    CommandDial.Enabled = True
End Sub

Private Sub Form_Load()
    'Enabled all ExceleTel TeleTools controls before using them
    etLine1.Enabled = True

    ' Fill the combo box with all available devices
    ComboDevice.Clear
    etLine1.DeviceID = 0
    For L = 0 To etLine1.DeviceCount - 1
        ComboDevice.AddItem etLine1.DeviceList(L)
    Next L
    'Select the first device
    If ComboDevice.ListCount > 0 Then
        ComboDevice.Text = ComboDevice.List(0)
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    'Close the etLine control when closing the form
    etLine1.DeviceActive = False
End Sub

 

 
 


Copyright © 1997-2007 ExceleTel Inc. All rights reserved. Friday August 17, 2007 11:05:24 AM

Contact Us