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.

482 lines
13 KiB

  1. /*
  2. -
  3. - Locale UI - info about redoing the TAB ORDER for various locales at runtime
  4. *
  5. *
  6. */
  7. #include "_apipch.h"
  8. int rgHomeAddressIDs[] =
  9. {
  10. IDC_STATIC_ETCHED,
  11. IDC_DETAILS_HOME_STATIC_ADDRESS,
  12. IDC_DETAILS_HOME_EDIT_ADDRESS,
  13. IDC_DETAILS_HOME_STATIC_CITY,
  14. IDC_DETAILS_HOME_EDIT_CITY,
  15. IDC_DETAILS_HOME_STATIC_STATE,
  16. IDC_DETAILS_HOME_EDIT_STATE,
  17. IDC_DETAILS_HOME_STATIC_ZIP,
  18. IDC_DETAILS_HOME_EDIT_ZIP,
  19. IDC_DETAILS_HOME_STATIC_COUNTRY,
  20. IDC_DETAILS_HOME_EDIT_COUNTRY,
  21. -1, // use -1 to terminate this array
  22. };
  23. int rgBusinessAddressIDs[] =
  24. {
  25. IDC_STATIC_ETCHED,
  26. IDC_DETAILS_BUSINESS_STATIC_ADDRESS,
  27. IDC_DETAILS_BUSINESS_EDIT_ADDRESS,
  28. IDC_DETAILS_BUSINESS_STATIC_CITY,
  29. IDC_DETAILS_BUSINESS_EDIT_CITY,
  30. IDC_DETAILS_BUSINESS_STATIC_STATE,
  31. IDC_DETAILS_BUSINESS_EDIT_STATE,
  32. IDC_DETAILS_BUSINESS_STATIC_ZIP,
  33. IDC_DETAILS_BUSINESS_EDIT_ZIP,
  34. IDC_DETAILS_BUSINESS_STATIC_COUNTRY,
  35. IDC_DETAILS_BUSINESS_EDIT_COUNTRY,
  36. IDC_DETAILS_BUSINESS_STATIC_COMPANY,
  37. IDC_DETAILS_BUSINESS_EDIT_COMPANY,
  38. -1, // use -1 to terminate this array
  39. };
  40. int rgDistListAddressIDs[] =
  41. {
  42. IDC_STATIC_ETCHED,
  43. IDC_DISTLIST_STATIC_STREET,
  44. IDC_DISTLIST_EDIT_ADDRESS,
  45. IDC_DISTLIST_STATIC_CITY,
  46. IDC_DISTLIST_EDIT_CITY,
  47. IDC_DISTLIST_STATIC_STATE,
  48. IDC_DISTLIST_EDIT_STATE,
  49. IDC_DISTLIST_STATIC_ZIP,
  50. IDC_DISTLIST_EDIT_ZIP,
  51. IDC_DISTLIST_STATIC_COUNTRY,
  52. IDC_DISTLIST_EDIT_COUNTRY,
  53. -1, // use -1 to terminate this array
  54. };
  55. enum tabIDs
  56. {
  57. tabEtched=0,
  58. tabStaticAddress,
  59. tabEditAddress,
  60. tabStaticCity,
  61. tabEditCity,
  62. tabStaticState,
  63. tabEditState,
  64. tabStaticZip,
  65. tabEditZip,
  66. tabStaticCountry,
  67. tabEditCountry,
  68. tabStaticCompany,
  69. tabEditCompany,
  70. tabMax
  71. };
  72. int rgPersonalNameIDs[] =
  73. {
  74. IDC_DETAILS_PERSONAL_FRAME_NAME,
  75. IDC_DETAILS_PERSONAL_STATIC_FIRSTNAME,
  76. IDC_DETAILS_PERSONAL_EDIT_FIRSTNAME,
  77. IDC_DETAILS_PERSONAL_STATIC_MIDDLENAME,
  78. IDC_DETAILS_PERSONAL_EDIT_MIDDLENAME,
  79. IDC_DETAILS_PERSONAL_STATIC_LASTNAME,
  80. IDC_DETAILS_PERSONAL_EDIT_LASTNAME,
  81. -1,
  82. };
  83. enum tabNameIDs
  84. {
  85. tabFrame=0,
  86. tabStaticFirst,
  87. tabEditFirst,
  88. tabStaticMiddle,
  89. tabEditMiddle,
  90. tabStaticLast,
  91. tabEditLast,
  92. tabNameMax,
  93. };
  94. /*
  95. The following is the information on which this localization is based
  96. H Honorific, T Title, F FirstName, S SecondName, L Lastname,
  97. C Companyname, 1 Address1, 2 Address2, c City, s State/Province, p Postal Code,
  98. n Nation (Country), w Country Code
  99. LCID Locale Name 1st row 2nd row 3rd row 4th row 5th row 6th row 7th row 8th row Note
  100. 0c09 English (Australia) HFSL C12cspn
  101. 0416 Portuguese (Brazil) HFSL C12pcsn "2" is not normally used
  102. 0402 Bulgarian nspc12C HFSL
  103. 1009 English (Canada) HFSL C12cspn "S" and "2" are not normally used
  104. 0c0c French (Canada) HFSL C12cspn "S" and "2" are not normally used
  105. 0804 China nsc12 LFH
  106. 041a 0c1a, 081a 0424 Croatian Serbian Slovenian HFSL C12pcsn
  107. 0405 Czech HFSL C12pcsn
  108. 0406 Danish HTFSL C12wpcn
  109. 040b Finnish TFSL C12pcn
  110. 040c French (Standard) HFL C12pcn
  111. 0407 German (Standard) HTFL C12wpcn
  112. 0408 Greek TFSL C12pcn
  113. 040e (home) Hungary HLFS c12psn
  114. 040e (bus) Hungary HLFS Cpc12sn
  115. 0410 Italian (Standard) TFL C12wpcsn
  116. 0411 Japanese npsc12C LFH
  117. 0412 Korean nsc12Cp
  118. 080a 100a 140a 1c0a 200a 240a 280a 2c0a 300a 340a 380a 3c0a 400a 440a 480a
  119. 4c0a 500a Spanish (Latin America) THFSL C12pcsn
  120. 043e Malaysian HFSL C12pcsn
  121. 0413 Dutch (Standard) TFSL C12pcn
  122. xx14 (home) Norwegian TFL 12pcn
  123. xx14 (bus) Norwegian TFL C12pcn
  124. 0415 Polish HFSL C12pcsn
  125. 0816 Portuguese (Portugal) HFSL C12cpn There are kommas between each HFS and L
  126. 0418 Romanian HFSL C12pcsn
  127. 0419 Russian npsc12C L FS
  128. 040a, 0c0a Spanish (Spain) HFSL C12pcn
  129. 041d Swedish TFL C12pcn
  130. 100c, 0807 0810 Swiss HFSL C12pcn
  131. 041f Turkish HFSL C12pcn
  132. 0409 English (US) HFSL C12cspn
  133. */
  134. //
  135. // For entering names in the WAB, the order is FirstMiddleLast for all languages except
  136. // Japanese, Korean, Chinese, Russian and Hungarian
  137. //
  138. // However we have a seperate personal tab for Japanese, Korean and Chinese so
  139. // we don't need to do anything for those languages .. just Russian and Hungarian
  140. //
  141. // LFS
  142. static const int tabLayoutName[] = {
  143. tabFrame,
  144. tabStaticLast, tabEditLast,
  145. tabStaticFirst, tabEditFirst,
  146. tabStaticMiddle,tabEditMiddle,
  147. };
  148. /*
  149. Note that in creating the layouts below we are assuming that
  150. // C12pcn == C12pcsn
  151. // C12wpcsn == C12pcsn
  152. // C12wpcn == C12pcsn
  153. // nsc12 == nspc12C
  154. // C12cpn == C12cspn
  155. Otherwise we have too many to deal with
  156. */
  157. // C12cspn
  158. // 0416 1009 0c0c 0409
  159. // C12cpn == C12cspn
  160. // 0816
  161. static const int tabLayout1[] = {
  162. tabEtched,
  163. tabStaticCompany, tabEditCompany, //C
  164. tabStaticAddress, tabEditAddress, //12
  165. tabStaticCity, tabEditCity, //c
  166. tabStaticState, tabEditState, //s
  167. tabStaticZip, tabEditZip, //p
  168. tabStaticCountry, tabEditCountry //n
  169. };
  170. // C12pcsn
  171. // 041a 0c1a 081a 0424 0405 080a 100a 140a
  172. // 1c0a 200a 240a 280a 2c0a 300a 340a 380a 3c0a
  173. // 400a 440a 480a 4c0a 500a 043e 0415 0418
  174. // C12pcn == C12pcsn
  175. // 040b 040c 0408 0413 xx14 040a 0c0a 041d 100c 0807 0810 041f
  176. // C12wpcsn == C12pcsn
  177. // 0410
  178. // C12wpcn = C12pcsn
  179. // 0406 0407
  180. static const int tabLayout2[] = {
  181. tabEtched,
  182. tabStaticCompany, tabEditCompany, //C
  183. tabStaticAddress, tabEditAddress, //12
  184. tabStaticZip, tabEditZip, //p
  185. tabStaticCity, tabEditCity, //c
  186. tabStaticState, tabEditState, //s
  187. tabStaticCountry, tabEditCountry //n
  188. };
  189. // npsc12C
  190. // 0411 0419
  191. static const int tabLayout3[] = {
  192. tabEtched,
  193. tabStaticCountry, tabEditCountry, //n
  194. tabStaticZip, tabEditZip, //p
  195. tabStaticState, tabEditState, //s
  196. tabStaticCity, tabEditCity, //c
  197. tabStaticAddress, tabEditAddress, //12
  198. tabStaticCompany, tabEditCompany, //C
  199. };
  200. // nspc12C
  201. // 0402
  202. // nsc12 == nspc12C
  203. // 0804
  204. static const int tabLayout4[] = {
  205. tabEtched,
  206. tabStaticCountry, tabEditCountry, //n
  207. tabStaticState, tabEditState, //s
  208. tabStaticZip, tabEditZip, //p
  209. tabStaticCity, tabEditCity, //c
  210. tabStaticAddress, tabEditAddress, //12
  211. tabStaticCompany, tabEditCompany, //C
  212. };
  213. // nsc12Cp
  214. // 0412
  215. static const int tabLayout5[] = {
  216. tabEtched,
  217. tabStaticCountry, tabEditCountry, //n
  218. tabStaticState, tabEditState, //s
  219. tabStaticCity, tabEditCity, //c
  220. tabStaticAddress, tabEditAddress, //12
  221. tabStaticCompany, tabEditCompany, //C
  222. tabStaticZip, tabEditZip, //p
  223. };
  224. // c12psn
  225. // 040e - home
  226. static const int tabLayout6[] = {
  227. tabEtched,
  228. tabStaticCity, tabEditCity, //c
  229. tabStaticAddress, tabEditAddress, //12
  230. tabStaticZip, tabEditZip, //p
  231. tabStaticState, tabEditState, //s
  232. tabStaticCountry, tabEditCountry, //n
  233. tabStaticCompany, tabEditCompany, //C
  234. };
  235. // Cpc12sn
  236. // 040e - business
  237. static const int tabLayout7[] = {
  238. tabEtched,
  239. tabStaticCompany, tabEditCompany, //C
  240. tabStaticZip, tabEditZip, //p
  241. tabStaticCity, tabEditCity, //c
  242. tabStaticAddress, tabEditAddress, //12
  243. tabStaticState, tabEditState, //s
  244. tabStaticCountry, tabEditCountry //n
  245. };
  246. /*
  247. -
  248. - GetLocaleTemplate
  249. *
  250. * Checks the current user locale and the prop sheet being modified and returns a pointer
  251. * to the correct template
  252. *
  253. */
  254. void GetLocaleTemplate(LPINT * lppTemplate, int nPropSheet)
  255. {
  256. LCID lcid = GetUserDefaultLCID();
  257. *lppTemplate = NULL;
  258. if(nPropSheet == contactPersonal)
  259. {
  260. switch(lcid)
  261. {
  262. case 0x0419: //russian
  263. case 0x040e: //hungarian
  264. //case 0x0804: //chinese //These 3 are commented out because they get their own dlg template
  265. //case 0x0411: //japanese
  266. //case 0x0412: //korean
  267. *lppTemplate = (LPINT) tabLayoutName;
  268. break;
  269. }
  270. return;
  271. }
  272. switch(lcid)
  273. {
  274. case 0x0c09: //english
  275. case 0x0416: //Portuguese (Brazil)
  276. case 0x1009: //English (Canada)
  277. case 0x0c0c: //French (Canada)
  278. case 0x0409: //English (US)
  279. case 0x0816: //Portuguese (Portugal)
  280. *lppTemplate = (LPINT) tabLayout1;
  281. break;
  282. case 0x041a: case 0x0c1a: case 0x081a: case 0x0424: //Croatian Serbian Slovenian
  283. case 0x0405: //Czech
  284. case 0x080a: case 0x100a: case 0x140a: case 0x1c0a: case 0x200a: case 0x240a:
  285. case 0x280a: case 0x2c0a: case 0x300a: case 0x340a: case 0x380a: case 0x3c0a:
  286. case 0x400a: case 0x440a: case 0x480a: case 0x4c0a: case 0x500a: // Latin America
  287. case 0x043e: //Malaysia
  288. case 0x0415: //Polish
  289. case 0x0418: //Romanian
  290. case 0x040b: //Finnish
  291. case 0x040c: //French (Standard)
  292. case 0x0408: //Greek
  293. case 0x0413: //Dutch (Standard)
  294. case 0x040a: case 0x0c0a: //Spanish (Spain)
  295. case 0x041d: //Swedish
  296. case 0x100c: case 0x0807: case 0x0810: //Swiss
  297. case 0x041f: //Turkish
  298. case 0x0410: //Italian (Standard)
  299. case 0x0406: //Danish
  300. case 0x0407: //German (Standard)
  301. case 0x0414: case 0x0814: //Norwegian
  302. *lppTemplate = (LPINT) tabLayout2;
  303. break;
  304. case 0x0411: //Japanese
  305. case 0x0419: //Russian
  306. *lppTemplate = (LPINT) tabLayout3;
  307. break;
  308. case 0x0402: //Bulgarian
  309. case 0x0804: //China
  310. *lppTemplate = (LPINT) tabLayout4;
  311. break;
  312. case 0x0412: //Korean
  313. *lppTemplate = (LPINT) tabLayout5;
  314. break;
  315. case 0x040e: //Hungary
  316. if(nPropSheet == contactBusiness)
  317. *lppTemplate = (LPINT) tabLayout7;
  318. else
  319. *lppTemplate = (LPINT) tabLayout6;
  320. break;
  321. }
  322. return;
  323. }
  324. /*
  325. -
  326. - ChangeLocaleBasedTabOrder
  327. -
  328. // To reorder the tabbing in a dialog, we basically need to reset the Z-orders of the child
  329. // controls with respect to each other ..
  330. //
  331. // Thus we will get a handle to all the child controls, and reorder them after the IDC_STATIC_ETCHED
  332. // based on the template we will create for reoldering ..
  333. //
  334. // The templates will vary by locale and are different for home and business since business needs to include
  335. // country ..
  336. //
  337. // So to do this, we will get an array that will list the relative order of the UI controls
  338. // Then we will load the hWnds of the UI controls in the order we want them
  339. // Then we will do a SetWindowPos for each successive item in the array to follow the one before
  340. //
  341. // The hard part is creating all the array information in the first place
  342. //
  343. */
  344. void ChangeLocaleBasedTabOrder(HWND hWnd, int nPropSheet)
  345. {
  346. #if 0
  347. int * rgIDs = NULL;
  348. int nCount = 0, i = 0, n=0;
  349. HWND * rghWnd = NULL;
  350. int * lpTabOrderTemplate = NULL;
  351. switch(nPropSheet)
  352. {
  353. case contactPersonal:
  354. rgIDs = rgPersonalNameIDs;
  355. break;
  356. case contactHome:
  357. rgIDs = rgHomeAddressIDs;
  358. break;
  359. case contactBusiness:
  360. rgIDs = rgBusinessAddressIDs;
  361. break;
  362. case groupOther:
  363. rgIDs = rgDistListAddressIDs;
  364. break;
  365. default:
  366. goto out;
  367. break;
  368. }
  369. rghWnd = LocalAlloc(LMEM_ZEROINIT, sizeof(HWND)*tabMax);
  370. if(!rghWnd)
  371. goto out;
  372. GetLocaleTemplate(&lpTabOrderTemplate, nPropSheet);
  373. if(!lpTabOrderTemplate)
  374. goto out;
  375. nCount = 0;
  376. for(i=0;i<tabMax && rgIDs[i]!=-1;i++)
  377. {
  378. int tabPos = lpTabOrderTemplate[i];
  379. // Need to ignore the company-name related ids from the home and group panes
  380. if( (nPropSheet == contactHome || nPropSheet == groupOther) &&
  381. (tabPos == tabStaticCompany || tabPos == tabEditCompany) )
  382. continue;
  383. rghWnd[nCount] = GetDlgItem(hWnd, rgIDs[tabPos]);
  384. nCount++;
  385. }
  386. //for(i=1;i<nCount;i++)
  387. // SetWindowPos(rghWnd[i-1], rghWnd[i], 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  388. // Starting backwards, we will put each item on the top - that way we know these are all topmost
  389. // in the right order ..
  390. //
  391. // Not sure if this is completely foolproof or not ..
  392. //
  393. for(i=nCount-1;i>=0;i--)
  394. SetWindowPos(rghWnd[i], HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
  395. out:
  396. LocalFreeAndNull((LPVOID*)&rghWnd);
  397. #endif
  398. return;
  399. }