⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vcdemo_prodlg.cpp

📁 VoiceAngel,很好的控件,VC源码
💻 CPP
📖 第 1 页 / 共 3 页
字号:

	CString s1,s2,s3;
	s2=13;s3=10;
	s2=s2+s3;

    m_edtMsg.GetWindowText(s1);
	if (strlen(s1)!=0)
    	s1=s1+s2;
	s1=s1+msg;
    m_edtMsg.SetWindowText(s1);
	m_edtMsg.SetSel(s1.GetLength(),-1);

}

void CVcDemo_proDlg::OnOptLine() 
{
	// TODO: Add your control notification handler code here
	m_Device=0; //play or record through the line
   
}

void CVcDemo_proDlg::OnOptSndcard() 
{
	// TODO: Add your control notification handler code here
	m_Device=1;
    m_btnPlay.EnableWindow();
	m_btnRecord.EnableWindow();
}




void CVcDemo_proDlg::OnPlayDoneAngel(long LineIndex) 
{
	// TODO: Add your control notification handler code here
	ShowMsg("Played!");
    m_btnPlay.EnableWindow(true);
	m_btnStop.EnableWindow(false);
	m_btnRecord.EnableWindow(true);
	KillTimer(m_dwTimer);
	m_bar.SetPos(0);
	UpdateControls();
}

void CVcDemo_proDlg::OnBtnStop() 
{
   m_Va.SetCurrentLineIndex(CurLineIndex);

	m_Va.Stop(); //Stop playing or recording.
    m_Va.CloseWaveFile();
    m_bar.SetPos(0);
    KillTimer(m_dwTimer);
    if (m_Va.GetErrorNumber()!=0)
      ShowMsg(m_Va.GetErrorDescribe())  ;
	UpdateControls();

}

void CVcDemo_proDlg::OnChangeEdtTelnum() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CDialog::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
		UpdateData(true);
    	if(m_TelNum.GetLength()>0 )
			m_btnDial.EnableWindow(true);
		else
			m_btnDial.EnableWindow(false);

}

void CVcDemo_proDlg::OnCkSpeakerphone() 
{
	// TODO: Add your control notification handler code here
	if(m_ckSpeakerphone.GetCheck()==1)
	   m_Va.EnableSpeakerPhone(true);
	else
	   m_Va.EnableSpeakerPhone(false);	 
}

void CVcDemo_proDlg::OnCkMonitorSilence() 
{
	// TODO: Add your control notification handler code here

	UpdateData(true);
	m_Va.MonitorSilence(m_tmSilence,60000);

}

void CVcDemo_proDlg::OnCkMonitorDigits() 
{
	// TODO: Add your control notification handler code here
   if( m_ckMonitorDigit.GetCheck()==1)
	m_Va.MonitorDigit(true);
   else
	m_Va.MonitorDigit(false);
}

void CVcDemo_proDlg::OnDigitDetectedAngel(long LineIndex, LPCTSTR Digit) 
{
	// TODO: Add your control notification handler code here
	CString s="Digit ";
	s+=Digit;
	s+=" detected!";
	ShowMsg(s);
}

void CVcDemo_proDlg::OnBtnGatherDigits() 
{
	m_Va.SetCurrentLineIndex(CurLineIndex);
	UpdateData(true);
	m_Va.GatherDigits(m_DigitCount,m_EndDigit.GetBuffer(1),m_FirstTimeout,m_InterTimeout);
   
}

void CVcDemo_proDlg::OnDigitsGatheredAngel(long LineIndex, LPCTSTR Digits, long Result) 
{
	// TODO: Add your control notification handler code here
	CString s="Digits Gathered:";
	s=s+Digits;
	ShowMsg(s);
}

void CVcDemo_proDlg::OnSilenceAngel(long LineIndex) 
{
	// TODO: Add your control notification handler code here
	ShowMsg("Silence detected!");UpdateControls();
}


void CVcDemo_proDlg::OnBtnSendfax() 
{   
 /***********************Fax documents supported**************************************************
 can be TIFF Group III(T.4), TIFF Group IV(T.6) file, .doc or .xls file.
	TIFF Group III(T.4), TIFF Group IV(T.6) files can be used by voiceangel directly. With the help of DocToTiff ocx control,
	Microsoft office files (.doc or .xls file) can be converted to T.6 tiff files. It can continue to
	convert the T.6 tiff file to T.4 file. 
	T.4 file is used in common mode, T.6 file is needed in ECM(Error Correct Mode)
	ECM mode give more check on error duration the fax session. But it is much more slower. 
	Some modems do not support ECM mode at all.
 To use DocToTiff, you should
1.Use Win2k , XP or Later edition of windows.
2.Set up the fax printer in the system.
3.Have Microsoft office installed.
DocToTiff run word or excel in background and print the document into a tif(T.6) file.
**************************Device Supprted***************************************************
	Fax modems only
**************************When can I send fax***********************************************
It can work in two case:

1. Send the fax directly when the line is IDLE.
  In this case, call SendFax directly without calling Dial method. VoiceAngel will dial the number and then give a fax tone immediately, and the fax session start.

2. Send fax in a connected call.
  In this case, a connected call has existed, after Answer or Dial has been called. The telNumber parameter is ignored and the call is switched from voice mode to fax mode.
******************************************************************************************/


	 m_Va.SetCurrentLineIndex(CurLineIndex);
	 CString file;
	 m_edtFaxDoc.GetWindowText(file);
	 file.MakeLower();
     
	 if(file.Find(".doc")!=-1 || file.Find(".xls")!=-1)
	 { m_docToTif.OpenDoc(file);
       
       m_docToTif.ConvertToTiff("convertedT6.tif");
	   if(m_docToTif.ErrorNumber())
	   {   ShowMsg(m_docToTif.ErrorDescribe());
		    return;
	   }
       file="convertedT6.tif";
	   if(!m_ckECM.GetCheck())
       {   m_docToTif.T6toT4("convertedT6.tif","convertedT4.tif",false,false);
	       if(m_docToTif.ErrorNumber())
		   {   ShowMsg(m_docToTif.ErrorDescribe());
		       return;
		   }
	       file="convertedT4.tif";
	   }

	 }
     

 //If a voice call already connected,the telNumber pamameter should be set "",because it needn't dial the telephone number.
	CString sLogfile;
	sLogfile.Format("faxlog%d.txt",CurLineIndex);
	if (m_Va.GetLineStatus()==LINE_STATUS_CONNECTED)
		m_Va.SendFax( file.GetBuffer(40),"","Your Local ID",sLogfile.GetBuffer(40));
	else if(m_Va.GetLineStatus()==LINE_STATUS_IDLE)
	{   CString sTel;
	    m_edtFaxNum.GetWindowText(sTel);
		sTel.TrimLeft();sTel.TrimRight();
		if (sTel=="")
		{ MessageBox("Please input the telphone number.");
		  return;
		}
		m_Va.SendFax(file.GetBuffer(40),sTel.GetBuffer(10),"Your Local ID", sLogfile.GetBuffer(40));	
		
	}
	if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
    UpdateControls();
    
}

void CVcDemo_proDlg::OnBtnReceivefax() 
{  /*******************Documents supported**********************************************
   VoiceAngel write the received data into a Tiff TIFF Group III(T.4) or TIFF Group IV(T.6) file.
   If the fax is received in ECM(Error Correct Mode), it use T.6 file, else it use T.4 file.
  ********************Device Supported***************************************************** 
	 The Method ReceiveFax can only be called on the line which is a voice fax modem.
  ********************When can I receive a fax********************************************
It can work in two case:
1. Receive the fax directly when the line is ringing.
  In this case, the call is not in Connected status. The modem directly answers with a fax tone and start the fax session.
2. Receive fax in a connected call.
  In this case, a connected call has existed, after Answer or Dial has been called. The call is switched from voice mode to fax mode and the fax session start.
****************************************************************************************/
	CString sLogfile;
	sLogfile.Format("faxlog%d",CurLineIndex);
	m_Va.SetCurrentLineIndex(CurLineIndex);
	m_Va.ReceiveFax("FaxReceived.tif",false,false,false,"Your Local ID",sLogfile.GetBuffer(40));
	if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
		UpdateControls();

}

void CVcDemo_proDlg::OnSelchangeCmbLines() 
{
	// TODO: Add your control notification handler code here

	CurLineIndex=m_cmbLines.GetCurSel()-1;
	m_Va.SetCurrentLineIndex(CurLineIndex);
	if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
	m_Va.SetLineForShowWave(CurLineIndex);
    

	ShowMsg("Available BearerModes:");
    DWORD dwBearerMode=m_Va.GetAvailableBearerModes();
	if(dwBearerMode&LINEBEARERMODE_VOICE ) ShowMsg("LINEBEARERMODE_VOICE ");
	if(dwBearerMode&LINEBEARERMODE_SPEECH ) ShowMsg("LINEBEARERMODE_SPEECH ");
	if(dwBearerMode&LINEBEARERMODE_MULTIUSE) ShowMsg("LINEBEARERMODE_MULTIUSE");
	if(dwBearerMode&LINEBEARERMODE_DATA ) ShowMsg("LINEBEARERMODE_DATA ");
	if(dwBearerMode&LINEBEARERMODE_ALTSPEECHDATA  ) ShowMsg("LINEBEARERMODE_ALTSPEECHDATA ");
	if(dwBearerMode&LINEBEARERMODE_NONCALLSIGNALING  ) ShowMsg("LINEBEARERMODE_NONCALLSIGNALING ");
	if(dwBearerMode&LINEBEARERMODE_PASSTHROUGH  ) ShowMsg("LINEBEARERMODE_PASSTHROUGH ");
	if(dwBearerMode&LINEBEARERMODE_RESTRICTEDDATA  ) ShowMsg("LINEBEARERMODE_RESTRICTEDDATA ");
   

	ShowMsg("Available MediaModes:");
	DWORD dwMediaMode=m_Va.GetAvailableMediaModes();
	if(dwMediaMode& LINEMEDIAMODE_UNKNOWN  ) ShowMsg("LINEMEDIAMODE_UNKNOWN");
	if(dwMediaMode& LINEMEDIAMODE_INTERACTIVEVOICE) ShowMsg("LINEMEDIAMODE_INTERACTIVEVOICE");
 	if(dwMediaMode& LINEMEDIAMODE_AUTOMATEDVOICE ) ShowMsg("LINEMEDIAMODE_AUTOMATEDVOICE");
   	if(dwMediaMode& LINEMEDIAMODE_DATAMODEM ) ShowMsg("LINEMEDIAMODE_DATAMODEM");
	if(dwMediaMode& LINEMEDIAMODE_G3FAX) ShowMsg("LINEMEDIAMODE_G3FAX");
	if(dwMediaMode& LINEMEDIAMODE_TDD) ShowMsg("LINEMEDIAMODE_TDD");
	if(dwMediaMode& LINEMEDIAMODE_G4FAX ) ShowMsg("LINEMEDIAMODE_G4FAX");
	if(dwMediaMode& LINEMEDIAMODE_DIGITALDATA ) ShowMsg("LINEMEDIAMODE_DIGITALDATA ");
	if(dwMediaMode& LINEMEDIAMODE_TELETEX ) ShowMsg("LINEMEDIAMODE_TELETEX");
	if(dwMediaMode& LINEMEDIAMODE_VIDEOTEX ) ShowMsg("LINEMEDIAMODE_VIDEOTEX ");
	if(dwMediaMode& LINEMEDIAMODE_TELEX ) ShowMsg("LINEMEDIAMODE_TELEX ");
	if(dwMediaMode& LINEMEDIAMODE_MIXED  ) ShowMsg("LINEMEDIAMODE_MIXED ");
	if(dwMediaMode& LINEMEDIAMODE_ADSI ) ShowMsg("LINEMEDIAMODE_ADSI ");
	if(dwMediaMode& LINEMEDIAMODE_VOICEVIEW  ) ShowMsg("LINEMEDIAMODE_VOICEVIEW ");

    //m_Va.SetBearerMode(the bearer mode you observed);
	//m_Va.SetMediaMode(the media mode you observed);
     CString msg;
	 if(m_Va.GetLineType()==LINE_TYPE_SOUND_CARD)
	 {ShowMsg("Sound card selected.");}
	 else if(m_Va.GetLineStatus()==LINE_STATUS_CLOSED)
	 {	 m_Va.Open();
	     if (m_Va.GetErrorNumber()) ShowMsg(m_Va.GetErrorDescribe());
		 else 
		 {	 
			 msg.Format("Line %d opened.",CurLineIndex);
			 ShowMsg(msg);
		 }
	 }
	 else
	 {msg.Format("Line %d selected.",CurLineIndex);ShowMsg(msg);}

	
	m_ckAnalyzeRingBackTone.SetCheck(false);
	switch (m_Va.GetLineType() )
      {case 0:
          ShowMsg("Unknown line type");
	       break;
       case 1:
       ShowMsg("Line Type:Data Modem");
       break;
       case 2:
         ShowMsg("Line Type:Voice Modem"); 
	     m_ckAnalyzeRingBackTone.SetCheck(true);
	     break;
       case 3:
          ShowMsg("Line Type:Voice board port");
          if(m_Va.GetPlayBufferSize()==8192 && m_Va.GetRecordBufferSize()==3200)
             ShowMsg("The Buffer Size is the default value, for quick response, please configure the Receive Buffer Threshold of the wave driver to 1024, and set PlayBufferSize, RecordBufferSize both to 1024.") ;
          break;
       case 4:
          ShowMsg("Line Type:PBX port");
          break;
       case 5:

          //ShowMsg("Line Type:Sound Card");

          break;
    }
	if(IsWindow(DlgSpeech.m_hWnd))
	{DlgSpeech.LoadSpeech();}
	UpdateControls();
}

void CVcDemo_proDlg::OnBtnCancelfax() 
{
 	m_Va.SetCurrentLineIndex(CurLineIndex);
	 m_btnCancelFax.EnableWindow(false);
	 m_Va.CancelFax();
	if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
	m_Va.Drop();
   	if (m_Va.GetErrorNumber()!=0) ShowMsg(m_Va.GetErrorDescribe());
   	UpdateControls();
}


void CVcDemo_proDlg::OnOptRecorded() 
{
	// TODO: Add your control notification handler code here
	m_sWaveFile="Recorded.wav";
}

void CVcDemo_proDlg::OnOptMultiFiles() 
{
	// TODO: Add your control notification handler code here
	m_sWaveFile="MergedFiles.wav";
}

void CVcDemo_proDlg::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	
	CDialog::OnTimer(nIDEvent);
	if (m_Va.GetWaveFileLen() == m_Va.GetWaveFilePos())
      m_bar.SetRangeMax(m_Va.GetWaveFileLen() / 1024) ;
    m_bar.SetPos(m_Va.GetWaveFilePos()/1024);

}

void CVcDemo_proDlg::OnBtnTransferSettings() 
{
	// TODO: Add your control notification handler code here
	DlgTranSet.DoModal();
}

void CVcDemo_proDlg::OnBtnStartTransfer() 
{
	m_Va.SetCurrentLineIndex(CurLineIndex);
    CString num; CString WaveFileToRecordRingBackTone;
	m_edtNumToTransfer.GetWindowText(num);
	m_edtWaveFileToRecordRingBackTone.GetWindowText(WaveFileToRecordRingBackTone);
    m_Va.StartTransfer( num,30, m_ckAnalyzeRingBackTone.GetCheck(),WaveFileToRecordRingBackTone.GetBuffer(30),DlgTranSet.m_sHookFlash );
 	UpdateControls();
    
}

void CVcDemo_proDlg::OnBtnCompleteTransfer() 
{
	m_Va.SetCurrentLineIndex(CurLineIndex);

	m_Va.CompleteTransfer(DlgTranSet.m_TransferCompleteMode,DlgTranSet.m_sCompleteTransfer );

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -