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.

681 lines
24 KiB

  1. /****************************************************************************
  2. CONFIG.CPP
  3. Owner: cslim
  4. Copyright (c) 1997-1999 Microsoft Corporation
  5. IME Configuration DLG and registry access functions
  6. History:
  7. 14-JUL-1999 cslim Copied from IME98 source tree
  8. *****************************************************************************/
  9. #include "precomp.h"
  10. #include "ui.h"
  11. #include "imedefs.h"
  12. #include "debug.h"
  13. #include "common.h"
  14. #include "names.h"
  15. #include "winex.h"
  16. #include "config.h"
  17. #include "cicero.h"
  18. #include "resource.h"
  19. // Config DLG Help ID
  20. #define IDH_GRP_STATUSWIN 1001
  21. #define IDH_JUNBAN_TOGGLE 1002
  22. #define IDH_HANJA_CONV 1003
  23. #define IDH_GRP_KEYLAYOUT 1004
  24. #define IDH_2BEOLSIK 1005
  25. #define IDH_3BEOLSIK_390 1006
  26. #define IDH_3BEOLSIK_FINAL 1007
  27. #define IDH_DELJASO 1008
  28. #define IDH_K1HANJA 1009
  29. // Private functions
  30. static void PASCAL AddPage(LPPROPSHEETHEADERW ppsh, UINT id, DLGPROC pfn);
  31. static INT_PTR CALLBACK ConfigDLGProc1(HWND hDlg, UINT message,
  32. WPARAM wParam, LPARAM lParam);
  33. static int *GetContextHelpList();
  34. static BOOL IsValidCtrlIdForHelp(INT *helpList, INT ctrlId);
  35. static void GetHelpFileName();
  36. int *GetContextHelpList()
  37. {
  38. // Context Help Ids of PropertySheet
  39. static int ProDlgCtxHelpList[] =
  40. {
  41. IDC_GRP_KEYLAYOUT, IDH_GRP_KEYLAYOUT,
  42. IDC_GRP_STATUSWIN, IDH_GRP_STATUSWIN,
  43. IDC_JUNBAN_TOGGLE, IDH_JUNBAN_TOGGLE,
  44. IDC_HANJA_CONV, IDH_HANJA_CONV,
  45. IDC_2BEOLSIK, IDH_2BEOLSIK,
  46. IDC_3BEOLSIK_390, IDH_3BEOLSIK_390,
  47. IDC_3BEOLSIK_FINAL, IDH_3BEOLSIK_FINAL,
  48. IDC_DELJASO, IDH_DELJASO,
  49. IDC_K1HANJA, IDH_K1HANJA,
  50. 0, 0
  51. };
  52. return ProDlgCtxHelpList;
  53. }
  54. BOOL IsValidCtrlIdForHelp(INT *helpList, INT ctrlId)
  55. {
  56. INT *p;
  57. for(p = helpList; *p != 0; p+=2)
  58. {
  59. if(ctrlId == *p)
  60. return fTrue;
  61. }
  62. return fFalse;
  63. }
  64. void GetHelpFileName(LPTSTR szHelpFileNameFull, int cchszHelpFileNameFull)
  65. {
  66. // WARNING: This only will work for NT or Win98. For Win95 need to check system locale
  67. OurLoadStringA(vpInstData->hInst, IDS_CONTEXTHELP_FILENAME, szHelpFileNameFull, MAX_PATH);
  68. }
  69. static HWND hwndPropSheet = (HWND)0;
  70. static BOOL g_fDestroyPropNow = FALSE;
  71. BOOL ConfigDLG(HWND hwndParent)
  72. {
  73. static HPROPSHEETPAGE rPages[1];
  74. static PROPSHEETHEADERW psh;
  75. static WCHAR szCaption[64];
  76. MSG msg;
  77. BOOL fRet = fFalse;
  78. // If config DLG already created
  79. if (IsWindow(hwndPropSheet))
  80. {
  81. SetForegroundWindow(hwndPropSheet);
  82. return fTrue;
  83. }
  84. // init msg
  85. ZeroMemory(&msg, sizeof(MSG));
  86. psh.dwSize = sizeof(psh);
  87. psh.dwFlags = PSH_NOAPPLYNOW | PSH_USEICONID | PSH_MODELESS | PSH_USEPAGELANG;
  88. psh.hwndParent = hwndParent;
  89. psh.hInstance = vpInstData->hInst;
  90. if (IsWinNT())
  91. OurLoadStringW(vpInstData->hInst, IDS_PROGRAM, szCaption, sizeof(szCaption)/sizeof(WCHAR));
  92. else
  93. OurLoadStringA(vpInstData->hInst, IDS_PROGRAM, (LPSTR)szCaption, sizeof(szCaption));
  94. psh.pszCaption = szCaption;
  95. psh.nPages = 0;
  96. psh.nStartPage = 0;
  97. psh.phpage = rPages;
  98. AddPage(&psh, IDD_CONFIG_PAGE1, ConfigDLGProc1);
  99. // if (PropertySheet(&psh) != -1)
  100. // return fTrue;
  101. // else
  102. // return fFalse;
  103. if (IsWinNT())
  104. hwndPropSheet = (HWND)PropertySheetW(&psh);
  105. else
  106. hwndPropSheet = (HWND)PropertySheetA((PROPSHEETHEADERA*)&psh);
  107. while (IsWindow(hwndPropSheet) && OurGetMessage(&msg, NULL, 0x00, 0x00))
  108. {
  109. // If the modeless guy is up and is ready to be destroyed
  110. // (PropSheet_GetCurrentPageHwnd returns NULL) then destroy the dialog.
  111. // PropSheet_GetCurrentPageHwnd will return NULL after the OK or Cancel
  112. // button has been pressed and all of the pages have been notified. The
  113. // Apply button doesn't cause this to happen.
  114. if(/*g_fDestroyPropNow == fTrue || */(hwndPropSheet && (NULL == PropSheet_GetCurrentPageHwnd(hwndPropSheet)))) {
  115. //enable the parent first to prevent another window from becoming the foreground window
  116. //EnableWindow(hwndParent, TRUE);
  117. DestroyWindow(hwndPropSheet);
  118. //break;
  119. }
  120. //use PropSheet_IsDialogMessage instead of IsDialogMessage
  121. if(!PropSheet_IsDialogMessage(hwndPropSheet, &msg))
  122. {
  123. TranslateMessage(&msg);
  124. if (IsWinNT())
  125. DispatchMessageW(&msg);
  126. else
  127. DispatchMessageA(&msg);
  128. }
  129. }
  130. hwndPropSheet = (HWND)0;
  131. // if (g_fDestroyPropNow == fTrue) // closed a property sheet by the other process
  132. // PostMessage(hwndParent, WM_PAUSERESUME, TRUE, FALSE); // close engine
  133. // g_fDestroyPropNow = fFalse;
  134. return fTrue;
  135. }
  136. void PASCAL AddPage(LPPROPSHEETHEADERW ppsh, UINT idDlg, DLGPROC pfn)
  137. {
  138. //if (ppsh->nPages < 3)
  139. //{
  140. PROPSHEETPAGE psp;
  141. ZeroMemory(&psp, sizeof(psp));
  142. psp.dwSize = sizeof(psp);
  143. psp.dwFlags = PSP_DLGINDIRECT;
  144. psp.hInstance = vpInstData->hInst;
  145. psp.pResource = ExLoadDialogTemplate(GetSystemDefaultLangID(), vpInstData->hInst, MAKEINTRESOURCE(idDlg));
  146. psp.pfnDlgProc = pfn;
  147. psp.lParam = 0;
  148. ppsh->phpage[ppsh->nPages] = CreatePropertySheetPage(&psp);
  149. if (ppsh->phpage[ppsh->nPages])
  150. ppsh->nPages++;
  151. //}
  152. }
  153. INT_PTR CALLBACK ConfigDLGProc1(HWND hDlg, UINT message , WPARAM wParam, LPARAM lParam)
  154. {
  155. UINT i;
  156. static StatusButtonTypes prevButtonTypes[MAX_NUM_OF_STATUS_BUTTONS];
  157. static UINT uPrevNumOfButtons, uPrevKeyboardType;
  158. static BOOL fPrevJasoDel;
  159. static BOOL fK1Hanja;
  160. BOOL fShowIME=fTrue;
  161. BOOL fFound = fFalse;
  162. TCHAR szHelpFileNameFull[MAX_PATH];
  163. CIMEData ImeData(CIMEData::SMReadWrite);
  164. // When no IME instance is running on the system, we should init shared mem.
  165. ImeData.InitImeData();
  166. Dbg(DBGID_Misc, TEXT("ConfigDLGProc"));
  167. switch(message)
  168. {
  169. case WM_NOTIFY:
  170. switch (((NMHDR FAR *)lParam)->code)
  171. {
  172. case PSN_APPLY:
  173. DbgAssert(uPrevNumOfButtons <= MAX_NUM_OF_STATUS_BUTTONS);
  174. ImeData->uNumOfButtons = uPrevNumOfButtons;
  175. for (i = 0; i<MAX_NUM_OF_STATUS_BUTTONS; i++)
  176. ImeData->StatusButtons[i].m_ButtonType = prevButtonTypes[i];
  177. UpdateStatusButtons(ImeData);
  178. UpdateStatusWinDimension();
  179. ImeData.SetCurrentBeolsik(uPrevKeyboardType);
  180. ImeData.SetJasoDel(fPrevJasoDel);
  181. ImeData.SetKSC5657Hanja(fK1Hanja);
  182. SetRegValues(GETSET_REG_STATUS_BUTTONS|GETSET_REG_IMEKL|GETSET_REG_JASODEL|GETSET_REG_KSC5657);
  183. break;
  184. default:
  185. return fFalse;
  186. }
  187. break;
  188. case WM_INITDIALOG:
  189. DbgAssert(ImeData->uNumOfButtons <= MAX_NUM_OF_STATUS_BUTTONS);
  190. uPrevNumOfButtons = ImeData->uNumOfButtons;
  191. // Backup current button status
  192. for (i=0; i<MAX_NUM_OF_STATUS_BUTTONS; i++)
  193. prevButtonTypes[i] = ImeData->StatusButtons[i].m_ButtonType;
  194. for (i = 0; i < uPrevNumOfButtons; i++)
  195. {
  196. switch (prevButtonTypes[i])
  197. {
  198. case JUNJA_BANJA_TOGGLE_BUTTON:
  199. CheckDlgButton(hDlg, IDC_JUNBAN_TOGGLE, BST_CHECKED);
  200. break;
  201. case HANJA_CONV_BUTTON:
  202. CheckDlgButton(hDlg, IDC_HANJA_CONV, BST_CHECKED);
  203. break;
  204. case IME_PAD_BUTTON:
  205. CheckDlgButton(hDlg, IDC_IMEPAD, BST_CHECKED);
  206. break;
  207. }
  208. }
  209. // Get Show IME stataus window flag
  210. // If this flag is fFalse disable all show button check boxes
  211. SystemParametersInfo(SPI_GETSHOWIMEUI, 0, (PVOID)&fShowIME, 0);
  212. if (fShowIME==fFalse || IsCicero())
  213. {
  214. EnableWindow(GetDlgItem(hDlg, IDC_JUNBAN_TOGGLE), fFalse);
  215. EnableWindow(GetDlgItem(hDlg, IDC_HANJA_CONV), fFalse);
  216. EnableWindow(GetDlgItem(hDlg, IDC_IMEPAD), fFalse);
  217. }
  218. #if defined(_WIN64)
  219. EnableWindow(GetDlgItem(hDlg, IDC_IMEPAD), fFalse);
  220. #endif
  221. uPrevKeyboardType = ImeData.GetCurrentBeolsik();
  222. CheckRadioButton(hDlg, IDC_2BEOLSIK, IDC_3BEOLSIK_FINAL, IDC_2BEOLSIK+uPrevKeyboardType);
  223. fPrevJasoDel = ImeData.GetJasoDel();
  224. if (fPrevJasoDel)
  225. CheckDlgButton(hDlg, IDC_DELJASO, BST_CHECKED);
  226. else
  227. CheckDlgButton(hDlg, IDC_DELJASO, BST_UNCHECKED);
  228. // KSC-5657 Hanja
  229. fK1Hanja = ImeData.GetKSC5657Hanja() && (vpInstData->f16BitApps == fFalse) && !IsWin95();
  230. if (fK1Hanja)
  231. CheckDlgButton(hDlg, IDC_K1HANJA, BST_CHECKED);
  232. else
  233. CheckDlgButton(hDlg, IDC_K1HANJA, BST_UNCHECKED);
  234. // If 16 bit Apps disable K1 Hanja
  235. if (vpInstData->f16BitApps || IsWin95())
  236. EnableWindow(GetDlgItem(hDlg, IDC_K1HANJA), fFalse);
  237. return fTrue;
  238. case WM_COMMAND:
  239. switch (wParam)
  240. {
  241. case IDC_2BEOLSIK:
  242. //if (IsDlgButtonChecked(hDlg, IDC_2BEOLSIK)) {
  243. uPrevKeyboardType = KL_2BEOLSIK;
  244. //}
  245. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  246. break;
  247. case IDC_3BEOLSIK_390:
  248. uPrevKeyboardType = KL_3BEOLSIK_390;
  249. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  250. break;
  251. case IDC_3BEOLSIK_FINAL:
  252. uPrevKeyboardType = KL_3BEOLSIK_FINAL;
  253. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  254. break;
  255. case IDC_JUNBAN_TOGGLE:
  256. // Jun/Banja toggle button setting
  257. if (IsDlgButtonChecked(hDlg, IDC_JUNBAN_TOGGLE))
  258. {
  259. if (prevButtonTypes[1] != JUNJA_BANJA_TOGGLE_BUTTON)
  260. {
  261. for (i = uPrevNumOfButtons-1; i >= 1; i--)
  262. prevButtonTypes[i+1] = prevButtonTypes[i];
  263. prevButtonTypes[1] = JUNJA_BANJA_TOGGLE_BUTTON;
  264. uPrevNumOfButtons++;
  265. }
  266. }
  267. else
  268. {
  269. if (prevButtonTypes[1] == JUNJA_BANJA_TOGGLE_BUTTON)
  270. {
  271. for (i = 1; i < uPrevNumOfButtons-1; i++)
  272. prevButtonTypes[i] = prevButtonTypes[i+1];
  273. prevButtonTypes[uPrevNumOfButtons] = NULL_BUTTON;
  274. uPrevNumOfButtons--;
  275. }
  276. }
  277. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  278. break;
  279. case IDC_HANJA_CONV:
  280. for (i = 1; i < uPrevNumOfButtons; i++)
  281. {
  282. if (prevButtonTypes[i] == HANJA_CONV_BUTTON)
  283. {
  284. fFound = fTrue;
  285. break;
  286. }
  287. }
  288. // Hanja conv button setting
  289. if (IsDlgButtonChecked(hDlg, IDC_HANJA_CONV))
  290. {
  291. if (fFound == fFalse)
  292. {
  293. if (prevButtonTypes[uPrevNumOfButtons-1] == IME_PAD_BUTTON)
  294. {
  295. prevButtonTypes[uPrevNumOfButtons-1] = HANJA_CONV_BUTTON;
  296. prevButtonTypes[uPrevNumOfButtons] = IME_PAD_BUTTON;
  297. }
  298. else
  299. {
  300. prevButtonTypes[uPrevNumOfButtons] = HANJA_CONV_BUTTON;
  301. }
  302. uPrevNumOfButtons++;
  303. }
  304. }
  305. else
  306. {
  307. if (fFound == fTrue)
  308. {
  309. uPrevNumOfButtons--;
  310. for (; i < uPrevNumOfButtons; i++)
  311. prevButtonTypes[i] = prevButtonTypes[i+1];
  312. prevButtonTypes[uPrevNumOfButtons] = NULL_BUTTON;
  313. }
  314. }
  315. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  316. break;
  317. case IDC_IMEPAD:
  318. if (IsDlgButtonChecked(hDlg, IDC_IMEPAD))
  319. {
  320. if (prevButtonTypes[uPrevNumOfButtons-1] != IME_PAD_BUTTON)
  321. prevButtonTypes[uPrevNumOfButtons++] = IME_PAD_BUTTON;
  322. }
  323. else
  324. {
  325. if (prevButtonTypes[uPrevNumOfButtons-1] == IME_PAD_BUTTON)
  326. prevButtonTypes[--uPrevNumOfButtons] = NULL_BUTTON;
  327. }
  328. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  329. break;
  330. case IDC_DELJASO:
  331. if (IsDlgButtonChecked(hDlg, IDC_DELJASO))
  332. fPrevJasoDel = fTrue;
  333. else
  334. fPrevJasoDel = fFalse;
  335. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  336. break;
  337. case IDC_K1HANJA:
  338. if (IsDlgButtonChecked(hDlg, IDC_K1HANJA))
  339. fK1Hanja = fTrue;
  340. else
  341. fK1Hanja = fFalse;
  342. OurSendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)hDlg, 0L);
  343. break;
  344. default:
  345. return fFalse;
  346. }
  347. break;
  348. case WM_CONTEXTMENU:
  349. GetHelpFileName(szHelpFileNameFull, MAX_PATH);
  350. WinHelp((HWND)wParam,
  351. szHelpFileNameFull,
  352. HELP_CONTEXTMENU,
  353. (ULONG_PTR)(LPVOID)GetContextHelpList());
  354. return 0;
  355. case WM_HELP:
  356. INT *pHelpList;
  357. pHelpList = GetContextHelpList();
  358. if(IsValidCtrlIdForHelp(pHelpList, ((LPHELPINFO)lParam)->iCtrlId))
  359. {
  360. GetHelpFileName(szHelpFileNameFull, MAX_PATH);
  361. WinHelp((HWND)((LPHELPINFO)lParam)->hItemHandle,
  362. szHelpFileNameFull,
  363. HELP_WM_HELP,
  364. (ULONG_PTR)pHelpList);
  365. }
  366. return 0;
  367. default:
  368. return fFalse;
  369. }
  370. return fTrue;
  371. }
  372. BOOL GetStatusWinPosReg(POINT *pptStatusWinPosReg)
  373. {
  374. HKEY hKey;
  375. DWORD dwBuf, dwCb;
  376. BOOL fSuccess = fFalse;
  377. // Prevent Winlogon process from accessing registry
  378. if ((vpInstData->dwSystemInfoFlags & IME_SYSINFO_WINLOGON))
  379. return fFalse;
  380. if (RegOpenKeyEx(HKEY_CURRENT_USER, g_szIMEKL, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
  381. {
  382. dwCb = sizeof(dwBuf);
  383. if (RegQueryValueEx(hKey, g_szStatusPos, NULL, NULL, (LPBYTE)&dwBuf, &dwCb) == ERROR_SUCCESS)
  384. {
  385. pptStatusWinPosReg->x = HIWORD(dwBuf);
  386. pptStatusWinPosReg->y = LOWORD(dwBuf);
  387. fSuccess = fTrue;
  388. }
  389. RegCloseKey(hKey);
  390. }
  391. return fSuccess;
  392. }
  393. ///////////////////////////////////////////////////////////////////////////////
  394. //
  395. BOOL GetRegValues(UINT uGetBits)
  396. {
  397. HKEY hKey;
  398. DWORD dwBuf, dwCb, dwType;
  399. CHAR szLexFileName[MAX_PATH];
  400. CIMEData ImeData(CIMEData::SMReadWrite);
  401. BOOL fSuccess = fTrue;
  402. Dbg(DBGID_Misc, "GetRegValues()");
  403. if (RegOpenKeyEx(HKEY_CURRENT_USER, g_szIMERootKey, 0, KEY_ALL_ACCESS, &hKey) == ERROR_SUCCESS)
  404. {
  405. ///////////////////////////////////////////////////////////////////
  406. // IME Keyboard Layout
  407. if (uGetBits & GETSET_REG_IMEKL)
  408. {
  409. dwCb = sizeof(dwBuf);
  410. if (RegQueryValueEx(hKey, g_szIMEKL, NULL, NULL, (LPBYTE)&dwBuf, &dwCb)
  411. == ERROR_SUCCESS)
  412. {
  413. if (/*dwBuf >= KL_2BEOLSIK &&*/ dwBuf <= KL_3BEOLSIK_FINAL)
  414. ImeData.SetCurrentBeolsik(dwBuf);
  415. }
  416. else
  417. fSuccess = fFalse;
  418. }
  419. ///////////////////////////////////////////////////////////////////
  420. // Status window pos
  421. if (uGetBits & GETSET_REG_STATUSPOS)
  422. {
  423. dwCb = sizeof(dwBuf);
  424. if (RegQueryValueEx(hKey, g_szStatusPos, NULL, NULL, (LPBYTE)&dwBuf, &dwCb) == ERROR_SUCCESS)
  425. {
  426. ImeData->ptStatusPos.x = HIWORD(dwBuf);
  427. ImeData->ptStatusPos.y = LOWORD(dwBuf);
  428. }
  429. else
  430. fSuccess = fFalse;
  431. }
  432. ///////////////////////////////////////////////////////////////////
  433. // Status window button setting
  434. if (uGetBits & GETSET_REG_STATUS_BUTTONS)
  435. {
  436. BYTE ButtonReg[MAX_NUM_OF_STATUS_BUTTONS+1];
  437. int nButton;
  438. dwCb = sizeof(ButtonReg);
  439. dwType = REG_BINARY;
  440. if (RegQueryValueEx(hKey, g_szStatusButtons, NULL, &dwType, (LPBYTE)&ButtonReg, &dwCb) == ERROR_SUCCESS)
  441. {
  442. if (ButtonReg[0] == 0)
  443. ButtonReg[0] = 1;
  444. if (ButtonReg[0]<=MAX_NUM_OF_STATUS_BUTTONS)
  445. {
  446. for (nButton=0; nButton<ButtonReg[0]; nButton++)
  447. {
  448. // button data validity check
  449. #if !defined(_WIN64)
  450. if (ButtonReg[nButton+1] <= IME_PAD_BUTTON && ButtonReg[nButton+1] != NULL_BUTTON)
  451. #else
  452. if (ButtonReg[nButton+1] <= HANJA_CONV_BUTTON && ButtonReg[nButton+1] != NULL_BUTTON)
  453. #endif
  454. ImeData->StatusButtons[nButton].m_ButtonType = (StatusButtonTypes)ButtonReg[nButton+1];
  455. else
  456. break;
  457. }
  458. ImeData->uNumOfButtons = nButton;
  459. UpdateStatusButtons(ImeData);
  460. UpdateStatusWinDimension();
  461. }
  462. }
  463. else
  464. fSuccess = fFalse;
  465. }
  466. ///////////////////////////////////////////////////////////////////
  467. // Deletion by Jaso
  468. if (uGetBits & GETSET_REG_JASODEL)
  469. {
  470. dwCb = sizeof(dwBuf);
  471. if (RegQueryValueEx(hKey, g_szCompDel, NULL, NULL, (LPBYTE)&dwBuf, &dwCb)
  472. == ERROR_SUCCESS)
  473. ImeData.SetJasoDel(dwBuf);
  474. }
  475. if (uGetBits & GETSET_REG_ISO10646)
  476. {
  477. Dbg(DBGID_Misc, "GetRegValues() : vpInstData->f16BitApps = %d", vpInstData->f16BitApps);
  478. // If 16bit apps, always disable ISO10646(full range Hangul)
  479. if (vpInstData->f16BitApps == fTrue)
  480. {
  481. vpInstData->fISO10646 = fFalse;
  482. }
  483. else
  484. {
  485. dwCb = sizeof(dwBuf);
  486. if (RegQueryValueEx(hKey, g_szXWEnable, NULL, NULL, (LPBYTE)&dwBuf, &dwCb)
  487. == ERROR_SUCCESS)
  488. vpInstData->fISO10646 = dwBuf;
  489. else
  490. fSuccess = fFalse;
  491. // For Win95 and Win98 lookup INI file for ISO10646 setting.
  492. // ISO10646.EXE set registry
  493. if (!IsWinNT())
  494. vpInstData->fISO10646 = GetProfileInt(g_szXWEnable,
  495. OurGetModuleFileName(fFalse),
  496. vpInstData->fISO10646);
  497. }
  498. }
  499. // Get KSC5657 K1 Hanja flag
  500. if (uGetBits & GETSET_REG_KSC5657)
  501. {
  502. dwCb = sizeof(dwBuf);
  503. dwType = REG_DWORD;
  504. if (RegQueryValueEx(hKey, g_szEnableK1Hanja, NULL, &dwType, (LPBYTE)&dwBuf, &dwCb) == ERROR_SUCCESS)
  505. ImeData->fKSC5657Hanja = dwBuf;
  506. else
  507. ImeData->fKSC5657Hanja = fFalse;
  508. }
  509. // Get Unicode Tooltip Cand window flag
  510. // Currently this has no UI part which means hidden spec so no need SetReg now.
  511. if (uGetBits & GETSET_REG_CANDUNICODETT)
  512. {
  513. dwCb = sizeof(dwBuf);
  514. dwType = REG_DWORD;
  515. if (RegQueryValueEx(hKey, g_szEnableCandUnicodeTT, NULL, &dwType, (LPBYTE)&dwBuf, &dwCb) == ERROR_SUCCESS)
  516. ImeData->fCandUnicodeTT = dwBuf;
  517. else
  518. ImeData->fCandUnicodeTT = fFalse;
  519. }
  520. RegCloseKey(hKey);
  521. }
  522. else
  523. {
  524. fSuccess = fFalse;
  525. // DbgBreak can happen when logon and cumbersome especially in stress machine running chk build.
  526. // DbgAssert(0);
  527. }
  528. return fSuccess;
  529. }
  530. BOOL SetRegValues(UINT uSetBits)
  531. {
  532. HKEY hKey;
  533. DWORD dwBuf, dwCb;
  534. int nButton;
  535. CIMEData ImeData;
  536. ///////////////////////////////////////////////////////////////////////////
  537. // Set status pos
  538. if (RegCreateKey(HKEY_CURRENT_USER, g_szIMERootKey, &hKey) == ERROR_SUCCESS)
  539. {
  540. if (uSetBits & GETSET_REG_STATUSPOS)
  541. {
  542. dwCb = sizeof(dwBuf);
  543. dwBuf = (ImeData->ptStatusPos.x << 16) | (ImeData->ptStatusPos.y & 0xFFFF); // HIWORD : X, LOWORD : Y
  544. RegSetValueEx(hKey, g_szStatusPos, 0, REG_DWORD, (LPBYTE)&dwBuf, dwCb);
  545. }
  546. if (uSetBits & GETSET_REG_STATUS_BUTTONS)
  547. {
  548. BYTE ButtonReg[MAX_NUM_OF_STATUS_BUTTONS+1];
  549. dwCb = sizeof(ButtonReg);
  550. DbgAssert(ImeData->uNumOfButtons <= MAX_NUM_OF_STATUS_BUTTONS);
  551. // set number of button as the first element of array
  552. if (ImeData->uNumOfButtons<=MAX_NUM_OF_STATUS_BUTTONS)
  553. ButtonReg[0] = (BYTE)ImeData->uNumOfButtons;
  554. for (nButton=0; nButton < (INT)ImeData->uNumOfButtons; nButton++)
  555. ButtonReg[nButton+1] = ImeData->StatusButtons[nButton].m_ButtonType;
  556. // clear
  557. for (; nButton<MAX_NUM_OF_STATUS_BUTTONS; nButton++)
  558. ButtonReg[nButton+1] = NULL_BUTTON;
  559. RegSetValueEx(hKey, g_szStatusButtons, 0, REG_BINARY, (LPBYTE)&ButtonReg, dwCb);
  560. }
  561. if (uSetBits & GETSET_REG_IMEKL)
  562. {
  563. dwCb = sizeof(dwBuf);
  564. dwBuf = ImeData.GetCurrentBeolsik();
  565. RegSetValueEx(hKey, g_szIMEKL, 0, REG_DWORD, (LPBYTE)&dwBuf, dwCb);
  566. }
  567. if (uSetBits & GETSET_REG_JASODEL)
  568. {
  569. dwCb = sizeof(dwBuf);
  570. dwBuf = ImeData.GetJasoDel();
  571. RegSetValueEx(hKey, g_szCompDel, 0, REG_DWORD, (LPBYTE)&dwBuf, dwCb);
  572. }
  573. // Get KSC5657 K1 Hanja flag
  574. if (uSetBits & GETSET_REG_KSC5657)
  575. {
  576. dwCb = sizeof(dwBuf);
  577. dwBuf = ImeData.GetKSC5657Hanja();
  578. RegSetValueEx(hKey, g_szEnableK1Hanja, 0, REG_DWORD, (LPBYTE)&dwBuf, dwCb);
  579. }
  580. RegCloseKey(hKey);
  581. }
  582. else
  583. return fFalse;
  584. return fTrue;
  585. }