Using IAXOCX in VC

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



iaxocxvc.jpg



These are some sample codes for using IAXOCX in VB.




void CIaxphonevc6Dlg::OnInit() 
{
	// TODO: Add your control notification handler code here
	if (!m_initphone){
		m_mvbphone.SetHostName(_T("demo.mvb2000.cn"));
		m_mvbphone.SetPort(7569);
		m_mvbphone.SetUserID(_T("6201"));
		m_mvbphone.SetPassword(_T("6201"));
		m_mvbphone.SetCodec(2);
		m_mvbphone.InitIAX(1);
		m_initphone=true;
	}
	
}

void CIaxphonevc6Dlg::OnRegister() 
{
	// TODO: Add your control notification handler code here
	if (m_initphone)
		m_mvbphone.Register();
	else
		AfxMessageBox(_T("请先开始服务!"));
}

void CIaxphonevc6Dlg::OnDial() 
{
	UpdateData(true);
	// TODO: Add your control notification handler code here
	if (!m_PhoneNumber.IsEmpty()){
		m_mvbphone.Dial(m_PhoneNumber);
	}else{
		CWnd* pwnd=GetDlgItem(IDC_NUM);
		pwnd->SetFocus();
		AfxMessageBox(_T("请输入电话号码!"));

	}


	
}

void CIaxphonevc6Dlg::OnUnregister() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.UnRegister();
	
}

void CIaxphonevc6Dlg::OnShutdown() 
{
	// TODO: Add your control notification handler code here
	if (m_initphone)
		m_mvbphone.Shutdown();
}

void CIaxphonevc6Dlg::OnDevice() 
{
	// TODO: Add your control notification handler code here
	m_edit_device.SetWindowText(_T(""));
	m_mvbphone.GetAudioDevice();
}

void CIaxphonevc6Dlg::OnAnswer() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.AcceptCall(0);
}

void CIaxphonevc6Dlg::OnHangup() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.HangUp();
	m_PhoneNumber.Empty();
	
}

void CIaxphonevc6Dlg::OnHold() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.Hold(0);
}

void CIaxphonevc6Dlg::OnUnhold() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.UnHold(0);
}

BEGIN_EVENTSINK_MAP(CIaxphonevc6Dlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CIaxphonevc6Dlg)
	ON_EVENT(CIaxphonevc6Dlg, IDC_IAXOCX1, 7 /* Registration */, Iaxocx1_OnRegistration, VTS_I4 VTS_I4 VTS_I4 VTS_BSTR)
	ON_EVENT(CIaxphonevc6Dlg, IDC_IAXOCX1, 5 /* StateMessages */, Iaxocx1_OnStateMessages, VTS_I4 VTS_I4 VTS_BSTR)
	ON_EVENT(CIaxphonevc6Dlg, IDC_IAXOCX1, 2 /* AudioDevices */, Iaxocx1_OnAudioDevices, VTS_I4 VTS_BSTR VTS_BSTR VTS_BSTR)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CIaxphonevc6Dlg::Iaxocx1_OnRegistration(long RegID, long Reply, long msgCount, LPCTSTR ReplyText) 
{
	// TODO: Add your control notification handler code here
	CString sText;
	m_edit_event.GetWindowText(sText);
	sText=sText+_T("\r\n")+ReplyText;
	m_edit_event.SetWindowText(sText);

	
}

void CIaxphonevc6Dlg::Iaxocx1_OnStateMessages(long CallNo, long State, LPCTSTR Message) 
{
	// TODO: Add your control notification handler code here

	CString sText;
	m_edit_event.GetWindowText(sText);
	sText=sText+_T("\r\n")+Message;
	m_edit_event.SetWindowText(sText);
	
}

void CIaxphonevc6Dlg::Iaxocx1_OnAudioDevices(long DeviceID, LPCTSTR DeviceName, LPCTSTR DeviceType, LPCTSTR DeviceConfig) 
{
	// TODO: Add your control notification handler code here
	CString sText;
	m_edit_device.GetWindowText(sText);
	sText=sText+_T("\r\n")+DeviceName+_T("[")+DeviceType+_T("]")+_T("[")+DeviceConfig+_T("]");
	m_edit_device.SetWindowText(sText);

}

