Leaked source code of windows server 2003
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.

1560 lines
45 KiB

  1. // PropPage.cpp : Implementation of CSpPropertyPage
  2. #include "private.h"
  3. #include "globals.h"
  4. #include "PropPage.h"
  5. #include "commctrl.h"
  6. #include "cregkey.h"
  7. #include "cresstr.h"
  8. #include "cicspres.h"
  9. extern HRESULT _SetGlobalCompDWORD(REFGUID rguid, DWORD dw);
  10. extern HRESULT _GetGlobalCompDWORD(REFGUID rguid, DWORD *pdw);
  11. // only used for dialogs, not the class factory!
  12. CComModule _Module;
  13. //
  14. // Context Help Ids.
  15. //
  16. static int aSptipPropIds[] =
  17. {
  18. IDC_PP_ASSIGN_BUTTON, IDH_PP_ASSIGN_BUTTON,
  19. IDC_PP_BUTTON_MB_SETTING, IDH_PP_BUTTON_MB_SETTING,
  20. IDC_PP_SHOW_BALLOON, IDH_PP_SHOW_BALLOON,
  21. IDC_PP_LMA, IDH_PP_LMA,
  22. IDC_PP_HIGH_CONFIDENCE, IDH_PP_HIGH_CONFIDENCE,
  23. IDC_PP_SAVE_SPDATA, IDH_PP_SAVE_SPDATA,
  24. IDC_PP_REMOVE_SPACE, IDH_PP_REMOVE_SPACE,
  25. IDC_PP_DIS_DICT_TYPING, IDH_PP_DIS_DICT_TYPING,
  26. IDC_PP_PLAYBACK, IDH_PP_PLAYBACK,
  27. IDC_PP_DICT_CANDUI_OPEN, IDH_PP_DICT_CANDUI_OPEN,
  28. IDC_PP_BUTTON_ADVANCE, IDH_PP_BUTTON_ADVANCE,
  29. IDC_PP_BUTTON_SPCPL, IDH_PP_BUTTON_SPCPL,
  30. IDC_PP_BUTTON_LANGBAR, IDH_PP_BUTTON_LANGBAR,
  31. IDC_PP_DICTCMDS, IDH_PP_DICTCMDS,
  32. 0, 0
  33. };
  34. static int aSptipVoiceDlgIds[] =
  35. {
  36. IDC_PP_SELECTION_CMD, IDH_PP_SELECTION_CMD,
  37. IDC_PP_NAVIGATION_CMD, IDH_PP_NAVIGATION_CMD,
  38. IDC_PP_CASING_CMD, IDH_PP_CASING_CMD,
  39. IDC_PP_EDITING_CMD, IDH_PP_EDITING_CMD,
  40. IDC_PP_KEYBOARD_CMD, IDH_PP_KEYBOARD_CMD,
  41. IDC_PP_TTS_CMD, IDH_PP_TTS_CMD,
  42. IDC_PP_LANGBAR_CMD, IDH_PP_LANGBAR_CMD,
  43. 0, 0
  44. };
  45. static int aSptipButtonDlgIds[] =
  46. {
  47. IDC_PP_DICTATION_CMB, IDH_PP_DICTATION_CMB,
  48. IDC_PP_COMMAND_CMB, IDH_PP_COMMAND_CMB,
  49. 0, 0
  50. };
  51. #ifdef USE_IPROPERTYPAGE
  52. /////////////////////////////////////////////////////////////////////////////
  53. // CSpPropertyPage
  54. //////////////////////////////////////////////////////////////////////////////
  55. //
  56. // CSpPropertyPage::CSpPropertyPage
  57. //
  58. // Description: Constructor: initializes member variables
  59. //
  60. //////////////////////////////////////////////////////////////////////////////
  61. CSpPropertyPage::CSpPropertyPage() : m_hWndParent(NULL)
  62. {
  63. m_dwTitleID = IDS_PROPERTYPAGE_TITLE;
  64. m_dwHelpFileID = IDS_HELPFILESpPropPage;
  65. m_dwDocStringID = IDS_DOCSTRINGSpPropPage;
  66. m_SpPropItemsServer = NULL;
  67. m_dwNumCtrls = 0;
  68. m_IdCtrlPropMap = NULL;
  69. m_SpAdvanceSet = NULL;
  70. }
  71. //////////////////////////////////////////////////////////////////////////////
  72. //
  73. // CSpPropertyPage::~CSpPropertyPage
  74. //
  75. // Description: Destructor: clean up the array of CSpListenerItems
  76. //
  77. //////////////////////////////////////////////////////////////////////////////
  78. CSpPropertyPage::~CSpPropertyPage()
  79. {
  80. if ( m_SpPropItemsServer )
  81. delete m_SpPropItemsServer;
  82. if ( m_IdCtrlPropMap )
  83. cicMemFree(m_IdCtrlPropMap);
  84. if ( m_SpAdvanceSet )
  85. delete m_SpAdvanceSet;
  86. }
  87. //////////////////////////////////////////////////////////////////////////////
  88. //
  89. // CSpPropertyPage::Activate
  90. //
  91. // Description: Initializes the property page:
  92. // - calls Activate on the base class
  93. // - initializes the common controls
  94. // - initializes the property page dialog
  95. //
  96. // Parameters: hWndParent - handle to parent (host) window
  97. // prc - RECT of the parent
  98. // bModal - modality of the window
  99. //
  100. // Return Values: S_OK
  101. //
  102. //////////////////////////////////////////////////////////////////////////////
  103. STDMETHODIMP CSpPropertyPage::Activate(
  104. HWND hWndParent,
  105. LPCRECT prc,
  106. BOOL bModal)
  107. {
  108. InitCommonControls();
  109. Assert(hWndParent != NULL);
  110. m_hWndParent = hWndParent;
  111. HRESULT hr = PPBaseClass::Activate(hWndParent, prc, bModal);
  112. hr = InitPropertyPage();
  113. if (SUCCEEDED(hr))
  114. {
  115. SetDirty(FALSE);
  116. }
  117. return hr;
  118. }
  119. //////////////////////////////////////////////////////////////////////////////
  120. //
  121. // CSpPropertyPage::Apply
  122. //
  123. // Description: Calls CommitChanges and if SUCCEEDED sets the dirty bit
  124. //
  125. // Parameters: none
  126. //
  127. // Return Values: S_OK, E_FAIL
  128. //
  129. //////////////////////////////////////////////////////////////////////////////
  130. STDMETHODIMP CSpPropertyPage::Apply(void)
  131. {
  132. HRESULT hr = S_OK;
  133. if ( IsPageDirty( ) != S_OK ) return hr;
  134. // change the registry settings here. !!!
  135. Assert(m_SpPropItemsServer);
  136. m_SpPropItemsServer->_SavePropData( );
  137. // Notify all the Cicero Applications of these registry settings change.
  138. if ( SUCCEEDED(hr) )
  139. {
  140. hr = _SetGlobalCompDWORD(GUID_COMPARTMENT_SPEECH_PROPERTY_CHANGE, 1);
  141. }
  142. if (SUCCEEDED(hr))
  143. {
  144. SetDirty(FALSE);
  145. }
  146. return hr;
  147. }
  148. //////////////////////////////////////////////////////////////////////////////
  149. //
  150. // CSpPropertyPage::InitPropertyPage
  151. //
  152. // Description: Initializes the property page:
  153. // - initializes the listview
  154. // - loads the listener info into the listview
  155. //
  156. // Parameters: none
  157. //
  158. // Return Values: S_OK
  159. //
  160. //////////////////////////////////////////////////////////////////////////////
  161. HRESULT CSpPropertyPage::InitPropertyPage()
  162. {
  163. HRESULT hr = S_OK;
  164. // Add some initialization code here.
  165. if ( !m_SpPropItemsServer )
  166. m_SpPropItemsServer = (CSpPropItemsServer *) new CSpPropItemsServer;
  167. if ( !m_SpPropItemsServer )
  168. return E_FAIL;
  169. if ( !m_IdCtrlPropMap )
  170. {
  171. CONTROL_PROP_MAP IdCtrlPropMap[] =
  172. {
  173. // idCtrl, idPropItem, fEdit
  174. {IDC_PP_SELECTION_CMD, PropId_Cmd_Select_Correct, FALSE},
  175. {IDC_PP_NAVIGATION_CMD, PropId_Cmd_Navigation, FALSE},
  176. {IDC_PP_CASING_CMD, PropId_Cmd_Casing, FALSE},
  177. {IDC_PP_EDITING_CMD, PropId_Cmd_Editing, FALSE},
  178. {IDC_PP_KEYBOARD_CMD, PropId_Cmd_Keyboard, FALSE},
  179. {IDC_PP_LANGBAR_CMD, PropId_Cmd_Language_Bar, FALSE},
  180. {IDC_PP_TTS_CMD, PropId_Cmd_TTS, FALSE},
  181. {IDC_PP_DISABLE_DICTCMD, PropId_Cmd_DisDict, FALSE},
  182. {IDC_PP_ASSIGN_BUTTON, PropId_Mode_Button, FALSE},
  183. { 0, PropId_Max_Item_Id, FALSE }
  184. };
  185. DWORD dwPropItems = 0;
  186. while (IdCtrlPropMap[dwPropItems].idCtrl != 0 )
  187. dwPropItems ++;
  188. m_IdCtrlPropMap = (CONTROL_PROP_MAP *)cicMemAlloc(dwPropItems * sizeof(CONTROL_PROP_MAP));
  189. if ( m_IdCtrlPropMap == NULL )
  190. return E_OUTOFMEMORY;
  191. for ( DWORD i=0; i<dwPropItems; i++)
  192. {
  193. m_IdCtrlPropMap[i].fEdit = IdCtrlPropMap[i].fEdit;
  194. m_IdCtrlPropMap[i].idCtrl= IdCtrlPropMap[i].idCtrl;
  195. m_IdCtrlPropMap[i].idPropItem = IdCtrlPropMap[i].idPropItem;
  196. }
  197. m_dwNumCtrls = dwPropItems;
  198. }
  199. for (DWORD i=0; i<m_dwNumCtrls; i++ )
  200. {
  201. WORD idCtrl;
  202. PROP_ITEM_ID idPropItem;
  203. BOOL fEditControl;
  204. idCtrl = m_IdCtrlPropMap[i].idCtrl;
  205. idPropItem = m_IdCtrlPropMap[i].idPropItem;
  206. fEditControl = m_IdCtrlPropMap[i].fEdit;
  207. // BugBug: There is no edit control in current property page.
  208. // all the edit controls are moved to advanced setting dialog.
  209. // temporally keep the code here, but after we finish the code for the
  210. // advcanced setting dialog, please optimize code here.
  211. //
  212. if ( fEditControl )
  213. {
  214. SetDlgItemInt(idCtrl, (UINT)m_SpPropItemsServer->_GetPropData(idPropItem));
  215. }
  216. else
  217. {
  218. BOOL fEnable;
  219. LPARAM bst_Status;
  220. fEnable = (BOOL)m_SpPropItemsServer->_GetPropData(idPropItem);
  221. bst_Status = fEnable ? BST_CHECKED : BST_UNCHECKED;
  222. SendDlgItemMessage(idCtrl, BM_SETCHECK, bst_Status);
  223. }
  224. }
  225. // Specially handle the Mode button settings.
  226. if (! m_SpPropItemsServer->_GetPropData(PropId_Mode_Button) )
  227. {
  228. ::EnableWindow(GetDlgItem(IDC_PP_BUTTON_MB_SETTING), FALSE);
  229. }
  230. return hr;
  231. }
  232. //////////////////////////////////////////////////////////////////////////////
  233. //
  234. // CSpPropertyPage::OnCheckButtonSetting
  235. //
  236. // Description: Handle all the change in the checked buttons related to
  237. // speech tip setting. the status is Enable/Disable.
  238. //
  239. // Return Values: S_OK
  240. //
  241. //////////////////////////////////////////////////////////////////////////////
  242. LRESULT CSpPropertyPage::OnCheckButtonSetting(WORD wNotifyCode,WORD wID,HWND hWndCtl,BOOL& bHandled)
  243. {
  244. HRESULT hr = S_OK;
  245. BOOL fChecked = FALSE;
  246. BOOL fEnable = FALSE;
  247. PROP_ITEM_ID idPropItem = PropId_Max_Item_Id; // means not initialized
  248. Assert(m_SpPropItemsServer);
  249. Assert(m_IdCtrlPropMap);
  250. // Find the prop item ID associated with this checked box button.
  251. for ( DWORD i=0; i<m_dwNumCtrls; i++)
  252. {
  253. if ( m_IdCtrlPropMap[i].idCtrl == wID )
  254. {
  255. idPropItem = m_IdCtrlPropMap[i].idPropItem;
  256. break;
  257. }
  258. }
  259. if ( idPropItem >= PropId_Max_Item_Id )
  260. {
  261. // we don't find the control ID from our list, this is not possible, some thing wrong already.
  262. // exit here.
  263. return E_FAIL;
  264. }
  265. if ( wNotifyCode != BN_CLICKED )
  266. return hr;
  267. if ( ::SendMessage(hWndCtl, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  268. fChecked = TRUE;
  269. fEnable = fChecked;
  270. m_SpPropItemsServer->_SetPropData(idPropItem, fEnable);
  271. // Specially hanlde Mode Buttons.
  272. if ( wID == IDC_PP_ASSIGN_BUTTON )
  273. {
  274. ::EnableWindow(GetDlgItem(IDC_PP_BUTTON_MB_SETTING), fEnable);
  275. }
  276. SetDirty(TRUE);
  277. return hr;
  278. }
  279. //////////////////////////////////////////////////////////////////////////////
  280. //
  281. // CSpPropertyPage::OnPushButtonClicked
  282. //
  283. // Description: When the pushbutton is pressed in this page, this function
  284. // will be called to open corresponding dialog.
  285. //
  286. // Return Values: S_OK
  287. //
  288. //////////////////////////////////////////////////////////////////////////////
  289. LRESULT CSpPropertyPage::OnPushButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl,BOOL& bHandled)
  290. {
  291. HRESULT hr = S_OK;
  292. switch (wID)
  293. {
  294. case IDC_PP_BUTTON_ADVANCE :
  295. if (m_SpAdvanceSet)
  296. {
  297. delete m_SpAdvanceSet;
  298. m_SpAdvanceSet = NULL;
  299. }
  300. m_SpAdvanceSet = (CSpAdvanceSetting *) new CSpAdvanceSetting( );
  301. if ( m_SpAdvanceSet )
  302. {
  303. int nRetCode;
  304. nRetCode = m_SpAdvanceSet->DoModal(m_hWndParent, (LPARAM)m_SpPropItemsServer);
  305. if ( nRetCode == IDOK )
  306. SetDirty(TRUE);
  307. delete m_SpAdvanceSet;
  308. m_SpAdvanceSet = NULL;
  309. }
  310. break;
  311. case IDC_PP_BUTTON_LANGBAR :
  312. {
  313. TCHAR szCmdLine[MAX_PATH];
  314. TCHAR szInputPath[MAX_PATH];
  315. int cch = GetSystemDirectory(szInputPath, ARRAYSIZE(szInputPath));
  316. if (cch > 0)
  317. {
  318. // GetSystemDirectory appends no '\' unless the system
  319. // directory is the root, such like "c:\"
  320. if (cch != 3)
  321. StringCchCat(szInputPath, ARRAYSIZE(szInputPath),TEXT("\\"));
  322. StringCchCat(szInputPath, ARRAYSIZE(szInputPath), TEXT("input.dll"));
  323. StringCchPrintf(szCmdLine, ARRAYSIZE(szCmdLine), TEXT("rundll32 shell32.dll,Control_RunDLL \"%s\""),szInputPath);
  324. // start Language Bar control panel applet
  325. RunCPLSetting(szCmdLine);
  326. }
  327. break;
  328. }
  329. case IDC_PP_BUTTON_MB_SETTING :
  330. break;
  331. default :
  332. Assert(0);
  333. break;
  334. }
  335. return hr;
  336. }
  337. #endif // USE_IPROPERTYPAGE
  338. //
  339. //
  340. // CSpAdvanceSetting
  341. //
  342. CSpAdvanceSetting::CSpAdvanceSetting()
  343. {
  344. // m_dwTitleID = IDS_PROPERTYPAGE_TITLE;
  345. // m_dwHelpFileID = IDS_HELPFILESpPropPage;
  346. // m_dwDocStringID = IDS_DOCSTRINGSpPropPage;
  347. m_SpPropItemsServer = NULL;
  348. m_dwNumCtrls = 0;
  349. m_IdCtrlPropMap = NULL;
  350. }
  351. CSpAdvanceSetting::~CSpAdvanceSetting( )
  352. {
  353. if ( m_SpPropItemsServer )
  354. delete m_SpPropItemsServer;
  355. if ( m_IdCtrlPropMap )
  356. cicMemFree(m_IdCtrlPropMap);
  357. }
  358. LRESULT CSpAdvanceSetting::OnInitAdvanceDialog(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled )
  359. {
  360. Assert(lParam);
  361. m_SpPropBaseServer = (CSpPropItemsServer *)lParam;
  362. // Add some initialization code here.
  363. if ( !m_SpPropItemsServer )
  364. m_SpPropItemsServer = (CSpPropItemsServer *) new CSpPropItemsServer(m_SpPropBaseServer, PropId_MinId_InVoiceCmd, PropId_MaxId_InVoiceCmd);
  365. if ( !m_SpPropItemsServer )
  366. return FALSE;
  367. if ( !m_IdCtrlPropMap )
  368. {
  369. // Please make sure the array items are sorted by control id, and make sure the control id are sequent number,
  370. // so that we can use it to map to an index in the array easily.
  371. //
  372. CONTROL_PROP_MAP IdCtrlPropMap[] =
  373. {
  374. // idCtrl, idPropItem, fEdit
  375. {IDC_PP_SELECTION_CMD, PropId_Cmd_Select_Correct, FALSE},
  376. {IDC_PP_NAVIGATION_CMD, PropId_Cmd_Navigation, FALSE},
  377. {IDC_PP_CASING_CMD, PropId_Cmd_Casing, FALSE},
  378. {IDC_PP_EDITING_CMD, PropId_Cmd_Editing, FALSE},
  379. {IDC_PP_KEYBOARD_CMD, PropId_Cmd_Keyboard, FALSE},
  380. {IDC_PP_LANGBAR_CMD, PropId_Cmd_Language_Bar, FALSE},
  381. // {IDC_PP_TTS_CMD, PropId_Cmd_TTS, FALSE},
  382. // {IDC_PP_MAXNUM_ALTERNATES, PropId_Max_Alternates, TRUE},
  383. // {IDC_PP_MAXCHARS_ALTERNATE, PropId_MaxChar_Cand, TRUE},
  384. { 0, PropId_Max_Item_Id, FALSE }
  385. };
  386. DWORD dwPropItems = ARRAYSIZE(IdCtrlPropMap) - 1;
  387. m_IdCtrlPropMap = (CONTROL_PROP_MAP *)cicMemAlloc(dwPropItems * sizeof(CONTROL_PROP_MAP));
  388. if ( m_IdCtrlPropMap == NULL )
  389. return E_OUTOFMEMORY;
  390. for ( DWORD i=0; i<dwPropItems; i++)
  391. {
  392. m_IdCtrlPropMap[i] = IdCtrlPropMap[i];
  393. }
  394. m_dwNumCtrls = dwPropItems;
  395. }
  396. for (DWORD i=0; i<m_dwNumCtrls; i++ )
  397. {
  398. WORD idCtrl;
  399. PROP_ITEM_ID idPropItem;
  400. BOOL fEditControl;
  401. idCtrl = m_IdCtrlPropMap[i].idCtrl;
  402. idPropItem = m_IdCtrlPropMap[i].idPropItem;
  403. fEditControl = m_IdCtrlPropMap[i].fEdit;
  404. if ( fEditControl )
  405. {
  406. SetDlgItemInt(idCtrl, (UINT)m_SpPropItemsServer->_GetPropData(idPropItem));
  407. }
  408. else
  409. {
  410. BOOL fEnable;
  411. LPARAM bst_Status;
  412. fEnable = (BOOL)m_SpPropItemsServer->_GetPropData(idPropItem);
  413. bst_Status = fEnable ? BST_CHECKED : BST_UNCHECKED;
  414. SendDlgItemMessage(idCtrl, BM_SETCHECK, bst_Status);
  415. }
  416. }
  417. return TRUE;
  418. }
  419. LRESULT CSpAdvanceSetting::OnContextHelp(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled )
  420. {
  421. HRESULT hr = S_OK;
  422. switch (uMsg)
  423. {
  424. case WM_HELP :
  425. ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle,
  426. c_szHelpFile,
  427. HELP_WM_HELP,
  428. (DWORD_PTR)(LPTSTR)aSptipVoiceDlgIds );
  429. break;
  430. case WM_CONTEXTMENU : // right mouse click
  431. ::WinHelp( (HWND)wParam,
  432. c_szHelpFile,
  433. HELP_CONTEXTMENU,
  434. (DWORD_PTR)(LPTSTR)aSptipVoiceDlgIds );
  435. break;
  436. default :
  437. break;
  438. }
  439. return hr;
  440. }
  441. //////////////////////////////////////////////////////////////////////////////
  442. //
  443. // CSpAdvanceSetting::OnCheckButtonSetting
  444. //
  445. // Description: Handle all the change in the checked buttons in the Advanced
  446. // setting dialog. the status is Enable/Disable.
  447. //
  448. // Return Values: S_OK
  449. //
  450. //////////////////////////////////////////////////////////////////////////////
  451. LRESULT CSpAdvanceSetting::OnCheckButtonSetting(WORD wNotifyCode, WORD wID, HWND hWndCtl,BOOL& bHandled)
  452. {
  453. HRESULT hr = S_OK;
  454. BOOL fChecked = FALSE;
  455. BOOL fEnable = FALSE;
  456. PROP_ITEM_ID idPropItem = PropId_Max_Item_Id; // means not initialized
  457. Assert(m_SpPropItemsServer);
  458. Assert(m_IdCtrlPropMap);
  459. // Find the prop item ID associated with this checked box button.
  460. Assert( wID >= IDC_PP_SELECTION_CMD );
  461. idPropItem = m_IdCtrlPropMap[wID - IDC_PP_SELECTION_CMD].idPropItem;
  462. if ( idPropItem >= PropId_Max_Item_Id )
  463. {
  464. // we don't find the control ID from our list, this is not possible, some thing wrong already.
  465. // exit here.
  466. return E_FAIL;
  467. }
  468. if ( wNotifyCode != BN_CLICKED )
  469. return hr;
  470. if ( ::SendMessage(hWndCtl, BM_GETCHECK, 0, 0) == BST_CHECKED )
  471. fChecked = TRUE;
  472. fEnable = fChecked;
  473. m_SpPropItemsServer->_SetPropData(idPropItem, fEnable);
  474. return hr;
  475. }
  476. /*
  477. //////////////////////////////////////////////////////////////////////////////
  478. //
  479. // CSpAdvanceSetting::OnEditControlSetting
  480. //
  481. // Description: Handle all the change in the edit controls related to
  482. // speech tip setting. the value is editable.
  483. //
  484. // Return Values: S_OK
  485. //
  486. //////////////////////////////////////////////////////////////////////////////
  487. LRESULT CSpAdvanceSetting::OnEditControlSetting(WORD wNotifyCode, WORD wID, HWND hWndCtl,BOOL& bHandled)
  488. {
  489. HRESULT hr = S_OK;
  490. ULONG ulValue = 0;
  491. PROP_ITEM_ID idPropItem = PropId_Max_Item_Id; // means not initialized
  492. Assert(m_SpPropItemsServer);
  493. Assert(m_IdCtrlPropMap);
  494. Assert( wID >= IDC_PP_SHOW_BALLOON );
  495. idPropItem = m_IdCtrlPropMap[wID - IDC_PP_SHOW_BALLOON].idPropItem;
  496. if ( idPropItem >= PropId_Max_Item_Id )
  497. {
  498. // we don't find the control ID from our list, this is not possible, some thing wrong already.
  499. // exit here.
  500. return E_FAIL;
  501. }
  502. if ( wNotifyCode != EN_CHANGE )
  503. return hr;
  504. ulValue = (ULONG) GetDlgItemInt(wID);
  505. m_SpPropItemsServer->_SetPropData(idPropItem, ulValue);
  506. // Enable OK button due to EditBox value change.
  507. ::EnableWindow(GetDlgItem(IDOK), TRUE);
  508. return hr;
  509. }
  510. */
  511. //////////////////////////////////////////////////////////////////////////////
  512. //
  513. // CSpAdvanceSetting::IsItemStatusChanged
  514. //
  515. // Description: Check to see if some items' status have been changed
  516. // since the dialog open.
  517. //
  518. // Return Values: S_OK
  519. //
  520. //////////////////////////////////////////////////////////////////////////////
  521. BOOL CSpAdvanceSetting::IsItemStatusChanged( )
  522. {
  523. BOOL fChanged = FALSE;
  524. // Comparing the current item status with the base server's item status
  525. // to determine if there is any item changed
  526. if ( m_SpPropItemsServer && m_SpPropBaseServer)
  527. {
  528. DWORD idPropItem;
  529. DWORD dwOrgData, dwCurData;
  530. for (idPropItem = (DWORD)PropId_MinId_InVoiceCmd; idPropItem <= (DWORD)PropId_MaxId_InVoiceCmd; idPropItem++ )
  531. {
  532. dwCurData = m_SpPropItemsServer->_GetPropData((PROP_ITEM_ID)idPropItem);
  533. dwOrgData = m_SpPropBaseServer->_GetPropData((PROP_ITEM_ID)idPropItem);
  534. if ( dwCurData != dwOrgData )
  535. {
  536. fChanged = TRUE;
  537. break;
  538. }
  539. }
  540. }
  541. return fChanged;
  542. }
  543. LRESULT CSpAdvanceSetting::OnPushButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl,BOOL& bHandled)
  544. {
  545. HRESULT hr=S_OK;
  546. int nRetCode;
  547. Assert(m_SpPropItemsServer);
  548. Assert(m_SpPropBaseServer);
  549. Assert(m_IdCtrlPropMap);
  550. if ( wID != IDOK && wID != IDCANCEL )
  551. return E_FAIL;
  552. nRetCode = FALSE; // Means no item changed
  553. if ( wID == IDOK && IsItemStatusChanged( ))
  554. {
  555. //Merge back all the change to the base property server.
  556. m_SpPropBaseServer->_MergeDataFromServer(m_SpPropItemsServer, PropId_MinId_InVoiceCmd, PropId_MaxId_InVoiceCmd);
  557. nRetCode = TRUE;
  558. }
  559. EndDialog(nRetCode);
  560. return hr;
  561. }
  562. //
  563. //
  564. // CSpModeButtonSetting
  565. //
  566. KEYNAME_VK_MAP pName_VK_Table[] = {
  567. { TEXT("F1"), VK_F1 },
  568. { TEXT("F2"), VK_F2 },
  569. { TEXT("F3"), VK_F3 },
  570. { TEXT("F4"), VK_F4 },
  571. { TEXT("F5"), VK_F5 },
  572. { TEXT("F6"), VK_F6 },
  573. { TEXT("F7"), VK_F7 },
  574. { TEXT("F8"), VK_F8 },
  575. { TEXT("F9"), VK_F9 },
  576. { TEXT("F10"), VK_F10 },
  577. { TEXT("F11"), VK_F11 },
  578. { TEXT("F12"), VK_F12 },
  579. { TEXT("Space"), VK_SPACE },
  580. { TEXT("Esc"), VK_ESCAPE },
  581. { TEXT("PgUp"), VK_PRIOR },
  582. { TEXT("PgDn"), VK_NEXT },
  583. { TEXT("Home"), VK_HOME },
  584. { TEXT("End"), VK_END },
  585. { TEXT("Left"), VK_LEFT },
  586. { TEXT("Right"), VK_RIGHT },
  587. { TEXT("Up"), VK_UP },
  588. { TEXT("Down"), VK_DOWN },
  589. { TEXT("Insert"), VK_INSERT },
  590. { TEXT("Delete"), VK_DELETE },
  591. { TEXT("+"), VK_ADD },
  592. { TEXT("-"), VK_SUBTRACT },
  593. { TEXT("/"), VK_DIVIDE },
  594. { TEXT("*"), VK_MULTIPLY },
  595. { TEXT("Enter"), VK_RETURN },
  596. { TEXT("Tab"), VK_TAB },
  597. { TEXT("Pause"), VK_PAUSE },
  598. { TEXT("ScrollLock"), VK_SCROLL },
  599. { TEXT("NumLock"), VK_NUMLOCK },
  600. };
  601. CSpModeButtonSetting::CSpModeButtonSetting()
  602. {
  603. // m_dwTitleID = IDS_PROPERTYPAGE_TITLE;
  604. // m_dwHelpFileID = IDS_HELPFILESpPropPage;
  605. // m_dwDocStringID = IDS_DOCSTRINGSpPropPage;
  606. m_SpPropItemsServer = NULL;
  607. m_dwNumCtrls = 0;
  608. m_IdCtrlPropMap = NULL;
  609. }
  610. CSpModeButtonSetting::~CSpModeButtonSetting( )
  611. {
  612. if ( m_SpPropItemsServer )
  613. delete m_SpPropItemsServer;
  614. if ( m_IdCtrlPropMap )
  615. cicMemFree(m_IdCtrlPropMap);
  616. }
  617. LRESULT CSpModeButtonSetting::OnInitModeButtonDialog(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled )
  618. {
  619. Assert(lParam);
  620. m_SpPropBaseServer = (CSpPropItemsServer *)lParam;
  621. // Add some initialization code here.
  622. if ( !m_SpPropItemsServer )
  623. m_SpPropItemsServer = (CSpPropItemsServer *) new CSpPropItemsServer(m_SpPropBaseServer, PropId_MinId_InModeButton, PropId_MaxId_InModeButton);
  624. if ( !m_SpPropItemsServer )
  625. return FALSE;
  626. if ( !m_IdCtrlPropMap )
  627. {
  628. // Please make sure the array items are sorted by control id, and make sure the control id are sequent number,
  629. // so that we can use it to map to an index in the array easily.
  630. //
  631. CONTROL_PROP_MAP IdCtrlPropMap[] =
  632. {
  633. // idCtrl, idPropItem, fEdit
  634. {IDC_PP_DICTATION_CMB, PropId_Dictation_Key, FALSE },
  635. {IDC_PP_COMMAND_CMB, PropId_Command_Key, FALSE },
  636. { 0, PropId_Max_Item_Id, FALSE }
  637. };
  638. DWORD dwPropItems = ARRAYSIZE(IdCtrlPropMap) - 1;
  639. m_IdCtrlPropMap = (CONTROL_PROP_MAP *)cicMemAlloc(dwPropItems * sizeof(CONTROL_PROP_MAP));
  640. if ( m_IdCtrlPropMap == NULL )
  641. return E_OUTOFMEMORY;
  642. for ( DWORD i=0; i<dwPropItems; i++)
  643. {
  644. m_IdCtrlPropMap[i] = IdCtrlPropMap[i];
  645. }
  646. m_dwNumCtrls = dwPropItems;
  647. }
  648. for (DWORD i=0; i<m_dwNumCtrls; i++ )
  649. {
  650. WORD idCtrl;
  651. PROP_ITEM_ID idPropItem;
  652. DWORD dwPropData;
  653. HWND hCombBox;
  654. idCtrl = m_IdCtrlPropMap[i].idCtrl;
  655. idPropItem = m_IdCtrlPropMap[i].idPropItem;
  656. dwPropData = m_SpPropItemsServer->_GetPropData(idPropItem);
  657. hCombBox = GetDlgItem(idCtrl);
  658. if ( hCombBox )
  659. {
  660. int iIndex, iIndexDef = CB_ERR; // CB_ERR is -1
  661. // Initialize the list box items
  662. for ( int j = 0; j < ARRAYSIZE(pName_VK_Table); j++ )
  663. {
  664. iIndex = (int)::SendMessage(hCombBox, CB_ADDSTRING, 0, (LPARAM)pName_VK_Table[j].pKeyName);
  665. ::SendMessage(hCombBox, CB_SETITEMDATA, iIndex, (LPARAM)(void*)&pName_VK_Table[j]);
  666. if ( pName_VK_Table[j].wVKey == dwPropData )
  667. iIndexDef = j;
  668. }
  669. // Set the current selection based on property item data.
  670. if ( iIndexDef != CB_ERR )
  671. ::SendMessage(hCombBox, CB_SETCURSEL, iIndexDef, 0 );
  672. }
  673. }
  674. return TRUE;
  675. }
  676. //////////////////////////////////////////////////////////////////////////////
  677. //
  678. // CSpModeButtonSetting::OnCombBoxSetting
  679. //
  680. // Description: Handle all the change in the CombBox controls related to
  681. // mode button setting.
  682. //
  683. // Return Values: S_OK
  684. //
  685. //////////////////////////////////////////////////////////////////////////////
  686. LRESULT CSpModeButtonSetting::OnCombBoxSetting(WORD wNotifyCode, WORD wID, HWND hWndCtl,BOOL& bHandled)
  687. {
  688. HRESULT hr = S_OK;
  689. KEYNAME_VK_MAP *pCurKeyData;
  690. int iIndex;
  691. PROP_ITEM_ID idPropItem = PropId_Max_Item_Id; // means not initialized
  692. if ( wNotifyCode != CBN_SELCHANGE )
  693. return hr;
  694. Assert(m_SpPropItemsServer);
  695. Assert(m_IdCtrlPropMap);
  696. Assert(wID >= IDC_PP_DICTATION_CMB);
  697. idPropItem = m_IdCtrlPropMap[wID - IDC_PP_DICTATION_CMB].idPropItem;
  698. if ( idPropItem >= PropId_Max_Item_Id )
  699. {
  700. // we don't find the control ID from our list, this is not possible, some thing wrong already.
  701. // exit here.
  702. return E_FAIL;
  703. }
  704. iIndex = (int)::SendMessage(hWndCtl, CB_GETCURSEL, 0, 0);
  705. pCurKeyData = (KEYNAME_VK_MAP *)::SendMessage(hWndCtl, CB_GETITEMDATA, iIndex, 0);
  706. if ( pCurKeyData )
  707. {
  708. m_SpPropItemsServer->_SetPropData(idPropItem, pCurKeyData->wVKey);
  709. }
  710. return hr;
  711. }
  712. LRESULT CSpModeButtonSetting::OnContextHelp(UINT uMsg, WPARAM wParam, LPARAM lParam,BOOL& bHandled )
  713. {
  714. HRESULT hr = S_OK;
  715. switch (uMsg)
  716. {
  717. case WM_HELP :
  718. ::WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle,
  719. c_szHelpFile,
  720. HELP_WM_HELP,
  721. (DWORD_PTR)(LPTSTR)aSptipButtonDlgIds );
  722. break;
  723. case WM_CONTEXTMENU : // right mouse click
  724. ::WinHelp((HWND)wParam,
  725. c_szHelpFile,
  726. HELP_CONTEXTMENU,
  727. (DWORD_PTR)(LPTSTR)aSptipButtonDlgIds );
  728. break;
  729. default:
  730. break;
  731. }
  732. return hr;
  733. }
  734. LRESULT CSpModeButtonSetting::OnPushButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl,BOOL& bHandled)
  735. {
  736. HRESULT hr=S_OK;
  737. int nRetCode;
  738. Assert(m_SpPropItemsServer);
  739. Assert(m_SpPropBaseServer);
  740. Assert(m_IdCtrlPropMap);
  741. if ( wID != IDOK && wID != IDCANCEL )
  742. return E_FAIL;
  743. nRetCode = wID;
  744. if ( wID == IDOK )
  745. {
  746. //Merge back all the change to the base property server.
  747. m_SpPropBaseServer->_MergeDataFromServer(m_SpPropItemsServer, PropId_MinId_InModeButton, PropId_MaxId_InModeButton);
  748. }
  749. EndDialog(nRetCode);
  750. return hr;
  751. }
  752. //
  753. //
  754. // Class CSptipPropertyPage
  755. //
  756. //
  757. CSptipPropertyPage::CSptipPropertyPage ( WORD wDlgId, BOOL fLaunchFromInputCpl )
  758. {
  759. m_wDlgId = wDlgId;
  760. m_SpPropItemsServer = NULL;
  761. m_dwNumCtrls = 0;
  762. m_IdCtrlPropMap = NULL;
  763. m_SpAdvanceSet = NULL;
  764. m_SpModeBtnSet = NULL;
  765. m_hDlg = NULL;
  766. m_fLaunchFromInputCpl = fLaunchFromInputCpl;
  767. }
  768. CSptipPropertyPage::~CSptipPropertyPage ( )
  769. {
  770. if ( m_SpPropItemsServer )
  771. delete m_SpPropItemsServer;
  772. if ( m_IdCtrlPropMap )
  773. cicMemFree(m_IdCtrlPropMap);
  774. if ( m_SpAdvanceSet )
  775. delete m_SpAdvanceSet;
  776. if ( m_SpModeBtnSet )
  777. delete m_SpModeBtnSet;
  778. }
  779. //////////////////////////////////////////////////////////////////////////////
  780. //
  781. // CSptipPropertyPage::SetDirty
  782. //
  783. // Description: When there is any setting changed in the property page
  784. // by user, this function is called to notify the property
  785. // sheet of the status change. Property sheet will activate
  786. // Apply button.
  787. //
  788. // Return Values: NONE
  789. //
  790. //////////////////////////////////////////////////////////////////////////////
  791. void CSptipPropertyPage::SetDirty(BOOL fDirty)
  792. {
  793. HWND hwndParent = ::GetParent( m_hDlg );
  794. m_fIsDirty = fDirty;
  795. ::SendMessage( hwndParent, m_fIsDirty ? PSM_CHANGED : PSM_UNCHANGED, (WPARAM)(m_hDlg), 0 );
  796. }
  797. //////////////////////////////////////////////////////////////////////////////
  798. //
  799. // CSptipPropertyPage::OnCheckButtonSetting
  800. //
  801. // Description: Handle all the change in the checked buttons related to
  802. // speech tip setting. the status is Enable/Disable.
  803. //
  804. // Return Values: S_OK
  805. //
  806. //////////////////////////////////////////////////////////////////////////////
  807. LRESULT CSptipPropertyPage::OnCheckButtonSetting(WORD wNotifyCode, WORD wID, HWND hWndCtl)
  808. {
  809. HRESULT hr = S_OK;
  810. BOOL fChecked = FALSE;
  811. BOOL fEnable = FALSE;
  812. PROP_ITEM_ID idPropItem = PropId_Max_Item_Id; // means not initialized
  813. Assert(m_SpPropItemsServer);
  814. Assert(m_IdCtrlPropMap);
  815. if ( wNotifyCode != BN_CLICKED )
  816. return hr;
  817. // Find the prop item ID associated with this checked box button.
  818. for ( DWORD i=0; i<m_dwNumCtrls; i++)
  819. {
  820. if ( m_IdCtrlPropMap[i].idCtrl == wID )
  821. {
  822. idPropItem = m_IdCtrlPropMap[i].idPropItem;
  823. break;
  824. }
  825. }
  826. if ( idPropItem >= PropId_Max_Item_Id )
  827. {
  828. // we don't find the control ID from our list, this is not possible, some thing wrong already.
  829. // exit here.
  830. return E_FAIL;
  831. }
  832. if ( ::SendMessage(hWndCtl, BM_GETCHECK, 0, 0 ) == BST_CHECKED )
  833. fChecked = TRUE;
  834. // Specially handle "Show Balloon" item.
  835. if ( wID == IDC_PP_SHOW_BALLOON )
  836. fEnable = !fChecked;
  837. else
  838. fEnable = fChecked;
  839. m_SpPropItemsServer->_SetPropData(idPropItem, fEnable);
  840. // Specially hanlde Mode Buttons.
  841. if ( wID == IDC_PP_ASSIGN_BUTTON )
  842. {
  843. ::EnableWindow(::GetDlgItem(m_hDlg, IDC_PP_BUTTON_MB_SETTING), fEnable);
  844. }
  845. SetDirty(TRUE);
  846. return hr;
  847. }
  848. //////////////////////////////////////////////////////////////////////////////
  849. //
  850. // CSptipPropertyPage::OnPushButtonClicked
  851. //
  852. // Description: When pushed button is pressed, this function is called
  853. // to respond it.
  854. //
  855. // Return Values: S_OK
  856. //
  857. //////////////////////////////////////////////////////////////////////////////
  858. const TCHAR c_szcplsKey[] = TEXT("software\\microsoft\\windows\\currentversion\\control panel\\cpls");
  859. LRESULT CSptipPropertyPage::OnPushButtonClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl)
  860. {
  861. HRESULT hr = S_OK;
  862. switch (wID)
  863. {
  864. case IDC_PP_BUTTON_ADVANCE :
  865. if (m_SpAdvanceSet)
  866. {
  867. delete m_SpAdvanceSet;
  868. m_SpAdvanceSet = NULL;
  869. }
  870. m_SpAdvanceSet = (CSpAdvanceSetting *) new CSpAdvanceSetting( );
  871. if ( m_SpAdvanceSet )
  872. {
  873. int nRetCode;
  874. nRetCode = m_SpAdvanceSet->DoModalW(m_hDlg, (LPARAM)m_SpPropItemsServer);
  875. if ( nRetCode == TRUE)
  876. SetDirty(TRUE);
  877. delete m_SpAdvanceSet;
  878. m_SpAdvanceSet = NULL;
  879. }
  880. break;
  881. case IDC_PP_BUTTON_LANGBAR :
  882. {
  883. TCHAR szCmdLine[MAX_PATH];
  884. TCHAR szInputPath[MAX_PATH];
  885. int cch = GetSystemDirectory(szInputPath, ARRAYSIZE(szInputPath));
  886. if (cch > 0)
  887. {
  888. // GetSystemDirectory appends no '\' unless the system
  889. // directory is the root, such like "c:\"
  890. if (cch != 3)
  891. StringCchCat(szInputPath,ARRAYSIZE(szInputPath),TEXT("\\"));
  892. StringCchCat(szInputPath, ARRAYSIZE(szInputPath), TEXT("input.dll"));
  893. StringCchPrintf(szCmdLine, ARRAYSIZE(szCmdLine), TEXT("rundll32 shell32.dll,Control_RunDLL \"%s\""),szInputPath);
  894. // start Language Bar control panel applet
  895. RunCPLSetting(szCmdLine);
  896. }
  897. break;
  898. }
  899. case IDC_PP_BUTTON_SPCPL :
  900. {
  901. // these have to be Ansi based, as we support non-NT
  902. TCHAR szCplPath[MAX_PATH];
  903. TCHAR szCmdLine[MAX_PATH];
  904. CMyRegKey regkey;
  905. szCplPath[0] = TEXT('\0');
  906. if (S_OK == regkey.Open(HKEY_LOCAL_MACHINE, c_szcplsKey, KEY_READ))
  907. {
  908. LONG lret;
  909. lret = regkey.QueryValueCch(szCplPath, TEXT("Speech"), ARRAYSIZE(szCplPath));
  910. }
  911. if ( szCplPath[0] )
  912. {
  913. StringCchPrintf(szCmdLine, ARRAYSIZE(szCmdLine), TEXT("rundll32 shell32.dll,Control_RunDLL \"%s\""),szCplPath);
  914. // start speech control panel applet
  915. RunCPLSetting(szCmdLine);
  916. }
  917. break;
  918. }
  919. case IDC_PP_BUTTON_MB_SETTING :
  920. if (m_SpModeBtnSet)
  921. {
  922. delete m_SpModeBtnSet;
  923. m_SpModeBtnSet = NULL;
  924. }
  925. m_SpModeBtnSet = (CSpModeButtonSetting *) new CSpModeButtonSetting( );
  926. if ( m_SpModeBtnSet )
  927. {
  928. int nRetCode;
  929. DWORD dwDictOrg, dwCommandOrg;
  930. DWORD dwDictNew, dwCommandNew;
  931. dwDictOrg = m_SpPropItemsServer->_GetPropData(PropId_Dictation_Key);
  932. dwCommandOrg = m_SpPropItemsServer->_GetPropData(PropId_Command_Key);
  933. nRetCode = m_SpModeBtnSet->DoModalW(m_hDlg, (LPARAM)m_SpPropItemsServer);
  934. dwDictNew = m_SpPropItemsServer->_GetPropData(PropId_Dictation_Key);
  935. dwCommandNew = m_SpPropItemsServer->_GetPropData(PropId_Command_Key);
  936. if ( (dwDictNew != dwDictOrg) || (dwCommandNew != dwCommandOrg) )
  937. SetDirty(TRUE);
  938. delete m_SpModeBtnSet;
  939. m_SpModeBtnSet = NULL;
  940. }
  941. break;
  942. default :
  943. Assert(0);
  944. break;
  945. }
  946. return hr;
  947. }
  948. //////////////////////////////////////////////////////////////////////////////
  949. //
  950. // CSptipPropertyPage::OnInitSptipPropPageDialog
  951. //
  952. // Description: This function responds to the WM_INITDIALOG message
  953. // Getting the initial value for all the property items,
  954. // and show the correct status in the related control items.
  955. //
  956. // Return Values: S_OK
  957. //
  958. //////////////////////////////////////////////////////////////////////////////
  959. LRESULT CSptipPropertyPage::OnInitSptipPropPageDialog(HWND hDlg )
  960. {
  961. HRESULT hr=S_OK;
  962. m_hDlg = hDlg;
  963. if ( !m_SpPropItemsServer )
  964. m_SpPropItemsServer = (CSpPropItemsServer *) new CSpPropItemsServer;
  965. if ( !m_SpPropItemsServer )
  966. return E_FAIL;
  967. if ( !m_IdCtrlPropMap )
  968. {
  969. CONTROL_PROP_MAP IdCtrlPropMap[] =
  970. {
  971. // idCtrl, idPropItem, fEdit
  972. {IDC_PP_SHOW_BALLOON, PropId_Hide_Balloon, FALSE},
  973. {IDC_PP_LMA, PropId_Support_LMA, FALSE},
  974. {IDC_PP_HIGH_CONFIDENCE, PropId_High_Confidence, FALSE},
  975. {IDC_PP_SAVE_SPDATA, PropId_Save_Speech_Data, FALSE},
  976. {IDC_PP_REMOVE_SPACE, PropId_Remove_Space, FALSE},
  977. {IDC_PP_DIS_DICT_TYPING, PropId_DisDict_Typing, FALSE},
  978. {IDC_PP_PLAYBACK, PropId_PlayBack, FALSE},
  979. {IDC_PP_DICT_CANDUI_OPEN, PropId_Dict_CandOpen, FALSE},
  980. {IDC_PP_DICTCMDS, PropId_Cmd_DictMode, FALSE},
  981. {IDC_PP_ASSIGN_BUTTON, PropId_Mode_Button, FALSE},
  982. { 0, PropId_Max_Item_Id, FALSE }
  983. };
  984. DWORD dwPropItems = ARRAYSIZE(IdCtrlPropMap) -1 ;
  985. m_IdCtrlPropMap = (CONTROL_PROP_MAP *)cicMemAlloc(dwPropItems * sizeof(CONTROL_PROP_MAP));
  986. if ( m_IdCtrlPropMap == NULL )
  987. return E_OUTOFMEMORY;
  988. for ( DWORD i=0; i<dwPropItems; i++)
  989. {
  990. m_IdCtrlPropMap[i] = IdCtrlPropMap[i];
  991. }
  992. m_dwNumCtrls = dwPropItems;
  993. }
  994. for (DWORD i=0; i<m_dwNumCtrls; i++ )
  995. {
  996. WORD idCtrl;
  997. PROP_ITEM_ID idPropItem;
  998. BOOL fEditControl;
  999. idCtrl = m_IdCtrlPropMap[i].idCtrl;
  1000. idPropItem = m_IdCtrlPropMap[i].idPropItem;
  1001. fEditControl = m_IdCtrlPropMap[i].fEdit;
  1002. // BugBug: There is no edit control in current property page.
  1003. // all the edit controls are moved to advanced setting dialog.
  1004. // temporally keep the code here, but after we finish the code for the
  1005. // advcanced setting dialog, please optimize code here.
  1006. //
  1007. if ( fEditControl )
  1008. {
  1009. ::SetDlgItemInt(m_hDlg, idCtrl, (UINT)m_SpPropItemsServer->_GetPropData(idPropItem), TRUE);
  1010. }
  1011. else
  1012. {
  1013. BOOL fEnable;
  1014. LPARAM bst_Status;
  1015. fEnable = (BOOL)m_SpPropItemsServer->_GetPropData(idPropItem);
  1016. // Specially handle "Show Balloon" button.
  1017. // Since internally we have "Hide_Balloon" property, it should be oppsite to
  1018. // to the check status of the button.
  1019. if ( idPropItem == PropId_Hide_Balloon )
  1020. bst_Status = fEnable ? BST_UNCHECKED : BST_CHECKED;
  1021. else
  1022. bst_Status = fEnable ? BST_CHECKED : BST_UNCHECKED;
  1023. ::SendDlgItemMessage(m_hDlg, idCtrl, BM_SETCHECK, bst_Status, 0);
  1024. }
  1025. }
  1026. // Specially handle the Mode button settings.
  1027. if (! m_SpPropItemsServer->_GetPropData(PropId_Mode_Button) )
  1028. {
  1029. ::EnableWindow(::GetDlgItem(m_hDlg, IDC_PP_BUTTON_MB_SETTING), FALSE);
  1030. }
  1031. // if the property page is launched from input cpl, we don't want to show
  1032. // language bar buttons in this page.
  1033. if ( m_fLaunchFromInputCpl )
  1034. {
  1035. ::ShowWindow(::GetDlgItem(m_hDlg, IDC_PP_BUTTON_LANGBAR), SW_HIDE);
  1036. }
  1037. return hr;
  1038. }
  1039. //////////////////////////////////////////////////////////////////////////////
  1040. //
  1041. // CSptipPropertyPage::OnApply
  1042. //
  1043. // Description: When Apply or OK button is clicked, this function will
  1044. // check if there is any item status change, if changed,
  1045. // save the data to the persistent storage, and notify
  1046. // Cicero application to update their status.
  1047. //
  1048. // Return Values: S_OK
  1049. //
  1050. //////////////////////////////////////////////////////////////////////////////
  1051. LRESULT CSptipPropertyPage::OnApply( )
  1052. {
  1053. HRESULT hr = S_OK;
  1054. if ( !IsPageDirty( ) ) return hr;
  1055. // change the registry settings here. !!!
  1056. Assert(m_SpPropItemsServer);
  1057. m_SpPropItemsServer->_SavePropData( );
  1058. // Notify all the Cicero Applications of these registry settings change.
  1059. if ( SUCCEEDED(hr) )
  1060. {
  1061. hr = _SetGlobalCompDWORD(GUID_COMPARTMENT_SPEECH_PROPERTY_CHANGE, 1);
  1062. }
  1063. if (SUCCEEDED(hr))
  1064. {
  1065. SetDirty(FALSE);
  1066. }
  1067. return hr;
  1068. }
  1069. //////////////////////////////////////////////////////////////////////////////
  1070. //
  1071. // CSptipPropertyPage::SpPropertyPageProc
  1072. //
  1073. // Description: Message handling procedure callback function for
  1074. // the dialog.
  1075. //
  1076. // Return Values: required value per message.
  1077. //
  1078. //////////////////////////////////////////////////////////////////////////////
  1079. INT_PTR CALLBACK CSptipPropertyPage::SpPropertyPageProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  1080. {
  1081. INT iRet = 0;
  1082. CSptipPropertyPage *pSpProp = (CSptipPropertyPage *)::GetWindowLongPtr(hDlg, GWLP_USERDATA);
  1083. switch (message)
  1084. {
  1085. case WM_INITDIALOG:
  1086. {
  1087. PROPSHEETPAGEW *pPropSheetPage = (PROPSHEETPAGEW *)(lParam);
  1088. Assert(pPropSheetPage);
  1089. ::SetWindowLongPtr(hDlg, GWLP_USERDATA, pPropSheetPage->lParam);
  1090. pSpProp = (CSptipPropertyPage *)(pPropSheetPage->lParam);
  1091. if ( pSpProp )
  1092. pSpProp->OnInitSptipPropPageDialog(hDlg);
  1093. iRet = TRUE;
  1094. break;
  1095. }
  1096. case WM_NOTIFY:
  1097. Assert(pSpProp);
  1098. switch (((NMHDR*)lParam)->code)
  1099. {
  1100. case PSN_APPLY:
  1101. pSpProp->OnApply();
  1102. break;
  1103. case PSN_QUERYCANCEL: // user clicks the Cancel button
  1104. //pSpProp->OnCancel();
  1105. break;
  1106. }
  1107. break;
  1108. case WM_HELP :
  1109. WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle,
  1110. c_szHelpFile,
  1111. HELP_WM_HELP,
  1112. (DWORD_PTR)(LPTSTR)aSptipPropIds );
  1113. break;
  1114. case WM_CONTEXTMENU : // right mouse click
  1115. WinHelp( (HWND)wParam,
  1116. c_szHelpFile,
  1117. HELP_CONTEXTMENU,
  1118. (DWORD_PTR)(LPTSTR)aSptipPropIds );
  1119. break;
  1120. case ( WM_COMMAND ) :
  1121. {
  1122. Assert(pSpProp);
  1123. switch (LOWORD(wParam))
  1124. {
  1125. case IDC_PP_SHOW_BALLOON :
  1126. case IDC_PP_LMA :
  1127. case IDC_PP_HIGH_CONFIDENCE :
  1128. case IDC_PP_SAVE_SPDATA :
  1129. case IDC_PP_REMOVE_SPACE :
  1130. case IDC_PP_DIS_DICT_TYPING :
  1131. case IDC_PP_PLAYBACK :
  1132. case IDC_PP_DICT_CANDUI_OPEN :
  1133. case IDC_PP_DICTCMDS :
  1134. case IDC_PP_ASSIGN_BUTTON :
  1135. if ( pSpProp )
  1136. pSpProp->OnCheckButtonSetting( HIWORD(wParam), LOWORD(wParam), (HWND)lParam );
  1137. break;
  1138. case IDC_PP_BUTTON_MB_SETTING :
  1139. case IDC_PP_BUTTON_ADVANCE :
  1140. case IDC_PP_BUTTON_LANGBAR :
  1141. case IDC_PP_BUTTON_SPCPL :
  1142. if ( pSpProp )
  1143. pSpProp->OnPushButtonClicked( HIWORD(wParam), LOWORD(wParam), (HWND)lParam );
  1144. break;
  1145. default :
  1146. iRet = 0;
  1147. }
  1148. iRet = TRUE;
  1149. break;
  1150. }
  1151. case WM_DESTROY :
  1152. {
  1153. Assert(pSpProp);
  1154. if ( pSpProp )
  1155. delete pSpProp;
  1156. break;
  1157. }
  1158. }
  1159. return (iRet);
  1160. }
  1161. //
  1162. // CSapiIMX::InvokeSpeakerOptions
  1163. //
  1164. //
  1165. void CSapiIMX::_InvokeSpeakerOptions( BOOL fLaunchFromInputCpl )
  1166. {
  1167. PROPSHEETHEADERW psh;
  1168. HPROPSHEETPAGE phPages[2];
  1169. // check if this proppage has already shown up and got focus.
  1170. HWND hWndFore;
  1171. hWndFore = ::GetForegroundWindow( );
  1172. if ( hWndFore )
  1173. {
  1174. WCHAR wszTextTitle[MAX_PATH];
  1175. GetWindowTextW(hWndFore, wszTextTitle, ARRAYSIZE(wszTextTitle));
  1176. if ( wcscmp(wszTextTitle, CRStr(IDS_PROPERTYPAGE_TITLE)) == 0 )
  1177. {
  1178. // the proppage has beeb shown and got focus.
  1179. // don't show it again.
  1180. return;
  1181. }
  1182. }
  1183. ::InitCommonControls( );
  1184. // Initialize the property sheet header.
  1185. psh.dwSize = sizeof(PROPSHEETHEADERW);
  1186. psh.dwFlags = 0;
  1187. psh.hwndParent = ::GetActiveWindow( );
  1188. psh.hInstance = GetCicResInstance(g_hInst, IDS_PROPERTYPAGE_TITLE);
  1189. psh.pszCaption = MAKEINTRESOURCEW(IDS_PROPERTYPAGE_TITLE);
  1190. psh.nStartPage = 0;
  1191. psh.phpage = phPages;
  1192. psh.nPages = 0;
  1193. // Add one page for now.
  1194. // extendable for the future.
  1195. CSptipPropertyPage *pSpProp = (CSptipPropertyPage *) new CSptipPropertyPage(IDD_PROPERTY_PAGE, fLaunchFromInputCpl);
  1196. if ( pSpProp )
  1197. {
  1198. PROPSHEETPAGEW psp;
  1199. psp.dwSize = sizeof(PROPSHEETPAGEW);
  1200. psp.dwFlags = PSP_DEFAULT;
  1201. psp.hInstance = GetCicResInstance(g_hInst, pSpProp->GetDlgResId());
  1202. psp.pszTemplate = MAKEINTRESOURCEW( pSpProp->GetDlgResId( ) );
  1203. psp.pfnDlgProc = pSpProp->GetDlgProc( );
  1204. psp.lParam = (LPARAM) pSpProp;
  1205. phPages[psh.nPages] = ::CreatePropertySheetPageW(&psp);
  1206. if (phPages[psh.nPages])
  1207. psh.nPages ++;
  1208. }
  1209. // If there is at least one page exists, create the property sheet.
  1210. //
  1211. if ( psh.nPages > 0 )
  1212. ::PropertySheetW(&psh);
  1213. }