Old fashion design for PC-104
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

577 lines
21 KiB

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: PhoneEditDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PhoneEditDlg.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "PhoneEditDlg.h"
  16. #include <cderr.h>
  17. #include "..\LgLib\Version.h"
  18. CPhoneEditDlg::CPhoneEditDlg()
  19. {
  20. m_pPhoneCommand = NULL;
  21. }
  22. CPhoneEditDlg::~CPhoneEditDlg()
  23. {
  24. Destroy();
  25. }
  26. UINT CPhoneEditDlg::DoModal( CApplication* pApplication, HWND hParent, CPhoneCallCenter::PPHONE_COMMAND pPhoneCommand )
  27. {
  28. HINSTANCE hInstance = (HINSTANCE)::GetWindowLong( hParent, GWL_HINSTANCE );
  29. m_pPhoneCommand = pPhoneCommand;
  30. return CGenericWnd::DoModal( hInstance, (LPCTSTR)IDD_PHONE_EDIT_DLG, hParent );
  31. }
  32. void CPhoneEditDlg::Destroy()
  33. {
  34. m_WavePlayer.ResetWave();
  35. m_WaveFile.Destroy();
  36. m_SpeechPlayer.ResetSpeech();
  37. ::PlaySound( NULL, NULL, SND_PURGE );
  38. CGenericWnd::DestroyWindow();
  39. }
  40. LRESULT CPhoneEditDlg::OnDestroy( WPARAM, LPARAM )
  41. {
  42. return 0;
  43. }
  44. LRESULT CPhoneEditDlg::OnInitDialog( WPARAM, LPARAM )
  45. {
  46. // initialize combo box with availible modem names
  47. CLgModem modem;
  48. if( modem.Create() )
  49. {
  50. for( DWORD i = 0; i < modem.GetDeviceCount(); i++ )
  51. {
  52. TCHAR pModemName[MAX_PATH];
  53. modem.GetDeviceName( i, pModemName, MAX_PATH );
  54. SendDlgItemMessage( IDC_COMBO_MODEM, CB_ADDSTRING, 0, (LPARAM)pModemName );
  55. }
  56. modem.Destroy();
  57. }
  58. SendDlgItemMessage( IDC_COMBO_MODEM, CB_SETCURSEL, m_pPhoneCommand->nModem, 0 );
  59. // set phone number
  60. ::SetWindowText( GetDlgItem(IDC_EDIT_NUMBER), m_pPhoneCommand->command.pPhoneNumber );
  61. // set redial
  62. SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
  63. SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneRedialCount, 0 ) );
  64. // set dial time
  65. SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
  66. SendDlgItemMessage( IDC_SPIN_TIME, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDialTime / 1000UL, 0 ) );
  67. // set drop time
  68. SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETRANGE, 0, MAKELONG( 30000, 0 ) );
  69. SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.dwPhoneDropTime / 1000UL, 0 ) );
  70. // initialize voices
  71. CLgSpeechPlayer::EnumVoice( EnumVoiceProc, this );
  72. // set welcome data
  73. SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)0, (SHORT)100 ) );
  74. SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)-10, (SHORT)10 ) );
  75. switch( m_pPhoneCommand->command.ePhoneWelcomeType )
  76. {
  77. case CLgVoiceModemCallCenter::VOICE_TYPE_NONE:
  78. CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_NONE );
  79. break;
  80. case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE:
  81. CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_WAVE );
  82. ::SetWindowText( GetDlgItem(IDC_EDIT_WELCOME_WAVE), m_pPhoneCommand->command.pPhoneWelcomeData );
  83. break;
  84. case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH:
  85. CheckRadioButton( IDC_RADIO_WELCOME_NONE, IDC_RADIO_WELCOME_TEXT2SPEECH, IDC_RADIO_WELCOME_TEXT2SPEECH );
  86. ::SetWindowText( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneWelcomeData );
  87. SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume );
  88. SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate );
  89. break;
  90. }
  91. // set message data
  92. SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)0, (SHORT)100 ) );
  93. SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_SETRANGE, TRUE, (LPARAM)MAKELONG( (SHORT)-10, (SHORT)10 ) );
  94. switch( m_pPhoneCommand->command.ePhoneMessageType )
  95. {
  96. case CLgVoiceModemCallCenter::VOICE_TYPE_NONE:
  97. CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_NONE );
  98. break;
  99. case CLgVoiceModemCallCenter::VOICE_TYPE_WAVE:
  100. CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_WAVE );
  101. ::SetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), m_pPhoneCommand->command.pPhoneMessageData );
  102. break;
  103. case CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH:
  104. CheckRadioButton( IDC_RADIO_MESSAGE_NONE, IDC_RADIO_MESSAGE_TEXT2SPEECH, IDC_RADIO_MESSAGE_TEXT2SPEECH );
  105. ::SetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneMessageData );
  106. SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume );
  107. SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_SETPOS, TRUE, m_pPhoneCommand->command.nPhoneMessageText2SpeechRate );
  108. break;
  109. }
  110. SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETRANGE, 0, MAKELONG( 10, 0 ) );
  111. SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_SETPOS, 0, MAKELONG( m_pPhoneCommand->command.nPhoneMessageRepeatCount, 0 ) );
  112. // init welcome test
  113. UINT dwWaveOutCount = waveOutGetNumDevs();
  114. for( UINT i = 0; i < dwWaveOutCount; i++ )
  115. {
  116. WAVEOUTCAPS WaveOutCaps;
  117. memset( &WaveOutCaps, 0, sizeof(WaveOutCaps) );
  118. HRESULT hr = waveOutGetDevCaps( i, &WaveOutCaps, sizeof(WaveOutCaps) );
  119. if( SUCCEEDED(hr) )
  120. {
  121. INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_ADDSTRING, 0, (LPARAM)WaveOutCaps.szPname );
  122. if( nIndex != CB_ERR )
  123. {
  124. SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_SETITEMDATA, nIndex, (LPARAM)i );
  125. }
  126. }
  127. }
  128. SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_SETCURSEL, 0, 0 );
  129. // update dynamic
  130. OnRadioWelcome();
  131. OnRadioMessage();
  132. return TRUE;
  133. }
  134. LRESULT CPhoneEditDlg::OnCommand( WPARAM wParam, LPARAM )
  135. {
  136. UINT nCtrlId = LOWORD( wParam );
  137. switch( nCtrlId )
  138. {
  139. case IDCANCEL:
  140. OnButtonCancel();
  141. break;
  142. case IDC_RADIO_WELCOME_NONE:
  143. case IDC_RADIO_WELCOME_WAVE:
  144. case IDC_RADIO_WELCOME_TEXT2SPEECH:
  145. OnRadioWelcome();
  146. break;
  147. case IDC_RADIO_MESSAGE_NONE:
  148. case IDC_RADIO_MESSAGE_WAVE:
  149. case IDC_RADIO_MESSAGE_TEXT2SPEECH:
  150. OnRadioMessage();
  151. break;
  152. case IDOK:
  153. OnButtonOk();
  154. break;
  155. case IDC_BUTTON_WELCOME_FILE:
  156. OnButtonWelcomeFile();
  157. break;
  158. case IDC_BUTTON_WELCOME_TEST:
  159. OnButtonWelcomeTest();
  160. break;
  161. case IDC_BUTTON_MESSAGE_FILE:
  162. OnButtonMessageFile();
  163. break;
  164. case IDC_BUTTON_MESSAGE_TEST:
  165. OnButtonMessageTest();
  166. break;
  167. default:
  168. if( HIWORD(wParam) == BN_CLICKED )
  169. break;
  170. break;
  171. }
  172. return TRUE;
  173. }
  174. void CPhoneEditDlg::OnButtonCancel()
  175. {
  176. CGenericWnd::EndDialog( IDCANCEL );
  177. }
  178. void CPhoneEditDlg::OnButtonOk()
  179. {
  180. // initialize combo box with availible modem names
  181. m_pPhoneCommand->nModem = SendDlgItemMessage( IDC_COMBO_MODEM, CB_GETCURSEL, 0, 0 );
  182. // get phone number
  183. ::GetWindowText( GetDlgItem(IDC_EDIT_NUMBER), m_pPhoneCommand->command.pPhoneNumber, sizeof(m_pPhoneCommand->command.pPhoneNumber) );
  184. // get redial
  185. m_pPhoneCommand->command.nPhoneRedialCount = SendDlgItemMessage( IDC_SPIN_REDIAL, UDM_GETPOS, 0, 0 );
  186. // get dial time
  187. m_pPhoneCommand->command.dwPhoneDialTime = SendDlgItemMessage( IDC_SPIN_TIME, UDM_GETPOS, 0, 0 ) * 1000UL;
  188. // get drop time
  189. m_pPhoneCommand->command.dwPhoneDropTime = SendDlgItemMessage( IDC_SPIN_PAUSE, UDM_GETPOS, 0, 0 ) * 1000UL;
  190. // get welcome data
  191. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
  192. m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE;
  193. else
  194. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
  195. {
  196. m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE;
  197. ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_WAVE), m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) );
  198. }
  199. else
  200. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
  201. {
  202. m_pPhoneCommand->command.ePhoneWelcomeType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH;
  203. ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneWelcomeData, sizeof(m_pPhoneCommand->command.pPhoneWelcomeData) );
  204. INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETCURSEL, 0, 0 );
  205. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETITEMDATA, nIndex, 0 );
  206. wcscpy( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pVoice );
  207. m_pPhoneCommand->command.nPhoneWelcomeText2SpeechVolume = SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_GETPOS, 0, 0 );
  208. m_pPhoneCommand->command.nPhoneWelcomeText2SpeechRate = SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_GETPOS, 0, 0 );
  209. }
  210. // set message data
  211. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
  212. m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_NONE;
  213. else
  214. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
  215. {
  216. m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_WAVE;
  217. ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) );
  218. }
  219. else
  220. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
  221. {
  222. m_pPhoneCommand->command.ePhoneMessageType = CLgVoiceModemCallCenter::VOICE_TYPE_TEXT2SPEECH;
  223. ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), m_pPhoneCommand->command.pPhoneMessageData, sizeof(m_pPhoneCommand->command.pPhoneMessageData) );
  224. INT nIndex = SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETCURSEL, 0, 0 );
  225. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETITEMDATA, nIndex, 0 );
  226. wcscpy( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pVoice );
  227. m_pPhoneCommand->command.nPhoneMessageText2SpeechVolume = SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_GETPOS, 0, 0 );
  228. m_pPhoneCommand->command.nPhoneMessageText2SpeechRate = SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_GETPOS, 0, 0 );
  229. }
  230. m_pPhoneCommand->command.nPhoneMessageRepeatCount = SendDlgItemMessage( IDC_SPIN_REPEAT, UDM_GETPOS, 0, 0 );
  231. CGenericWnd::EndDialog( IDOK );
  232. }
  233. void CPhoneEditDlg::OnRadioWelcome()
  234. {
  235. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
  236. {
  237. ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_WAVE), FALSE );
  238. ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_FILE), FALSE );
  239. ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_TEST), FALSE );
  240. ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), FALSE );
  241. ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_VOLUME), FALSE );
  242. ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_RATE), FALSE );
  243. ::EnableWindow( GetDlgItem(IDC_COMBO_WELCOME_VOICE), FALSE );
  244. }
  245. else
  246. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
  247. {
  248. ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_WAVE), TRUE );
  249. ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_FILE), TRUE );
  250. ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_TEST), TRUE );
  251. ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), FALSE );
  252. ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_VOLUME), FALSE );
  253. ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_RATE), FALSE );
  254. ::EnableWindow( GetDlgItem(IDC_COMBO_WELCOME_VOICE), FALSE );
  255. }
  256. else
  257. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
  258. {
  259. ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_WAVE), FALSE );
  260. ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_FILE), FALSE );
  261. ::EnableWindow( GetDlgItem(IDC_BUTTON_WELCOME_TEST), TRUE );
  262. ::EnableWindow( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), TRUE );
  263. ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_VOLUME), TRUE );
  264. ::EnableWindow( GetDlgItem(IDC_SLIDER_WELCOME_RATE), TRUE );
  265. ::EnableWindow( GetDlgItem(IDC_COMBO_WELCOME_VOICE), TRUE );
  266. }
  267. }
  268. void CPhoneEditDlg::OnRadioMessage()
  269. {
  270. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
  271. {
  272. ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), FALSE );
  273. ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_FILE), FALSE );
  274. ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_TEST), FALSE );
  275. ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), FALSE );
  276. ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_VOLUME), FALSE );
  277. ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_RATE), FALSE );
  278. ::EnableWindow( GetDlgItem(IDC_COMBO_MESSAGE_VOICE), FALSE );
  279. }
  280. else
  281. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
  282. {
  283. ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), TRUE );
  284. ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_FILE), TRUE );
  285. ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_TEST), TRUE );
  286. ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), FALSE );
  287. ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_VOLUME), FALSE );
  288. ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_RATE), FALSE );
  289. ::EnableWindow( GetDlgItem(IDC_COMBO_MESSAGE_VOICE), FALSE );
  290. }
  291. else
  292. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
  293. {
  294. ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), FALSE );
  295. ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_FILE), FALSE );
  296. ::EnableWindow( GetDlgItem(IDC_BUTTON_MESSAGE_TEST), TRUE );
  297. ::EnableWindow( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), TRUE );
  298. ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_VOLUME), TRUE );
  299. ::EnableWindow( GetDlgItem(IDC_SLIDER_MESSAGE_RATE), TRUE );
  300. ::EnableWindow( GetDlgItem(IDC_COMBO_MESSAGE_VOICE), TRUE );
  301. }
  302. }
  303. void CPhoneEditDlg::OnButtonWelcomeFile()
  304. {
  305. TCHAR pFileName[MAX_PATH] = {0};
  306. TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0");
  307. OPENFILENAME OpenFileName;
  308. memset( &OpenFileName, 0, sizeof(OpenFileName) );
  309. // OpenFileName.lStructSize = sizeof(OPENFILENAME);
  310. OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400;
  311. OpenFileName.hwndOwner = GetSafeHwnd();
  312. OpenFileName.hInstance = NULL;
  313. OpenFileName.lpstrFilter = pFilter;
  314. OpenFileName.lpstrCustomFilter = NULL;
  315. OpenFileName.nMaxCustFilter = 0;
  316. OpenFileName.nFilterIndex = 1;
  317. OpenFileName.lpstrFile = pFileName;
  318. OpenFileName.nMaxFile = MAX_PATH;
  319. OpenFileName.lpstrFileTitle = NULL;
  320. OpenFileName.nMaxFileTitle = 0;
  321. OpenFileName.lpstrInitialDir = NULL;
  322. OpenFileName.lpstrTitle = NULL;
  323. OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
  324. if( !::GetOpenFileName( &OpenFileName ) )
  325. {
  326. DWORD dwError = ::CommDlgExtendedError();
  327. if( dwError )
  328. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::OnButtonMessageFile"), _T("GetOpenFileName returns %d"), dwError );
  329. return;
  330. }
  331. ::SetWindowText( GetDlgItem( IDC_EDIT_WELCOME_WAVE ), OpenFileName.lpstrFile );
  332. }
  333. void CPhoneEditDlg::OnButtonMessageFile()
  334. {
  335. TCHAR pFileName[MAX_PATH] = {0};
  336. TCHAR pFilter[] = _T("Windows wave files (*.wav)\0*.wav\0\0");
  337. OPENFILENAME OpenFileName;
  338. memset( &OpenFileName, 0, sizeof(OpenFileName) );
  339. // OpenFileName.lStructSize = sizeof(OPENFILENAME);
  340. OpenFileName.lStructSize = OPENFILENAME_SIZE_VERSION_400;
  341. OpenFileName.hwndOwner = GetSafeHwnd();
  342. OpenFileName.hInstance = NULL;
  343. OpenFileName.lpstrFilter = pFilter;
  344. OpenFileName.lpstrCustomFilter = NULL;
  345. OpenFileName.nMaxCustFilter = 0;
  346. OpenFileName.nFilterIndex = 1;
  347. OpenFileName.lpstrFile = pFileName;
  348. OpenFileName.nMaxFile = MAX_PATH;
  349. OpenFileName.lpstrFileTitle = NULL;
  350. OpenFileName.nMaxFileTitle = 0;
  351. OpenFileName.lpstrInitialDir = NULL;
  352. OpenFileName.lpstrTitle = NULL;
  353. OpenFileName.Flags = OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | OFN_PATHMUSTEXIST;
  354. if( !::GetOpenFileName( &OpenFileName ) )
  355. {
  356. DWORD dwError = ::CommDlgExtendedError();
  357. if( dwError )
  358. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_INFO, this, _T("CPhoneEditDlg::OnButtonMessageFile"), _T("GetOpenFileName returns %d"), dwError );
  359. return;
  360. }
  361. ::SetWindowText( GetDlgItem( IDC_EDIT_MESSAGE_WAVE ), OpenFileName.lpstrFile );
  362. }
  363. void CPhoneEditDlg::OnButtonWelcomeTest()
  364. {
  365. // get welcome data
  366. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_NONE ) )
  367. {
  368. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonWelcomeTest"), _T("Unexpected situation (state=NONE)") );
  369. return;
  370. }
  371. UINT dwWaveOutDevice = WAVE_MAPPER;
  372. // INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETCURSEL, 0, 0 );
  373. // if( nIndex != CB_ERR )
  374. // {
  375. // dwWaveOutDevice = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETITEMDATA, nIndex, 0 );
  376. // }
  377. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_WAVE ) )
  378. {
  379. // get file name
  380. TCHAR pFileName[MAX_PATH] = {0};
  381. ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_WAVE), pFileName, MAX_PATH );
  382. // stop previous wave
  383. // m_WavePlayer.ResetWave();
  384. ::PlaySound( NULL, NULL, SND_PURGE );
  385. // stop previous speech
  386. m_SpeechPlayer.ResetSpeech();
  387. // // load file
  388. // if( m_WaveFile.Load( pFileName ) )
  389. // {
  390. // // play file
  391. // m_WavePlayer.PlayWave( &m_WaveFile, dwWaveOutDevice );
  392. // }
  393. ::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC );
  394. }
  395. else
  396. if( IsDlgButtonChecked( IDC_RADIO_WELCOME_TEXT2SPEECH ) )
  397. {
  398. // get file name
  399. TCHAR pText[MAX_PATH] = {0};
  400. ::GetWindowText( GetDlgItem(IDC_EDIT_WELCOME_TEXT2SPEECH), pText, MAX_PATH );
  401. // stop previous wave
  402. // m_WavePlayer.ResetWave();
  403. ::PlaySound( NULL, NULL, SND_PURGE );
  404. // stop previous speech
  405. m_SpeechPlayer.ResetSpeech();
  406. // get voice id
  407. INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETCURSEL, 0, 0 );
  408. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_GETITEMDATA, nIndex, 0 );
  409. // play text
  410. m_SpeechPlayer.PlaySpeech( pText, dwWaveOutDevice,
  411. SendDlgItemMessage( IDC_SLIDER_WELCOME_VOLUME, TBM_GETPOS, 0, 0 ),
  412. SendDlgItemMessage( IDC_SLIDER_WELCOME_RATE, TBM_GETPOS, 0, 0 ), pVoice );
  413. }
  414. }
  415. void CPhoneEditDlg::OnButtonMessageTest()
  416. {
  417. // get welcome data
  418. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_NONE ) )
  419. {
  420. LGLOG( LOG_LEVEL_LOW, LOG_TYPE_WARNING, this, _T("CPhoneEditDlg::OnButtonMessageTest"), _T("Unexpected situation (state=NONE)") );
  421. return;
  422. }
  423. UINT dwWaveOutDevice = WAVE_MAPPER;
  424. // INT nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETCURSEL, 0, 0 );
  425. // if( nIndex != CB_ERR )
  426. // {
  427. // dwWaveOutDevice = SendDlgItemMessage( IDC_COMBO_WELCOME_TEST, CB_GETITEMDATA, nIndex, 0 );
  428. // }
  429. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_WAVE ) )
  430. {
  431. // get file name
  432. TCHAR pFileName[MAX_PATH] = {0};
  433. ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_WAVE), pFileName, MAX_PATH );
  434. // stop previous wave
  435. // m_WavePlayer.ResetWave();
  436. ::PlaySound( NULL, NULL, SND_PURGE );
  437. // stop previous speech
  438. m_SpeechPlayer.ResetSpeech();
  439. // // load file
  440. // if( m_WaveFile.Load( pFileName ) )
  441. // {
  442. // // play file
  443. // m_WavePlayer.PlayWave( &m_WaveFile, dwWaveOutDevice );
  444. // }
  445. ::PlaySound( pFileName, NULL, SND_FILENAME | SND_ASYNC );
  446. }
  447. else
  448. if( IsDlgButtonChecked( IDC_RADIO_MESSAGE_TEXT2SPEECH ) )
  449. {
  450. // get file name
  451. TCHAR pText[MAX_PATH] = {0};
  452. ::GetWindowText( GetDlgItem(IDC_EDIT_MESSAGE_TEXT2SPEECH), pText, MAX_PATH );
  453. // stop previous wave
  454. // m_WavePlayer.ResetWave();
  455. ::PlaySound( NULL, NULL, SND_PURGE );
  456. // stop previous speech
  457. m_SpeechPlayer.ResetSpeech();
  458. // get voice id
  459. INT nIndex = SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETCURSEL, 0, 0 );
  460. LPWSTR pVoice = (nIndex == CB_ERR) ? NULL : (LPWSTR)SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_GETITEMDATA, nIndex, 0 );
  461. // play text
  462. m_SpeechPlayer.PlaySpeech( pText, dwWaveOutDevice,
  463. SendDlgItemMessage( IDC_SLIDER_MESSAGE_VOLUME, TBM_GETPOS, 0, 0 ),
  464. SendDlgItemMessage( IDC_SLIDER_MESSAGE_RATE, TBM_GETPOS, 0, 0 ), pVoice );
  465. }
  466. }
  467. BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId, void* pParam )
  468. {
  469. CPhoneEditDlg *pThis = (CPhoneEditDlg*) pParam;
  470. return pThis->EnumVoiceProc( pDescription, pId );
  471. }
  472. BOOL CPhoneEditDlg::EnumVoiceProc( LPCTSTR pDescription, LPWSTR pId )
  473. {
  474. INT nIndex;
  475. LPWSTR pCopyId;
  476. nIndex = SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_ADDSTRING, 0, (LONG)pDescription );
  477. pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) );
  478. if( pCopyId ) wcscpy( pCopyId, pId );
  479. SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_SETITEMDATA, nIndex, (DWORD)pCopyId );
  480. if( !wcscmp( m_pPhoneCommand->command.pPhoneWelcomeText2SpeechVoice, pCopyId ) )
  481. SendDlgItemMessage( IDC_COMBO_WELCOME_VOICE, CB_SETCURSEL, nIndex, 0 );
  482. nIndex = SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_ADDSTRING, 0, (LONG)pDescription );
  483. pCopyId = (LPWSTR)CoTaskMemAlloc( ( wcslen(pId) + 1 ) * sizeof(WCHAR) );
  484. if( pCopyId ) wcscpy( pCopyId, pId );
  485. SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_SETITEMDATA, nIndex, (DWORD)pCopyId );
  486. if( !wcscmp( m_pPhoneCommand->command.pPhoneMessageText2SpeechVoice, pCopyId ) )
  487. SendDlgItemMessage( IDC_COMBO_MESSAGE_VOICE, CB_SETCURSEL, nIndex, 0 );
  488. return TRUE;
  489. }