void CIaxphonevc6Dlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("1"));
	else{
		m_PhoneNumber+=_T("1");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("2"));
	else{
		m_PhoneNumber+=_T("2");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("3"));
	else{
		m_PhoneNumber+=_T("3");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton4() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("4"));
	else{
		m_PhoneNumber+=_T("4");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton5() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("5"));
	else{
		m_PhoneNumber+=_T("5");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton6() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("6"));
	else{
		m_PhoneNumber+=_T("6");	  
		 UpdateData(false);
	}
}
void CIaxphonevc6Dlg::OnButton7() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("7"));
	else{
		m_PhoneNumber+=_T("7");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton8() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("8"));
	else{
		m_PhoneNumber+=_T("8");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton9() 
{
    long selcall=-1;
	CString st;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("9"));
	else{
		m_PhoneNumber+=_T("9");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton10() 
{
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("*"));
	else{
		m_PhoneNumber+=_T("*");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton11() 
{
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("0"));
	else{
		m_PhoneNumber+=_T("0");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton12() 
{
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("#"));
	else{
		m_PhoneNumber+=_T("#");	  
		 UpdateData(false);
	}
}

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



iaxocxvc.jpg



These are some sample codes for using IAXOCX in VB.




void CIaxphonevc6Dlg::OnInit() 
{
	// TODO: Add your control notification handler code here
	if (!m_initphone){
		m_mvbphone.SetHostName(_T("demo.mvb2000.cn"));
		m_mvbphone.SetPort(7569);
		m_mvbphone.SetUserID(_T("6201"));
		m_mvbphone.SetPassword(_T("6201"));
		m_mvbphone.SetCodec(2);
		m_mvbphone.InitIAX(1);
		m_initphone=true;
	}
	
}

void CIaxphonevc6Dlg::OnRegister() 
{
	// TODO: Add your control notification handler code here
	if (m_initphone)
		m_mvbphone.Register();
	else
		AfxMessageBox(_T("请先开始服务!"));
}

void CIaxphonevc6Dlg::OnDial() 
{
	UpdateData(true);
	// TODO: Add your control notification handler code here
	if (!m_PhoneNumber.IsEmpty()){
		m_mvbphone.Dial(m_PhoneNumber);
	}else{
		CWnd* pwnd=GetDlgItem(IDC_NUM);
		pwnd->SetFocus();
		AfxMessageBox(_T("请输入电话号码!"));

	}


	
}

void CIaxphonevc6Dlg::OnUnregister() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.UnRegister();
	
}

void CIaxphonevc6Dlg::OnShutdown() 
{
	// TODO: Add your control notification handler code here
	if (m_initphone)
		m_mvbphone.Shutdown();
}

void CIaxphonevc6Dlg::OnDevice() 
{
	// TODO: Add your control notification handler code here
	m_edit_device.SetWindowText(_T(""));
	m_mvbphone.GetAudioDevice();
}

void CIaxphonevc6Dlg::OnAnswer() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.AcceptCall(0);
}

void CIaxphonevc6Dlg::OnHangup() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.HangUp();
	m_PhoneNumber.Empty();
	
}

void CIaxphonevc6Dlg::OnHold() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.Hold(0);
}

void CIaxphonevc6Dlg::OnUnhold() 
{
	// TODO: Add your control notification handler code here
	m_mvbphone.UnHold(0);
}

BEGIN_EVENTSINK_MAP(CIaxphonevc6Dlg, CDialog)
    //{{AFX_EVENTSINK_MAP(CIaxphonevc6Dlg)
	ON_EVENT(CIaxphonevc6Dlg, IDC_IAXOCX1, 7 /* Registration */, Iaxocx1_OnRegistration, VTS_I4 VTS_I4 VTS_I4 VTS_BSTR)
	ON_EVENT(CIaxphonevc6Dlg, IDC_IAXOCX1, 5 /* StateMessages */, Iaxocx1_OnStateMessages, VTS_I4 VTS_I4 VTS_BSTR)
	ON_EVENT(CIaxphonevc6Dlg, IDC_IAXOCX1, 2 /* AudioDevices */, Iaxocx1_OnAudioDevices, VTS_I4 VTS_BSTR VTS_BSTR VTS_BSTR)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CIaxphonevc6Dlg::Iaxocx1_OnRegistration(long RegID, long Reply, long msgCount, LPCTSTR ReplyText) 
{
	// TODO: Add your control notification handler code here
	CString sText;
	m_edit_event.GetWindowText(sText);
	sText=sText+_T("\r\n")+ReplyText;
	m_edit_event.SetWindowText(sText);

	
}

void CIaxphonevc6Dlg::Iaxocx1_OnStateMessages(long CallNo, long State, LPCTSTR Message) 
{
	// TODO: Add your control notification handler code here

	CString sText;
	m_edit_event.GetWindowText(sText);
	sText=sText+_T("\r\n")+Message;
	m_edit_event.SetWindowText(sText);
	
}

void CIaxphonevc6Dlg::Iaxocx1_OnAudioDevices(long DeviceID, LPCTSTR DeviceName, LPCTSTR DeviceType, LPCTSTR DeviceConfig) 
{
	// TODO: Add your control notification handler code here
	CString sText;
	m_edit_device.GetWindowText(sText);
	sText=sText+_T("\r\n")+DeviceName+_T("[")+DeviceType+_T("]")+_T("[")+DeviceConfig+_T("]");
	m_edit_device.SetWindowText(sText);

}

void CIaxphonevc6Dlg::OnButton1() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("1"));
	else{
		m_PhoneNumber+=_T("1");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton2() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("2"));
	else{
		m_PhoneNumber+=_T("2");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton3() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("3"));
	else{
		m_PhoneNumber+=_T("3");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton4() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("4"));
	else{
		m_PhoneNumber+=_T("4");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton5() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("5"));
	else{
		m_PhoneNumber+=_T("5");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton6() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("6"));
	else{
		m_PhoneNumber+=_T("6");	  
		 UpdateData(false);
	}
}
void CIaxphonevc6Dlg::OnButton7() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("7"));
	else{
		m_PhoneNumber+=_T("7");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton8() 
{
	// TODO: Add your control notification handler code here
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("8"));
	else{
		m_PhoneNumber+=_T("8");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton9() 
{
    long selcall=-1;
	CString st;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("9"));
	else{
		m_PhoneNumber+=_T("9");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton10() 
{
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("*"));
	else{
		m_PhoneNumber+=_T("*");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton11() 
{
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("0"));
	else{
		m_PhoneNumber+=_T("0");	  
		 UpdateData(false);
	}
}

void CIaxphonevc6Dlg::OnButton12() 
{
    long selcall=-1;
	selcall=m_mvbphone.GetSelectedCall();
	if (selcall>=0 && m_mvbphone.GetLineStateINT(selcall)>0)
		m_mvbphone.SendDTMF(_T("#"));
	else{
		m_PhoneNumber+=_T("#");	  
		 UpdateData(false);
	}
}

Created by: jalonljc, Last modification: Fri 04 of May, 2012 (18:43 UTC) by admin
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+