ExceleTel Header Logo

 

menu_end_leftmenu_homemenu_aboutmenu_productsmenu_salesmenu_supportmenu_searchmenu_end_right

 

etDataModemDialTone Sample Program Source Code

Private Function IsDataModem() 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
        IsDataModem = True
    Else
        IsDataModem = 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 ComboDevice_Click()
    ' Disable the hangup button
    CommandHangup.Enabled = False

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

    ' Check to see if the selected device is a modem
    If IsDataModem Then
        ' Check to see if the selected device is a Voice modem
        If IsVoiceModem Then
            MsgBox ("This device is Voice Modem!" & vbCrLf & _
                    "Use the etVoiceModemDialTone sample program.")
            ' Disable the Dial Tone button
            CommandDialTone.Enabled = False
        Else
            ' Enable the Dial Tone button
            CommandDialTone.Enabled = True
        End If
    Else
        MsgBox ("This device is not a Modem")
        ' Disable the Dial Tone button
        CommandDialTone.Enabled = False
    End If
End Sub

Private Sub CommandDialTone_Click()
    ' Use Microsoft's modem compatibility mode
    etLine1.PrivilegeNone = True

    ' Active the TAPI Line device
    etLine1.DeviceActive = True

    If Not etLine1.DeviceActive Then
        MsgBox ("Error opening line device: " & etLine1.ErrorText)
    Else
        ' Set the phone number to 'W' which tells the modem to wait for dialtone
        etLine1.CallPhoneNumber = "W"
        ' Dial
        etLine1.CallDial
        ' Disable the Dial button
        CommandDialTone.Enabled = False
        ' Enable the hangup button
        CommandHangup.Enabled = True
    End If
End Sub

Private Sub CommandHangup_Click()
    ' As soon as the call is complete deactive the TAPI Line device
    etLine1.DeviceActive = False

    ' Enabled the Dial Tone button
    CommandDialTone.Enabled = True

    ' Disable the hangup button
    CommandHangup.Enabled = False
End Sub

Private Sub etLine1_OnConnected(ByVal CallHandle As Long)
    MsgBox ("Dial Tone detected!")
    CommandHangup_Click
End Sub

Private Sub etLine1_OnDisconnected(ByVal CallHandle As Long)
    If (etLine1.CallDisconnectMode = 0) Or _
        (etLine1.CallDisconnectMode = LINEDISCONNECTMODE_NORMAL) Then
        MsgBox ("Dial Tone detected!")
    Else
        If etLine1.CallDisconnectMode = LINEDISCONNECTMODE_NODIALTONE Then
            MsgBox ("Dial Tone was not detected!")
        Else
            ' Not sure if a dial tone was detected or not?
            MsgBox ("Disconnect mode = " & _
                    etLine1.StringLINEDISCONNECTMODE(etLine1.CallDisconnectMode))
        End If
    End If
    CommandHangup_Click
End Sub

Private Sub Form_Load()
    ' Disable the hangup button
    CommandHangup.Enabled = False

    'Enabled all ExceleTel TeleTools controls before using them
    etLine1.Enabled = True

    ' Fill in the list box with all available telephony devices
    ComboDevice.Clear
    etLine1.DeviceID = 0
    For L = 0 To etLine1.DeviceCount - 1
        ComboDevice.AddItem etLine1.DeviceList(L)
    Next L

    ' Select the first device in the list
    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