Search:
     
3CX Phone System for Windows Download the Free Edition

Using IAXOCX in vb

If you need the full demo codes ,please send email to support@ipxchina.cn.
You can get more information from our website http://www.ipxchina.cn.

The GUI of demo



iaxocxvb.jpg


These are some sample codes for using IAXOCX in VC.



Dim isHold As Boolean
Dim isMute As Boolean
Dim is_InitOk As Boolean
Dim last_dialout As String
Dim input_devid As Long
Dim output_devid As Long
Dim ring_devid As Long




Private Sub Command1_Click(Index As Integer)
   Dim linestatus As Long
   Dim key As String
   linestatus = MVBphone1.GetLineStateINT(0)
   key = Command1.Item(Index).Caption
   If (linestatus = 0) Then
       callnumber.Text = callnumber.Text + key
   End If
    If (linestatus > 0) Then
       MVBphone1.SendDTMF (key)
   End If
End Sub

Private Sub Command10_Click()
   Dim linestatus As Long
   linestatus = MVBphone1.GetLineStateINT(0)
   If (linestatus > 0) Then
       MVBphone1.RejectCall (0)
   End If
   
End Sub

Private Sub Command11_Click()
 Dim linestatus As Long
   linestatus = MVBphone1.GetLineStateINT(0)
   If (linestatus > 0) Then
       MVBphone1.BusyCall (0)
   End If
   
End Sub

Private Sub Command12_Click()
   MVBphone1.Mute
   isMute = True
End Sub

Private Sub Command13_Click()
    MVBphone1.UnMute
    isMute = False
End Sub

Private Sub Command14_Click()

   input_devid = ComboInput.ItemData(ComboInput.ListIndex)
   output_devid = ComboOutput.ItemData(ComboOutput.ListIndex)
   ring_devid = ComboRing.ItemData(ComboRing.ListIndex)
   MVBphone1.SetAudioDevices input_devid, output_devid, ring_devid
   MVBphone1.ApplyFilter Check_AGC.Value, Check_AAGC.Value, Check_RN.Value, Check_EC.Value, Check_CN.Value

End Sub

Private Sub Command15_Click()
MVBphone1.SetAudioDevices 1, 7, 7
End Sub

Private Sub Command2_Click()
   Dim num As String
   num = callnumber.Text
   If (Len(num) > 0) Then
       MVBphone1.Dial (num)
       last_dialout = num
   Else
       If (Len(last_dialout) > 0) Then
           MVBphone1.Dial (last_dialout)
       End If
   
   End If
End Sub

Private Sub Command3_Click()
   MVBphone1.HangupAll
   callnumber.Text = ""
   ShapeInput.Width = 0
   ShapeOutput.Width = 0
End Sub

Private Sub Command4_Click()
   Dim linestatus As Long
   linestatus = MVBphone1.GetLineStateINT(0)
   If (linestatus > 0) Then
       MVBphone1.AcceptCall (0)
   End If
End Sub

Private Sub Command5_Click()
   Dim linestatus As Long
   linestatus = MVBphone1.GetLineStateINT(0)
   If (linestatus > 0) Then
       MVBphone1.Hold (0)
       isHold = True
   End If
End Sub

Private Sub Command6_Click()
   Dim linestatus As Long
   linestatus = MVBphone1.GetLineStateINT(0)
   If (linestatus > 0) Then
       MVBphone1.UnHold (0)
       isHold = False
   End If
End Sub

Private Sub Command7_Click()
   Dim linestatus As Long
   Dim ret As Long
   Dim MyValue As String
   linestatus = MVBphone1.GetLineStateINT(0)
   If (linestatus > 0) Then
      
      MyValue = InputBox("请输入转接号码", "转接", Default, 100, 100)
      If (Len(MyValue) > 0) Then
         MVBphone1.BlindTransfer 0, MyValue
      End If
      
   End If
   callnumber.Text = ""
End Sub

Private Sub Command8_Click()
   MVBphone1.HostName = "192.168.0.96"
   MVBphone1.Port = 4569
   MVBphone1.UserID = "7101"
   MVBphone1.Password = "7101"
   MVBphone1.Codec = 4  'GSM-2,G711U-4,G711A-8
   MVBphone1.PhoneNumber = "7101"
   MVBphone1.Register
End Sub

Private Sub Command9_Click()
   MVBphone1.UnRegister
End Sub

Private Sub Form_Load()
   is_InitOk = False
   MVBphone1.InitIAX (1)
   
   MVBphone1.GetAudioDevice
   ShapeInput.Width = 0
   ShapeOutput.Width = 0
   VScrollMIC.Value = MVBphone1.GetMicVolume
   VScrollSPEAKER.Value = MVBphone1.GetSpeakerVolume
   'MVBphone1.ApplyFilter 0, 0, 0, 0, 0
   Check_AGC.Value = MVBphone1.GetFilterAGC
   Check_AAGC.Value = MVBphone1.GetFilterAAGC
   Check_CN.Value = MVBphone1.GetFilterCN
   Check_RN.Value = MVBphone1.GetFilterNoiseReduce
   Check_EC.Value = MVBphone1.GetFilterEchoCancel
   
   is_InitOk = True
End Sub

Private Sub Form_Unload(Cancel As Integer)
   MVBphone1.Shutdown
End Sub

Private Sub Label_link_Click()
   MVBphone1.AboutBox
End Sub

Private Sub MVBphone1_AudioDevices(ByVal DeviceID As Long, ByVal DeviceName As String, ByVal DeviceType As String, ByVal DeviceConfig As String)
   If (InStr(DeviceType, "INPUT") > 0) Then
       ComboInput.AddItem (Str(DeviceID) + "-" + DeviceName)
       ComboInput.ItemData(ComboInput.NewIndex) = DeviceID

       If (InStr(DeviceType, "INPUTDEFAULT")) Then
           input_devid = DeviceID
           ComboInput.ListIndex = ComboInput.NewIndex
       End If
   End If
   
   If (InStr(DeviceType, "OUTPUT") > 0) Then
       ComboOutput.AddItem (Str(DeviceID) + "-" + DeviceName)
       ComboOutput.ItemData(ComboOutput.NewIndex) = DeviceID
      If (InStr(DeviceType, "OUTPUTDEFAULT") > 0) Then
            input_devid = DeviceID
           ComboOutput.ListIndex = ComboOutput.NewIndex
      End If
   End If
   If (InStr(DeviceType, "RING") > 0) Then
       ComboRing.AddItem (Str(DeviceID) + "-" + DeviceName)
       ComboRing.ItemData(ComboRing.NewIndex) = DeviceID
       If (InStr(DeviceType, "RINGDEFAULT") > 0) Then
            ring_devid = DeviceID
           ComboRing.ListIndex = ComboRing.NewIndex
       End If
   End If
   
  
End Sub

Private Sub MVBphone1_Levels(ByVal InputLevel As Long, ByVal OutputLevel As Long)
   
   If (isMute) Then
       ShapeInput.Width = 0
   Else
    ShapeInput.Width = Int(3000 * (Abs(InputLevel) / 100000))
   End If
   If (isHold) Then
       ShapeOutput.Width = 0
   Else
    ShapeOutput.Width = Int(3000 * (Abs(OutputLevel) / 100000))
   End If
End Sub

Private Sub MVBphone1_Messages(ByVal CallNo As Long, ByVal Message As String, ByVal TypeINT As Long, ByVal TypeText As String)
   Label12.Caption = Message + "" + TypeText + ""
End Sub

Private Sub MVBphone1_Registration(ByVal RegID As Long, ByVal Reply As Long, ByVal msgCount As Long, ByVal ReplyText As String)
Label2.Caption = "注册状态:" + ReplyText + "" + Str(Reply) + ""
Label3.Caption = "语音留言:" + "" + Str(msgCount) + ""
End Sub

Private Sub MVBphone1_StateEvents(ByVal CallNo As Long, ByVal State As Long, ByVal AudioFormat As Long, ByVal VideoFormat As Long, ByVal RemoteNumber As String, ByVal RemoteName As String, ByVal LocalNumber As String, ByVal LocalContext As String)
Dim LineStateText As String
LineStateText = MVBphone1.GetLineState(CallNo)
If (State > 0) Then
   If (InStr(LineStateText, "OUTGOING") > 0) Then
       Label4.Caption = RemoteNumber
       Label11.Caption = "OUT"
   Else
      Label4.Caption = RemoteNumber + "  " + RemoteName
      Label11.Caption = "IN"
   End If
End If
If (AudioFormat = 2) Then
   Label5.Caption = "GSM"
End If
If (AudioFormat = 4) Then
   Label5.Caption = "G711A"
End If
If (AudioFormat = 8) Then
   Label5.Caption = "G711U"
End If
If (State <= 0) Then
    Label5.Caption = ""
End If
End Sub

Private Sub MVBphone1_StateMessages(ByVal CallNo As Long, ByVal State As Long, ByVal Message As String)
   Label1.Caption = "线路状态:" + Message + "" + Str(State) + ""
   If (State <= 0) Then
       ShapeInput.Width = 0
       ShapeOutput.Width = 0
   End If
   
End Sub

Private Sub VScrollMIC_Change()
   Dim Volume As Long
   If (is_InitOk) Then
       Volume = VScrollMIC.Value
       MVBphone1.SetMicVolume (Volume)
   End If
End Sub

Private Sub VScrollSPEAKER_Change()
   Dim Volume As Long
   If (is_InitOk) Then
       Volume = VScrollSPEAKER.Value
       MVBphone1.SetSpeakerVolume (Volume)
   End If
End Sub
Created by: jalonljc,Last modification on Wed 04 of Aug, 2010 [07:37 UTC]


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - support@voip-info.org

Page Changes | Comments

 





Search: