//---------------------------------------------------------------------------- // Laser Guard Ltd. // Copyright © 2000-2002. All Rights Reserved. // Version 1.0 01/01/2000 // Last modification: 08/10/2003 // PROJECT: // SUBSYSTEM: // FILE: PhoneEditDlg.cpp // AUTHOR: Sergey Chizhevskiy // OVERVIEW // ~~~~~~~~ // Source file of PhoneEditDlg.cpp //---------------------------------------------------------------------------- #include "stdafx.h" #include "PhoneEditDlg.h" #include #include "..\LgLib\Version.h" CPhoneEditDlg::CPhoneEditDlg() { m_pPhoneCommand = NULL; } CPhoneEditDlg::~CPhoneEditDlg() { Destroy(); } UINT CPhoneEditDlg::DoModal( CApplication* pApplication, HWND hParent, CPhoneCallCenter::PPHONE_COMMAND pPhoneCommand ) { HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE ); m_pPhoneCommand = pPhoneCommand; return CGenericWnd::DoModal( hInstance, (LPCTSTR)IDD_PHONE_EDIT_DLG, hParent ); } void CPhoneEditDlg::Destroy() { m_WavePlayer.ResetWave(); m_WaveFile.Destroy(); m_SpeechPlayer.ResetSpeech(); ::PlaySound( NULL, NULL, SND_PURGE ); CGenericWnd::DestroyWindow(); } LRESULT CPhoneEditDlg::OnDestroy( WPARAM, LPARAM ) { return 0; } LRESULT CPhoneEditDlg::OnInitDialog( WPARAM, LPARAM ) { // initialize combo box with availible modem names CLgModem modem; if( modem.Create() ) { for( DWORD i = 0; i < modem.GetDeviceCount(); i++ ) { TCHAR pModemName[MAX_PATH]; modem.GetDeviceName( i, pModemName, MAX_PATH ); SendDlgItemMessage( IDC_COMBO_MODEM, CB_ADDSTRING, 0, (LPARAM)pModemName ); } modem.Destroy(); } SendDlgItemMessage( IDC_COMBO_MODEM, CB_SETCURSEL, m_pPhoneCommand->nModem, 0 ); // set phone number ::SetWindowText( GetDlgItem(IDC_EDIT_NUMBER), m_pPhoneCommand->command.pPhoneNumber ); // set redial SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) ); SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneRedialCount, 0 ) ); // set dial time SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) ); SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDialTime / 1000UL, 0 ) ); // set drop time SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) ); SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDropTime / 1000UL, 0 ) ); // initialize voices CLgSpeechPlayer::EnumVoice( EnumVoiceProc, this ); // set welcome data SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)0, (SHORT)100 ) ); SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)-10, (SHORT)10 ) ); switch( m_pPhoneCommand->command.ePhoneWelcomeType ) { case CLgVoiceModemCallCenter::VOICE_TYPE_NONE: CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_NONE ); break; case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE: CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_WAVE ); ::SetWindowText( GetDlgItem(IDC_EDIT_WELCOME_WAVE), m_pPhoneCommand->command.pPhoneWelcomeData ); break; case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH: CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_TEXT2SPEECH ); ::SetWindowText( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneWelcomeData ); SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume ); SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate ); break; } // set message data SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)0, (SHORT)100 ) ); SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)-10, (SHORT)10 ) ); switch( m_pPhoneCommand->command.ePhoneMessageType ) { case CLgVoiceModemCallCenter::VOICE_TYPE_NONE: CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_NONE ); break; case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE: CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_WAVE ); ::SetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), m_pPhoneCommand->command.pPhoneMessageData ); break; case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH: CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_TEXT2SPEECH ); ::SetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneMessageData ); SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume ); SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneMessageText2SpeechRate ); break; } SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETRANGE, 0, MAKELONG( 10, 0 ) ); SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneMessageRepeatCount, 0 ) ); // init welcome test UINT dwWaveOutCount = waveOutGetNumDevs(); for( UINT i = 0; i < dwWaveOutCount; i++ ) { WAVEOUTCAPS WaveOutCaps; memset( &WaveOutCaps, 0, sizeof(WaveOutCaps) ); HRESULT hr = waveOutGetDevCaps( i, &WaveOutCaps, sizeof(WaveOutCaps) ); if( SUCCEEDED(hr) ) { INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_ADDSTRING, 0, (LPARAM)WaveOutCaps.szPname ); if( nIndex != CB_ERR ) { SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_SETITEMDATA, nIndex, (LPARAM)i ); } } } SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_SETCURSEL, 0, 0 ); // update dynamic OnRadioWelcome(); OnRadioMessage(); return TRUE; } LRESULT CPhoneEditDlg::OnCommand( WPARAM wParam, LPARAM ) { UINT nCtrlId = LOWORD( wParam ); switch( nCtrlId ) { case IDCANCEL: OnButtonCancel(); break; case IDC_RADIO_WELCOME_NONE: case IDC_RADIO_WELCOME_WAVE: case IDC_RADIO_WELCOME_TEXT2SPEECH: OnRadioWelcome(); break; case IDC_RADIO_MESSAGE_NONE: case IDC_RADIO_MESSAGE_WAVE: case IDC_RADIO_MESSAGE_TEXT2SPEECH: OnRadioMessage(); break; case IDOK: OnButtonOk(); break; case IDC_BUTTON_WELCOME_FILE: OnButtonWelcomeFile(); break; case IDC_BUTTON_WELCOME_TEST: OnButtonWelcomeTest(); break; case IDC_BUTTON_MESSAGE_FILE: OnButtonMessageFile(); break; case IDC_BUTTON_MESSAGE_TEST: OnButtonMessageTest(); break; default: if( HIWORD(wParam) == BN_CLICKED ) break; break; } return TRUE; } void CPhoneEditDlg::OnButtonCancel() { CGenericWnd::EndDialog( IDCANCEL ); } void CPhoneEditDlg::OnButtonOk() { // initialize combo box with availible modem names m_pPhoneCommand->nModem = SendDlgItemMessage( IDC_COMBO_MODEM, CB_GETCURSEL, 0, 0 ); // get phone number ::GetWindowText( GetDlgItem(IDC_EDIT_NUMBER), m_pPhoneCommand->command.pPhoneNumber, sizeof(m_pPhoneCommand->command.pPhoneNumber) ); // get redial m_pPhoneCommand->command.nPhoneRedialCount = SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_GETPOS, 0, 0 ); // get dial time m_pPhoneCommand->command.dwPhoneDialTime = SendDlgItemMessage( IDC_SPIN_TIME, UDM_GETPOS, 0, 0 ) * 1000UL; // get drop time m_pPhoneCommand->command.dwPhoneDropTime = SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_GETPOS, 0, 0 ) * 1000UL; // get welcome data if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) ) m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE; else if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) ) { m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE; ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_WAVE), m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) ); } else if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) ) { m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH; ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) ); INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETCURSEL, 0, 0 ); LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETITEMDATA, nIndex, 0 ); wcscpy( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pVoice ); m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume = SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_GETPOS, 0, 0 ); m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate = SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_GETPOS, 0, 0 ); } // set message data if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) ) m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE; else if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) ) { m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE; ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) ); } else if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) ) { m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH; ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) ); INT nIndex = SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETCURSEL, 0, 0 ); LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETITEMDATA, nIndex, 0 ); wcscpy( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pVoice ); m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume = SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_GETPOS, 0, 0 ); m_pPhoneCommand->command.nPhoneMessageText2SpeechRate = SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_GETPOS, 0, 0 ); } m_pPhoneCommand->command.nPhoneMessageRepeatCount = SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_GETPOS, 0, 0 ); CGenericWnd::EndDialog( IDOK ); } void CPhoneEditDlg::OnRadioWelcome() { if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) ) { ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_WAVE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_FILE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_TEST), FALSE ); ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_VOLUME), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_RATE), FALSE ); ::EnableWindow( GetDlgItem(IDC_COMBO_WELCOME_VOICE), FALSE ); } else if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) ) { ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_WAVE), TRUE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_FILE), TRUE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_TEST), TRUE ); ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_VOLUME), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_RATE), FALSE ); ::EnableWindow( GetDlgItem(IDC_COMBO_WELCOME_VOICE), FALSE ); } else if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) ) { ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_WAVE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_FILE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_TEST), TRUE ); ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), TRUE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_VOLUME), TRUE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_RATE), TRUE ); ::EnableWindow( GetDlgItem(IDC_COMBO_WELCOME_VOICE), TRUE ); } } void CPhoneEditDlg::OnRadioMessage() { if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) ) { ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_FILE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_TEST), FALSE ); ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_VOLUME), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_RATE), FALSE ); ::EnableWindow( GetDlgItem(IDC_COMBO_MESSAGE_VOICE), FALSE ); } else if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) ) { ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), TRUE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_FILE), TRUE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_TEST), TRUE ); ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_VOLUME), FALSE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_RATE), FALSE ); ::EnableWindow( GetDlgItem(IDC_COMBO_MESSAGE_VOICE), FALSE ); } else if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) ) { ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_FILE), FALSE ); ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_TEST), TRUE ); ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), TRUE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_VOLUME), TRUE ); ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_RATE), TRUE ); ::EnableWindow( GetDlgItem(IDC_COMBO_MESSAGE_VOICE), TRUE ); } } void CPhoneEditDlg::OnButtonWelcomeFile() { TCHAR pFileName[MAX_PATH] = {0}; TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0"); OPENFILENAME OpenFileName; memset( &OpenFileName, 0, sizeof(OpenFileName) ); // OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400; OpenFileName.hwndOwner = GetSafeHwnd(); OpenFileName.hInstance = NULL; OpenFileName.lpstrFilter = pFilter; OpenFileName.lpstrCustomFilter = NULL; OpenFileName.nMaxCustFilter = 0; OpenFileName.nFilterIndex = 1; OpenFileName.lpstrFile = pFileName; OpenFileName.nMaxFile = MAX_PATH; OpenFileName.lpstrFileTitle = NULL; OpenFileName.nMaxFileTitle = 0; OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = NULL; OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; if( !::GetOpenFileName( &OpenFileName ) ) { DWORD dwError = ::CommDlgExtendedError(); if( dwError ) LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::OnButtonMessageFile"), _T("GetOpenFileName returns %d"), dwError ); return; } ::SetWindowText( GetDlgItem( IDC_EDIT_WELCOME_WAVE ), OpenFileName.lpstrFile ); } void CPhoneEditDlg::OnButtonMessageFile() { TCHAR pFileName[MAX_PATH] = {0}; TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0"); OPENFILENAME OpenFileName; memset( &OpenFileName, 0, sizeof(OpenFileName) ); // OpenFileName.lStructSize = sizeof(OPENFILENAME); OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400; OpenFileName.hwndOwner = GetSafeHwnd(); OpenFileName.hInstance = NULL; OpenFileName.lpstrFilter = pFilter; OpenFileName.lpstrCustomFilter = NULL; OpenFileName.nMaxCustFilter = 0; OpenFileName.nFilterIndex = 1; OpenFileName.lpstrFile = pFileName; OpenFileName.nMaxFile = MAX_PATH; OpenFileName.lpstrFileTitle = NULL; OpenFileName.nMaxFileTitle = 0; OpenFileName.lpstrInitialDir = NULL; OpenFileName.lpstrTitle = NULL; OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST; if( !::GetOpenFileName( &OpenFileName ) ) { DWORD dwError = ::CommDlgExtendedError(); if( dwError ) LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::OnButtonMessageFile"), _T("GetOpenFileName returns %d"), dwError ); return; } ::SetWindowText( GetDlgItem( IDC_EDIT_MESSAGE_WAVE ), OpenFileName.lpstrFile ); } void CPhoneEditDlg::OnButtonWelcomeTest() { // get welcome data if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) ) { LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonWelcomeTest"), _T("Unexpected situation (state=NONE)") ); return; } UINT dwWaveOutDevice = WAVE_MAPPER; // INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETCURSEL, 0, 0 ); // if( nIndex != CB_ERR ) // { // dwWaveOutDevice = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETITEMDATA, nIndex, 0 ); // } if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) ) { // get file name TCHAR pFileName[MAX_PATH] = {0}; ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_WAVE), pFileName, MAX_PATH ); // stop previous wave // m_WavePlayer.ResetWave(); ::PlaySound( NULL, NULL, SND_PURGE ); // stop previous speech m_SpeechPlayer.ResetSpeech(); // // load file // if( m_WaveFile.Load( pFileName ) ) // { // // play file // m_WavePlayer.PlayWave( &m_WaveFile, dwWaveOutDevice ); // } ::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC ); } else if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) ) { // get file name TCHAR pText[MAX_PATH] = {0}; ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), pText, MAX_PATH ); // stop previous wave // m_WavePlayer.ResetWave(); ::PlaySound( NULL, NULL, SND_PURGE ); // stop previous speech m_SpeechPlayer.ResetSpeech(); // get voice id INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETCURSEL, 0, 0 ); LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETITEMDATA, nIndex, 0 ); // play text m_SpeechPlayer.PlaySpeech( pText, dwWaveOutDevice, SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_GETPOS, 0, 0 ), SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_GETPOS, 0, 0 ), pVoice ); } } void CPhoneEditDlg::OnButtonMessageTest() { // get welcome data if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) ) { LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonMessageTest"), _T("Unexpected situation (state=NONE)") ); return; } UINT dwWaveOutDevice = WAVE_MAPPER; // INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETCURSEL, 0, 0 ); // if( nIndex != CB_ERR ) // { // dwWaveOutDevice = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETITEMDATA, nIndex, 0 ); // } if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) ) { // get file name TCHAR pFileName[MAX_PATH] = {0}; ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), pFileName, MAX_PATH ); // stop previous wave // m_WavePlayer.ResetWave(); ::PlaySound( NULL, NULL, SND_PURGE ); // stop previous speech m_SpeechPlayer.ResetSpeech(); // // load file // if( m_WaveFile.Load( pFileName ) ) // { // // play file // m_WavePlayer.PlayWave( &m_WaveFile, dwWaveOutDevice ); // } ::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC ); } else if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) ) { // get file name TCHAR pText[MAX_PATH] = {0}; ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), pText, MAX_PATH ); // stop previous wave // m_WavePlayer.ResetWave(); ::PlaySound( NULL, NULL, SND_PURGE ); // stop previous speech m_SpeechPlayer.ResetSpeech(); // get voice id INT nIndex = SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETCURSEL, 0, 0 ); LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETITEMDATA, nIndex, 0 ); // play text m_SpeechPlayer.PlaySpeech( pText, dwWaveOutDevice, SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_GETPOS, 0, 0 ), SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_GETPOS, 0, 0 ), pVoice ); } } BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId, void* pParam ) { CPhoneEditDlg *pThis = (CPhoneEditDlg*) pParam; return pThis->EnumVoiceProc( pDescription, pId ); } BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId ) { INT nIndex; LPWSTR pCopyId; nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_ADDSTRING, 0, (LONG)pDescription ); pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) ); if( pCopyId ) wcscpy( pCopyId, pId ); SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_SETITEMDATA, nIndex, (DWORD)pCopyId ); if( !wcscmp( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pCopyId ) ) SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_SETCURSEL, nIndex, 0 ); nIndex = SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_ADDSTRING, 0, (LONG)pDescription ); pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) ); if( pCopyId ) wcscpy( pCopyId, pId ); SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_SETITEMDATA, nIndex, (DWORD)pCopyId ); if( !wcscmp( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pCopyId ) ) SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_SETCURSEL, nIndex, 0 ); return TRUE; }