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.

268 lines
7.3 KiB

  1. //
  2. // Include Files.
  3. //
  4. #include "input.h"
  5. #include "util.h"
  6. #include "inputdlg.h"
  7. #include "external.h"
  8. #include "inputhlp.h"
  9. //
  10. // Define global variables.
  11. //
  12. HWND g_hwndAdvanced = NULL;
  13. static BOOL g_bAdmin = FALSE;
  14. //
  15. // Define external variable and rotines.
  16. //
  17. extern g_bAdvChanged;
  18. extern UINT g_iInputs;
  19. extern UINT g_iOrgInputs;
  20. //
  21. // Context Help Ids.
  22. //
  23. static int aAdvancedHelpIds[] =
  24. {
  25. IDC_GROUPBOX1, IDH_COMM_GROUPBOX,
  26. IDC_ADVANCED_CUAS_ENABLE, IDH_ADVANCED_CUAS,
  27. IDC_ADVANCED_CUAS_TEXT, IDH_ADVANCED_CUAS,
  28. IDC_GROUPBOX2, IDH_COMM_GROUPBOX,
  29. IDC_ADVANCED_CTFMON_DISABLE, IDH_ADVANCED_CTFMON,
  30. IDC_ADVANCED_CTFMON_TEXT, IDH_ADVANCED_CTFMON,
  31. 0, 0
  32. };
  33. ////////////////////////////////////////////////////////////////////////////
  34. //
  35. // AdvancedDlgInit
  36. //
  37. ////////////////////////////////////////////////////////////////////////////
  38. void AdvancedDlgInit(HWND hwnd)
  39. {
  40. HKEY hkeyTemp;
  41. //
  42. // Get the setting of enable/disalbe Text Services input
  43. //
  44. if (IsDisableCtfmon())
  45. {
  46. EnableWindow(GetDlgItem(hwnd, IDC_ADVANCED_CUAS_ENABLE), FALSE);
  47. EnableWindow(GetDlgItem(hwnd, IDC_ADVANCED_CUAS_TEXT), FALSE);
  48. CheckDlgButton(hwnd, IDC_ADVANCED_CTFMON_DISABLE, TRUE);
  49. }
  50. else
  51. {
  52. CheckDlgButton(hwnd, IDC_ADVANCED_CTFMON_DISABLE, FALSE);
  53. //
  54. // Show the turned off advanced text service if ctfmon.exe process isn't
  55. // running with the multiple keyboard without adding any new layouts.
  56. //
  57. if (!IsSetupMode() &&
  58. IsEnabledTipOrMultiLayouts() &&
  59. g_iInputs == g_iOrgInputs &&
  60. FindWindow(c_szCTFMonClass, NULL) == NULL)
  61. {
  62. //
  63. // ctfmon.exe process doesn't running with TIP or multi keyboard
  64. // layouts. So change the status as the disabled ctfmon.
  65. //
  66. CheckDlgButton(hwnd, IDC_ADVANCED_CTFMON_DISABLE, TRUE);
  67. EnableWindow(GetDlgItem(hwnd, IDC_ADVANCED_CUAS_ENABLE), FALSE);
  68. EnableWindow(GetDlgItem(hwnd, IDC_ADVANCED_CUAS_TEXT), FALSE);
  69. // Try to keep the disabled status when Apply button is clicked.
  70. g_bAdvChanged = TRUE;
  71. }
  72. }
  73. //
  74. // Get Cicero Unaware Application Support setting info from the registry.
  75. //
  76. if (IsDisableCUAS())
  77. {
  78. // Turn off CUAS
  79. CheckDlgButton(hwnd, IDC_ADVANCED_CUAS_ENABLE, FALSE);
  80. }
  81. else
  82. {
  83. // Turn on CUAS
  84. CheckDlgButton(hwnd, IDC_ADVANCED_CUAS_ENABLE, TRUE);
  85. }
  86. //
  87. // Check the Administrative privileges by the token group SID.
  88. //
  89. if (IsAdminPrivilegeUser())
  90. {
  91. g_bAdmin = TRUE;
  92. }
  93. else
  94. {
  95. // Disable Cicero Unaware Application Support checkbox for local user
  96. EnableWindow(GetDlgItem(hwnd, IDC_ADVANCED_CUAS_ENABLE), FALSE);
  97. EnableWindow(GetDlgItem(hwnd, IDC_ADVANCED_CUAS_TEXT), FALSE);
  98. }
  99. }
  100. ////////////////////////////////////////////////////////////////////////////
  101. //
  102. // InputAdvancedDlgProc
  103. //
  104. // This is the dialog proc for the Input Advanced property sheet.
  105. //
  106. ////////////////////////////////////////////////////////////////////////////
  107. INT_PTR CALLBACK InputAdvancedDlgProc(
  108. HWND hDlg,
  109. UINT message,
  110. WPARAM wParam,
  111. LPARAM lParam)
  112. {
  113. switch (message)
  114. {
  115. case ( WM_HELP ) :
  116. {
  117. WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  118. c_szHelpFile,
  119. HELP_WM_HELP,
  120. (DWORD_PTR)(LPTSTR)aAdvancedHelpIds);
  121. break;
  122. }
  123. case ( WM_CONTEXTMENU ) : // right mouse click
  124. {
  125. WinHelp((HWND)wParam,
  126. c_szHelpFile,
  127. HELP_CONTEXTMENU,
  128. (DWORD_PTR)(LPTSTR)aAdvancedHelpIds);
  129. break;
  130. }
  131. case (WM_INITDIALOG) :
  132. {
  133. HWND hwndCUASText;
  134. HWND hwndCtfmonText;
  135. TCHAR szCUASText[MAX_PATH * 2];
  136. TCHAR szCtfmonText[MAX_PATH * 2];
  137. //
  138. // Save Advanced tab window handle
  139. //
  140. g_hwndAdvanced = hDlg;
  141. //
  142. // Set Cicero Unawared Application Support text string.
  143. //
  144. hwndCUASText = GetDlgItem(hDlg, IDC_ADVANCED_CUAS_TEXT);
  145. CicLoadString(hInstance, IDS_ADVANCED_CUAS_TEXT, szCUASText, MAX_PATH * 2);
  146. SetWindowText(hwndCUASText, szCUASText);
  147. //
  148. // Set disable all advanced text services text string.
  149. //
  150. hwndCtfmonText = GetDlgItem(hDlg, IDC_ADVANCED_CTFMON_TEXT);
  151. CicLoadString(hInstance, IDS_ADVANCED_CTFMON_TEXT, szCtfmonText, MAX_PATH * 2);
  152. SetWindowText(hwndCtfmonText, szCtfmonText);
  153. //
  154. // Initialize CUAS and CTFMON turn off status.
  155. //
  156. AdvancedDlgInit(hDlg);
  157. break;
  158. }
  159. case (WM_NOTIFY) :
  160. {
  161. switch (((NMHDR *)lParam)->code)
  162. {
  163. case (PSN_QUERYCANCEL) :
  164. case (PSN_RESET) :
  165. case (PSN_KILLACTIVE) :
  166. break;
  167. case (PSN_APPLY) :
  168. {
  169. break;
  170. }
  171. default :
  172. {
  173. return (FALSE);
  174. }
  175. }
  176. break;
  177. }
  178. case (WM_COMMAND) :
  179. {
  180. switch (LOWORD(wParam))
  181. {
  182. case (IDC_ADVANCED_CTFMON_DISABLE) :
  183. {
  184. if (IsDlgButtonChecked(hDlg, IDC_ADVANCED_CTFMON_DISABLE))
  185. {
  186. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_CUAS_ENABLE), FALSE);
  187. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_CUAS_TEXT), FALSE);
  188. }
  189. else
  190. {
  191. if (g_bAdmin)
  192. {
  193. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_CUAS_ENABLE), TRUE);
  194. EnableWindow(GetDlgItem(hDlg, IDC_ADVANCED_CUAS_TEXT), TRUE);
  195. }
  196. }
  197. // fall thru...
  198. }
  199. case (IDC_ADVANCED_CUAS_ENABLE) :
  200. {
  201. //
  202. // Set the advanced tab change status to apply it.
  203. //
  204. g_bAdvChanged = TRUE;
  205. PropSheet_Changed(GetParent(hDlg), hDlg);
  206. break;
  207. }
  208. case (IDOK) :
  209. {
  210. // fall thru...
  211. }
  212. case (IDCANCEL) :
  213. {
  214. EndDialog(hDlg, TRUE);
  215. break;
  216. }
  217. default :
  218. {
  219. return (FALSE);
  220. }
  221. }
  222. break;
  223. }
  224. default :
  225. {
  226. return (FALSE);
  227. }
  228. }
  229. return (TRUE);
  230. }