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.

555 lines
22 KiB

  1. // PageIni.cpp : Implementation of CPageIni
  2. #include "stdafx.h"
  3. #if FALSE
  4. //#include "PageInternational.h"
  5. //#include <windowsx.h>
  6. /*
  7. * Convert an object (X) to a count of bytes (cb).
  8. */
  9. #define cbX(X) sizeof(X)
  10. /*
  11. * Convert an array name (A) to a generic count (c).
  12. */
  13. #define cA(a) (cbX(a)/cbX(a[0]))
  14. static const TCHAR REGSTR_VAL_DOSVMCP[] = TEXT("DOSCP");
  15. static const TCHAR REGSTR_VAL_DOSCC[] = TEXT("DOSCC");
  16. static const TCHAR REGSTR_VAL_DOSCFN[] = TEXT("DOSCFN");
  17. static const TCHAR REGSTR_VAL_DOSCPFN[] = TEXT("DOSCPFN");
  18. static const TCHAR REGSTR_VAL_DOSKFN[] = TEXT("DOSKFN");
  19. static const TCHAR REGSTR_VAL_DOSKT[] = TEXT("DOSKT");
  20. static const TCHAR REGSTR_VAL_DOSKL[] = TEXT("DOSKL");
  21. static const TCHAR REGSTR_VAL_DOSLID[] = TEXT("DOSLID");
  22. static const TCHAR c_CodepageKey[] = TEXT("System\\CurrentControlSet\\Control\\Nls\\Codepage");
  23. // Language ID defines
  24. #define NO_LANG_ID TEXT(" ")
  25. #define LANG_ID_BE TEXT("be")
  26. #define LANG_ID_BG TEXT("bg")
  27. #define LANG_ID_BL TEXT("bl")
  28. #define LANG_ID_BR TEXT("br")
  29. #define LANG_ID_CA TEXT("ca")
  30. #define LANG_ID_CF TEXT("cf")
  31. #define LANG_ID_CZ TEXT("cz")
  32. #define LANG_ID_DK TEXT("dk")
  33. #define LANG_ID_ET TEXT("et")
  34. #define LANG_ID_FR TEXT("fr")
  35. #define LANG_ID_GK TEXT("gk")
  36. #define LANG_ID_GR TEXT("gr")
  37. #define LANG_ID_HE TEXT("he")
  38. #define LANG_ID_HU TEXT("hu")
  39. #define LANG_ID_IS TEXT("is")
  40. #define LANG_ID_IT TEXT("it")
  41. #define LANG_ID_LA TEXT("la")
  42. #define LANG_ID_NL TEXT("nl")
  43. #define LANG_ID_NO TEXT("no")
  44. #define LANG_ID_PL TEXT("pl")
  45. #define LANG_ID_PO TEXT("po")
  46. #define LANG_ID_RO TEXT("ro")
  47. #define LANG_ID_RU TEXT("ru")
  48. #define LANG_ID_SF TEXT("sf")
  49. #define LANG_ID_SG TEXT("sg")
  50. #define LANG_ID_SL TEXT("sl")
  51. #define LANG_ID_SP TEXT("sp")
  52. #define LANG_ID_SU TEXT("su")
  53. #define LANG_ID_SV TEXT("sv")
  54. #define LANG_ID_TR TEXT("tr")
  55. #define LANG_ID_UK TEXT("uk")
  56. #define LANG_ID_UR TEXT("ur")
  57. #define LANG_ID_YC TEXT("yc")
  58. #define LANG_ID_YU TEXT("yu")
  59. //----------------------------------------------------------------------
  60. // International settings for all code pages
  61. INTL_INFO cp_874[] = {
  62. {IDS_THAI, 0, 0, 0, 0, NO_LANG_ID, 0, 0, 0},
  63. };
  64. INTL_INFO cp_932[] = {
  65. {IDS_JAPANESE_101, 932, 81, 101, 0, NO_LANG_ID, IDS_COUNTRY_SYS, 0, IDS_JKEYBRD_SYS},
  66. {IDS_JAPANESE_106, 932, 81, 106, 0, NO_LANG_ID, IDS_COUNTRY_SYS, 0, IDS_JKEYBRD_SYS},
  67. };
  68. INTL_INFO cp_936[] = {
  69. {IDS_CHINA, 936, 86, 0, 0, NO_LANG_ID, 0, 0, 0},
  70. };
  71. INTL_INFO cp_949[] = {
  72. {IDS_KOREAN, 949, 82, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, 0, 0},
  73. };
  74. INTL_INFO cp_950[] = {
  75. {IDS_TAIWAN, 950, 88, 0, 0, NO_LANG_ID, 0, 0, 0},
  76. };
  77. INTL_INFO cp_1250[] = {
  78. {IDS_ALBANIAN, 852, 355, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  79. {IDS_CROATIAN, 852, 385, 0, 0, LANG_ID_YU, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  80. {IDS_CZECH, 852, 42, 0, 0, LANG_ID_CZ, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  81. {IDS_HUNGARIAN, 852, 36, 0, 0, LANG_ID_HU, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  82. {IDS_POLISH, 852, 48, 0, 0, LANG_ID_PL, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  83. {IDS_POLISH_Prgmers, 852, 48, 0, 0, LANG_ID_PL, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD4_SYS},
  84. {IDS_ROMANIAN, 852, 40, 0, 0, LANG_ID_RO, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  85. {IDS_SLOVAK, 852, 421, 0, 0, LANG_ID_SL, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  86. {IDS_SLOVENIAN, 852, 386, 0, 0, LANG_ID_YU, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBRD2_SYS},
  87. };
  88. INTL_INFO cp_1251[] = {
  89. {IDS_BELARUSSIAN, 866, 375, 0, 0, LANG_ID_BL, IDS_COUNTRY_SYS, IDS_EGA3_CPI, IDS_KEYBRD3_SYS},
  90. {IDS_BULGARIAN, 855, 359, 0, 0, LANG_ID_BG, IDS_COUNTRY_SYS, IDS_EGA3_CPI, IDS_KEYBRD2_SYS},
  91. {IDS_RUSSIAN, 866, 7, 0, 0, LANG_ID_RU, IDS_COUNTRY_SYS, IDS_EGA3_CPI, IDS_KEYBRD3_SYS},
  92. {IDS_SERBIAN, 855, 381, 0, 0, LANG_ID_YC, IDS_COUNTRY_SYS, IDS_EGA3_CPI, IDS_KEYBRD2_SYS},
  93. {IDS_UKRANIAN, 866, 380, 0, 0, LANG_ID_UR, IDS_COUNTRY_SYS, IDS_EGA3_CPI, IDS_KEYBRD3_SYS},
  94. };
  95. INTL_INFO cp_1252[] = {
  96. {IDS_AFRICAN, 850, 27, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  97. {IDS_BASQUE, 850, 34, 0, 0, LANG_ID_SP, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  98. {IDS_CATALAN, 850, 34, 0, 0, LANG_ID_SP, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  99. {IDS_DANISH, 850, 31, 0, 0, LANG_ID_DK, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  100. {IDS_DUTCH_Belgian, 850, 32, 0, 0, LANG_ID_BE, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  101. {IDS_DUTCH_Standard, 850, 31, 0, 0, LANG_ID_NL, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  102. {IDS_ENGLISH_United_States, 0, 0, 0, 0, NO_LANG_ID, 0, 0, 0},
  103. {IDS_ENGLISH_Australian, 437, 61, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  104. {IDS_ENGLISH_British, 850, 44, 0, 0, LANG_ID_UK, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  105. {IDS_ENGLISH_Canadian, 850, 4, 0, 0, LANG_ID_CA, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  106. {IDS_ENGLISH_Ireland, 850, 353, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  107. {IDS_ENGLISH_New_Zealand, 850, 64, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  108. {IDS_FINISH, 850, 358, 0, 0, LANG_ID_SU, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  109. {IDS_FRENCH_Belgian, 850, 32, 0, 0, LANG_ID_BE, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  110. {IDS_FRENCH_Canadian, 850, 2, 0, 0, LANG_ID_CF, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  111. {IDS_FRENCH_Luxembourg, 850, 33, 0, 0, LANG_ID_FR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  112. {IDS_FRENCH_Standard, 850, 33, 0, 0, LANG_ID_FR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  113. {IDS_FRENCH_Swiss, 850, 41, 0, 0, LANG_ID_SF, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  114. {IDS_GERMAN_Austrian, 850, 43, 0, 0, LANG_ID_GR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  115. {IDS_GERMAN_Liechtenstein, 850, 49, 0, 0, LANG_ID_GR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  116. {IDS_GERMAN_Luxembourg, 850, 49, 0, 0, LANG_ID_GR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  117. {IDS_GERMAN_Standard, 850, 49, 0, 0, LANG_ID_GR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  118. {IDS_GERMAN_Swiss, 850, 41, 0, 0, LANG_ID_SG, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  119. {IDS_ICELANDIC, 850, 354, 0, 0, LANG_ID_IS, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  120. {IDS_INDONESIAN, 850, 785, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA_CPI, 0},
  121. {IDS_ITALIAN_Standard, 850, 39, 0, 0, LANG_ID_IT, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  122. {IDS_ITALIAN_142_Standard, 850, 39, 0, 142, LANG_ID_IT, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  123. {IDS_ITALIAN_Swiss, 850, 41, 0, 0, LANG_ID_IT, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  124. {IDS_NORWEGIAN, 850, 47, 0, 0, LANG_ID_NO, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  125. {IDS_PORTUGUESE_Standard, 850, 351, 0, 0, LANG_ID_PO, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  126. {IDS_PORTUGUESE_Brazilian, 850, 55, 0, 0, LANG_ID_BR, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  127. {IDS_SPANISH_Argentina, 850, 54, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  128. {IDS_SPANISH_Bolivia, 850, 591, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  129. {IDS_SPANISH_Chile, 850, 56, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  130. {IDS_SPANISH_Colombia, 850, 57, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  131. {IDS_SPANISH_Costa_Rica, 850, 3, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  132. {IDS_SPANISH_Ecuador, 850, 593, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  133. {IDS_SPANISH_El_Salvador, 850, 503, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  134. {IDS_SPANISH_Honduras, 850, 504, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  135. {IDS_SPANISH_Mexico, 850, 52, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  136. {IDS_SPANISH_Modern_Sort, 850, 34, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  137. {IDS_SPANISH_Nicaragua, 850, 505, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  138. {IDS_SPANISH_Venezuela, 850, 58, 0, 0, LANG_ID_LA, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  139. {IDS_SWEDISH, 850, 46, 0, 0, LANG_ID_SV, IDS_COUNTRY_SYS, IDS_EGA_CPI, IDS_KEYBOARD_SYS},
  140. };
  141. INTL_INFO cp_1253[] = {
  142. {IDS_GREEK_737_LATIN, 737, 30, 0, 0, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  143. {IDS_GREEK_737_437_LATIN, 737, 30, 0, 0, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  144. {IDS_GREEK_869_LATIN, 869, 30, 0, 0, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  145. {IDS_GREEK_869_851_LATIN, 869, 30, 0, 0, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  146. {IDS_GREEK_737_IBM220, 737, 30, 0, 220, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  147. {IDS_GREEK_737_437_IBM220, 737, 30, 0, 220, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  148. {IDS_GREEK_869_IBM220, 869, 30, 0, 220, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  149. {IDS_GREEK_869_851_IBM220, 869, 30, 0, 220, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  150. {IDS_GREEK_737_IBM319, 737, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  151. {IDS_GREEK_737_437_IBM319, 737, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  152. {IDS_GREEK_869_IBM319, 869, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  153. {IDS_GREEK_869_851_IBM319, 869, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  154. {IDS_GREEK_737_LATIN_IBM319, 737, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  155. {IDS_GREEK_737_437_LATIN_IBM319, 737, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  156. {IDS_GREEK_869_LATIN_IBM319, 869, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  157. {IDS_GREEK_869_851_LATIN_IBM319, 869, 30, 0, 319, LANG_ID_GK, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD4_SYS},
  158. };
  159. INTL_INFO cp_1254[] = {
  160. {IDS_TURKISH_F_TYPE, 857, 90, 0, 440, LANG_ID_TR, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD2_SYS},
  161. {IDS_TURKISH_Q_TYPE, 857, 90, 0, 179, LANG_ID_TR, IDS_COUNTRY_SYS, IDS_EGA2_CPI, IDS_KEYBRD2_SYS},
  162. };
  163. INTL_INFO cp_1255[] = {
  164. {IDS_HEBREW, 862, 972, 0, 400, LANG_ID_HE, IDS_COUNTRY_SYS, IDS_HEBEGA_CPI, 0},
  165. };
  166. INTL_INFO cp_1256[] = {
  167. {IDS_ARABIC_Algeria, 720, 213, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  168. {IDS_ARABIC_Bahrain, 720, 973, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  169. {IDS_ARABIC_Egypt, 720, 20, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  170. {IDS_ARABIC_Iraq, 720, 964, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  171. {IDS_ARABIC_Jordan, 720, 961, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  172. {IDS_ARABIC_Kuwait, 720, 965, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  173. {IDS_ARABIC_Lebanon, 720, 961, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  174. {IDS_ARABIC_Libya, 720, 218, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  175. {IDS_ARABIC_Morocco, 720, 212, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  176. {IDS_ARABIC_Oman, 720, 969, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  177. {IDS_ARABIC_Qatar, 720, 974, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  178. {IDS_ARABIC_Saudi_Arabia, 720, 966, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  179. {IDS_ARABIC_Syria, 720, 963, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  180. {IDS_ARABIC_Tunisia, 720, 216, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  181. {IDS_ARABIC_U_A_E, 720, 971, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  182. {IDS_ARABIC_Yemen, 720, 969, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA4_CPI, 0},
  183. };
  184. INTL_INFO cp_1257[] = {
  185. {IDS_ESTONIAN, 775, 372, 0, 0, LANG_ID_ET, IDS_COUNTRY_SYS, IDS_EGA3_CPI, IDS_KEYBRD4_SYS},
  186. {IDS_LATVIAN, 775, 371, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA3_CPI, 0},
  187. {IDS_LITHUANIAN, 775, 370, 0, 0, NO_LANG_ID, IDS_COUNTRY_SYS, IDS_EGA3_CPI, 0},
  188. };
  189. INTL_INFO cp_1258[] = {
  190. {IDS_VIETNAMESE, 0, 0, 0, 0, NO_LANG_ID, 0, 0, 0},
  191. };
  192. //----------------------------------------------------------------------
  193. //----------------------------------------------------------------------
  194. //----------------------------------------------------------------------
  195. // Intl_SetEditText
  196. //
  197. // Sets an editbox text with a reg entry.
  198. void CPageInternational::Intl_SetEditText(HKEY hKey, LPCTSTR ptszRegValue, int ids, LPTSTR ptszCur)
  199. {
  200. TCHAR tszData[MAX_PATH*2];
  201. DWORD cbData = sizeof(tszData);
  202. if (RegQueryValueEx(hKey, ptszRegValue, NULL, NULL, (LPBYTE)tszData,
  203. &cbData) == ERROR_SUCCESS)
  204. {
  205. ::SetWindowText(GetDlgItem(ids), tszData);
  206. // saving appropriate initial setting
  207. lstrcpy(ptszCur, tszData);
  208. }
  209. }
  210. //----------------------------------------------------------------------
  211. // Intl_SetRegValue
  212. //
  213. // Sets a reg entry with an editbox text (removes reg entry if text is empty).
  214. void CPageInternational::Intl_SetRegValue(HKEY hKey, int ids, LPCTSTR ptszRegValue)
  215. {
  216. TCHAR tszData[MAX_PATH*2];
  217. ::GetWindowText(GetDlgItem(ids), tszData, MAX_PATH*2);
  218. if (tszData[0] != '\0')
  219. RegSetValueEx(hKey, ptszRegValue, 0, REG_SZ, (LPBYTE)tszData, lstrlen(tszData) + 1);
  220. else
  221. RegDeleteValue(hKey, ptszRegValue);
  222. }
  223. void CPageInternational::Intl_GetTextFromNum(UINT nNum, LPTSTR ptszText)
  224. {
  225. if (nNum)
  226. _itoa(nNum, ptszText, 10);
  227. else
  228. lstrcpy(ptszText, "");
  229. }
  230. //----------------------------------------------------------------------
  231. // Intl_GetTextFromIDS
  232. //
  233. // Helper for loading resource into string.
  234. void CPageInternational::Intl_GetTextFromIDS(int ids, LPTSTR ptszText)
  235. {
  236. if (ids)
  237. {
  238. CString str;
  239. str.LoadString(ids);
  240. ExpandEnvironmentStrings(str, ptszText, MAX_PATH);
  241. }
  242. else
  243. lstrcpy(ptszText, "");
  244. }
  245. //----------------------------------------------------------------------
  246. // Intl_GetCPArray
  247. //
  248. // Returns proper array of intl settings for passed in code page.
  249. UINT CPageInternational::Intl_GetCPArray(UINT nCodePage, INTL_INFO **ppIntlInfo)
  250. {
  251. UINT cElements;
  252. switch(nCodePage)
  253. {
  254. case 874:
  255. *ppIntlInfo = cp_874;
  256. cElements = cA(cp_874);
  257. break;
  258. case 932:
  259. *ppIntlInfo = cp_932;
  260. cElements = cA(cp_932);
  261. break;
  262. case 936:
  263. *ppIntlInfo = cp_936;
  264. cElements = cA(cp_936);
  265. break;
  266. case 949:
  267. *ppIntlInfo = cp_949;
  268. cElements = cA(cp_949);
  269. break;
  270. case 950:
  271. *ppIntlInfo = cp_950;
  272. cElements = cA(cp_950);
  273. break;
  274. case 1250:
  275. *ppIntlInfo = cp_1250;
  276. cElements = cA(cp_1250);
  277. break;
  278. case 1251:
  279. *ppIntlInfo = cp_1251;
  280. cElements = cA(cp_1251);
  281. break;
  282. case 1252:
  283. *ppIntlInfo = cp_1252;
  284. cElements = cA(cp_1252);
  285. break;
  286. case 1253:
  287. *ppIntlInfo = cp_1253;
  288. cElements = cA(cp_1253);
  289. break;
  290. case 1254:
  291. *ppIntlInfo = cp_1254;
  292. cElements = cA(cp_1254);
  293. break;
  294. case 1255:
  295. *ppIntlInfo = cp_1255;
  296. cElements = cA(cp_1255);
  297. break;
  298. case 1256:
  299. *ppIntlInfo = cp_1256;
  300. cElements = cA(cp_1256);
  301. break;
  302. case 1257:
  303. *ppIntlInfo = cp_1257;
  304. cElements = cA(cp_1257);
  305. break;
  306. case 1258:
  307. *ppIntlInfo = cp_1258;
  308. cElements = cA(cp_1258);
  309. break;
  310. default:
  311. *ppIntlInfo = NULL;
  312. cElements = 0;
  313. }
  314. return cElements;
  315. }
  316. CPageInternational::CPageInternational()
  317. {
  318. m_uiCaption = IDS_INTERNATIONAL_CAPTION;
  319. m_strName = _T("international");
  320. // init flags
  321. m_fInitializing = TRUE;
  322. m_fIntlDirty = FALSE;
  323. // init initial settings
  324. m_tszCurDOSCodePage[0] = '\0';
  325. m_tszCurCountryCode[0] = '\0';
  326. m_tszCurKeyboardType[0] = '\0';
  327. m_tszCurKeyboardLayout[0] = '\0';
  328. m_tszCurLanguageID[0] = '\0';
  329. m_tszCurCountryFilename[0] = '\0';
  330. m_tszCurCodePageFilename[0] = '\0';
  331. m_tszCurKeyboardFilename[0] = '\0';
  332. }
  333. /////////////////////////////////////////////////////////////////////////////
  334. // CPageIni
  335. LRESULT CPageInternational::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
  336. {
  337. HWND hLang;
  338. INTL_INFO *pIntlInfo = NULL;
  339. UINT cElements, i, nItem;
  340. CString szLanguage;
  341. HKEY hKey;
  342. ::EnableWindow(GetDlgItem(IDC_EDITCODEPAGE), TRUE);
  343. ::EnableWindow(GetDlgItem(IDC_EDITCOUNTRYCODE), TRUE);
  344. ::EnableWindow(GetDlgItem(IDC_EDITCOUNTRYDATAFILE), TRUE);
  345. ::EnableWindow(GetDlgItem(IDC_EDITDISPLAYDATAFILE), TRUE);
  346. ::EnableWindow(GetDlgItem(IDC_EDITKEYBOARDDATAFILE), TRUE);
  347. ::EnableWindow(GetDlgItem(IDC_EDITKEYBOARDTYPE), TRUE);
  348. ::EnableWindow(GetDlgItem(IDC_EDITKEYBOARDLAYOUT), TRUE);
  349. ::EnableWindow(GetDlgItem(IDC_EDITLANGUAGEID), TRUE);
  350. ::EnableWindow(GetDlgItem(IDC_COMBOLANGUAGES), TRUE);
  351. hLang = GetDlgItem(IDC_COMBOLANGUAGES);
  352. // set and select first Language combo box item
  353. szLanguage.LoadString(IDS_NO_LANG);
  354. nItem = ComboBox_AddString(hLang, szLanguage);
  355. ComboBox_SetCurSel(hLang, nItem);
  356. //nItem = ComboBox_AddString(hLang, TEXT("ABC"));
  357. // fill Language combo box based on active code page
  358. cElements = Intl_GetCPArray(GetACP(), &pIntlInfo);
  359. for (i = 0; i < cElements; i++)
  360. {
  361. szLanguage.LoadString(pIntlInfo[i].idsName);
  362. nItem = ComboBox_AddString(hLang, szLanguage.GetBuffer(0));
  363. ComboBox_SetItemData(hLang, nItem, &pIntlInfo[i]);
  364. }
  365. // Open Codepage reg key
  366. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_CodepageKey, 0, KEY_READ, &hKey)
  367. == ERROR_SUCCESS)
  368. {
  369. // set all edit boxes
  370. Intl_SetEditText(hKey, REGSTR_VAL_DOSVMCP, IDC_EDITCODEPAGE, m_tszCurDOSCodePage);
  371. Intl_SetEditText(hKey, REGSTR_VAL_DOSCC, IDC_EDITCOUNTRYCODE, m_tszCurCountryCode);
  372. Intl_SetEditText(hKey, REGSTR_VAL_DOSCFN, IDC_EDITCOUNTRYDATAFILE, m_tszCurCountryFilename);
  373. Intl_SetEditText(hKey, REGSTR_VAL_DOSCPFN, IDC_EDITDISPLAYDATAFILE, m_tszCurCodePageFilename);
  374. Intl_SetEditText(hKey, REGSTR_VAL_DOSKFN, IDC_EDITKEYBOARDDATAFILE, m_tszCurKeyboardFilename);
  375. Intl_SetEditText(hKey, REGSTR_VAL_DOSKT, IDC_EDITKEYBOARDTYPE, m_tszCurKeyboardType);
  376. Intl_SetEditText(hKey, REGSTR_VAL_DOSKL, IDC_EDITKEYBOARDLAYOUT, m_tszCurKeyboardLayout);
  377. Intl_SetEditText(hKey, REGSTR_VAL_DOSLID, IDC_EDITLANGUAGEID, m_tszCurLanguageID);
  378. RegCloseKey(hKey);
  379. }
  380. // limit appropriate edit boxes
  381. Edit_LimitText(GetDlgItem(IDC_EDITCODEPAGE), 5);
  382. Edit_LimitText(GetDlgItem(IDC_EDITCOUNTRYCODE), 5);
  383. Edit_LimitText(GetDlgItem(IDC_EDITKEYBOARDTYPE), 5);
  384. Edit_LimitText(GetDlgItem(IDC_EDITKEYBOARDLAYOUT), 5);
  385. Edit_LimitText(GetDlgItem(IDC_EDITLANGUAGEID), 2);
  386. // Done initializing
  387. m_fInitializing = FALSE;
  388. return TRUE;
  389. }
  390. LRESULT CPageInternational::OnSelchangeCombolanguages(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
  391. {
  392. int nItem;
  393. TCHAR tszText[MAX_PATH];
  394. INTL_INFO *pIntlInfo;
  395. nItem = ComboBox_GetCurSel(hWndCtl);
  396. if (nItem != CB_ERR)
  397. {
  398. if (nItem == 0)
  399. {
  400. // set to initial settings
  401. ::SetWindowText(GetDlgItem(IDC_EDITCODEPAGE), m_tszCurDOSCodePage);
  402. ::SetWindowText(GetDlgItem(IDC_EDITCOUNTRYCODE), m_tszCurCountryCode);
  403. ::SetWindowText(GetDlgItem(IDC_EDITCOUNTRYDATAFILE), m_tszCurCountryFilename);
  404. ::SetWindowText(GetDlgItem(IDC_EDITDISPLAYDATAFILE), m_tszCurCodePageFilename);
  405. ::SetWindowText(GetDlgItem(IDC_EDITKEYBOARDDATAFILE), m_tszCurKeyboardFilename);
  406. ::SetWindowText(GetDlgItem(IDC_EDITKEYBOARDTYPE), m_tszCurKeyboardType);
  407. ::SetWindowText(GetDlgItem(IDC_EDITKEYBOARDLAYOUT), m_tszCurKeyboardLayout);
  408. ::SetWindowText(GetDlgItem(IDC_EDITLANGUAGEID), m_tszCurLanguageID);
  409. }
  410. else
  411. {
  412. pIntlInfo = (INTL_INFO*)ComboBox_GetItemData(hWndCtl, nItem);
  413. if (pIntlInfo)
  414. {
  415. // set DOS code page
  416. Intl_GetTextFromNum(pIntlInfo->nDOSCodePage, tszText);
  417. ::SetWindowText(GetDlgItem(IDC_EDITCODEPAGE), tszText);
  418. // set country code
  419. Intl_GetTextFromNum(pIntlInfo->nCountryCode, tszText);
  420. ::SetWindowText(GetDlgItem(IDC_EDITCOUNTRYCODE), tszText);
  421. // set country data file name
  422. Intl_GetTextFromIDS(pIntlInfo->idsCountryFilename, tszText);
  423. ::SetWindowText(GetDlgItem(IDC_EDITCOUNTRYDATAFILE), tszText);
  424. // set display data file name
  425. Intl_GetTextFromIDS(pIntlInfo->idsCodePageFilename, tszText);
  426. ::SetWindowText(GetDlgItem(IDC_EDITDISPLAYDATAFILE), tszText);
  427. // set keyboard data file name
  428. Intl_GetTextFromIDS(pIntlInfo->idsKeyboardFilename, tszText);
  429. ::SetWindowText(GetDlgItem(IDC_EDITKEYBOARDDATAFILE), tszText);
  430. // set keyboard type
  431. Intl_GetTextFromNum(pIntlInfo->nKeyboardType, tszText);
  432. ::SetWindowText(GetDlgItem(IDC_EDITKEYBOARDTYPE), tszText);
  433. // set keyboard layout
  434. Intl_GetTextFromNum(pIntlInfo->nKeyboardLayout, tszText);
  435. ::SetWindowText(GetDlgItem(IDC_EDITKEYBOARDLAYOUT), tszText);
  436. // set language id
  437. if (lstrcmp(pIntlInfo->tszLanguageID, NO_LANG_ID) != 0)
  438. lstrcpyn(tszText, pIntlInfo->tszLanguageID, 3);
  439. else
  440. tszText[0] = '\0';
  441. ::SetWindowText(GetDlgItem(IDC_EDITLANGUAGEID), tszText);
  442. }
  443. }
  444. }
  445. return 0;
  446. }
  447. HRESULT CPageInternational::Notify(LPCTSTR szFromTab, LPCTSTR szToTab, TabNotify msg)
  448. {
  449. if (CPageBase::Notify(szFromTab, szToTab, msg) == S_FALSE)
  450. return S_FALSE;
  451. HRESULT hrReturn = S_OK;
  452. HKEY hKey;
  453. switch (msg)
  454. {
  455. case TAB_APPLY:
  456. if (!IsDirty())
  457. return S_OK;
  458. if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, c_CodepageKey, 0, KEY_WRITE, &hKey)
  459. == ERROR_SUCCESS)
  460. {
  461. Intl_SetRegValue(hKey, IDC_EDITCODEPAGE, REGSTR_VAL_DOSVMCP);
  462. Intl_SetRegValue(hKey, IDC_EDITCOUNTRYCODE, REGSTR_VAL_DOSCC);
  463. Intl_SetRegValue(hKey, IDC_EDITCOUNTRYDATAFILE, REGSTR_VAL_DOSCFN);
  464. Intl_SetRegValue(hKey, IDC_EDITDISPLAYDATAFILE, REGSTR_VAL_DOSCPFN);
  465. Intl_SetRegValue(hKey, IDC_EDITKEYBOARDDATAFILE, REGSTR_VAL_DOSKFN);
  466. Intl_SetRegValue(hKey, IDC_EDITKEYBOARDTYPE, REGSTR_VAL_DOSKT);
  467. Intl_SetRegValue(hKey, IDC_EDITKEYBOARDLAYOUT, REGSTR_VAL_DOSKL);
  468. Intl_SetRegValue(hKey, IDC_EDITLANGUAGEID, REGSTR_VAL_DOSLID);
  469. RegCloseKey(hKey);
  470. }
  471. break;
  472. case TAB_NORMAL:
  473. case TAB_DIAGNOSTIC:
  474. default:
  475. break;
  476. }
  477. return hrReturn;
  478. }
  479. #endif