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.

869 lines
27 KiB

  1. /*++
  2. Copyright (c) 1994-2000, Microsoft Corporation All rights reserved.
  3. Module Name:
  4. curdlg.c
  5. Abstract:
  6. This module implements the currency property sheet for the Regional
  7. Options applet.
  8. Revision History:
  9. --*/
  10. //
  11. // Include Files.
  12. //
  13. #include "intl.h"
  14. #include <tchar.h>
  15. #include <windowsx.h>
  16. #include "intlhlp.h"
  17. #include "maxvals.h"
  18. #define STRSAFE_LIB
  19. #include <strsafe.h>
  20. //
  21. // Global Variables.
  22. //
  23. static TCHAR sz_iCurrDigits[MAX_ICURRDIGITS+1];
  24. static TCHAR sz_iCurrency[MAX_ICURRENCY+1];
  25. static TCHAR sz_iNegCurr[MAX_INEGCURR+1];
  26. static TCHAR sz_sCurrency[MAX_SCURRENCY+1];
  27. static TCHAR sz_sMonDecimalSep[MAX_SMONDECSEP+1];
  28. static TCHAR sz_sMonGrouping[MAX_SMONGROUPING+1];
  29. static TCHAR sz_sMonThousandSep[MAX_SMONTHOUSEP+1];
  30. //
  31. // Context Help Ids.
  32. //
  33. static int aCurrencyHelpIds[] =
  34. {
  35. IDC_SAMPLELBL1, IDH_INTL_CURR_POSVALUE,
  36. IDC_SAMPLE1, IDH_INTL_CURR_POSVALUE,
  37. IDC_SAMPLELBL2, IDH_INTL_CURR_NEGVALUE,
  38. IDC_SAMPLE2, IDH_INTL_CURR_NEGVALUE,
  39. IDC_SAMPLELBL3, IDH_COMM_GROUPBOX,
  40. IDC_POS_CURRENCY_SYM, IDH_INTL_CURR_POSOFSYMBOL,
  41. IDC_CURRENCY_SYMBOL, IDH_INTL_CURR_SYMBOL,
  42. IDC_NEG_NUM_FORMAT, IDH_INTL_CURR_NEGNUMFMT,
  43. IDC_DECIMAL_SYMBOL, IDH_INTL_CURR_DECSYMBOL,
  44. IDC_NUM_DECIMAL_DIGITS, IDH_INTL_CURR_DIGITSAFTRDEC,
  45. IDC_DIGIT_GROUP_SYMBOL, IDH_INTL_CURR_DIGITGRPSYMBOL,
  46. IDC_NUM_DIGITS_GROUP, IDH_INTL_CURR_DIGITSINGRP,
  47. 0, 0
  48. };
  49. ////////////////////////////////////////////////////////////////////////////
  50. //
  51. // Currency_DisplaySample
  52. //
  53. // Updates the currency sample. It formats the currency based on the
  54. // user's current locale settings. It displays either a positive value
  55. // or a negative value based on the Positive/Negative radio buttons.
  56. //
  57. ////////////////////////////////////////////////////////////////////////////
  58. void Currency_DisplaySample(
  59. HWND hDlg)
  60. {
  61. TCHAR szBuf[MAX_SAMPLE_SIZE];
  62. int nCharCount;
  63. //
  64. // Get the string representing the currency format for the positive sample
  65. // currency and, if the the value is valid, display it. Perform the same
  66. // operations for the negative currency sample.
  67. //
  68. nCharCount = GetCurrencyFormat( UserLocaleID,
  69. 0,
  70. szSample_Number,
  71. NULL,
  72. szBuf,
  73. MAX_SAMPLE_SIZE );
  74. if (nCharCount)
  75. {
  76. SetDlgItemText(hDlg, IDC_SAMPLE1, szBuf);
  77. }
  78. else
  79. {
  80. MessageBox(hDlg, szLocaleGetError, NULL, MB_OK | MB_ICONINFORMATION);
  81. }
  82. nCharCount = GetCurrencyFormat( UserLocaleID,
  83. 0,
  84. szNegSample_Number,
  85. NULL,
  86. szBuf,
  87. MAX_SAMPLE_SIZE );
  88. if (nCharCount)
  89. {
  90. SetDlgItemText(hDlg, IDC_SAMPLE2, szBuf);
  91. }
  92. else
  93. {
  94. MessageBox(hDlg, szLocaleGetError, NULL, MB_OK | MB_ICONINFORMATION);
  95. }
  96. }
  97. ////////////////////////////////////////////////////////////////////////////
  98. //
  99. // Currency_SaveValues
  100. //
  101. // Save values in the case that we need to restore them.
  102. //
  103. ////////////////////////////////////////////////////////////////////////////
  104. void Currency_SaveValues()
  105. {
  106. //
  107. // Save values.
  108. //
  109. if (!GetLocaleInfo( UserLocaleID,
  110. LOCALE_ICURRDIGITS,
  111. sz_iCurrDigits,
  112. MAX_ICURRDIGITS + 1 ))
  113. {
  114. //_tcscpy(sz_iCurrDigits, TEXT("2"));
  115. if(FAILED(StringCchCopy(sz_iCurrDigits, MAX_ICURRDIGITS+1, TEXT("2"))))
  116. {
  117. // This should be impossible, but we need to avoid PREfast complaints.
  118. }
  119. }
  120. if (!GetLocaleInfo( UserLocaleID,
  121. LOCALE_ICURRENCY,
  122. sz_iCurrency,
  123. MAX_ICURRENCY + 1 ))
  124. {
  125. //_tcscpy(sz_iCurrency, TEXT("0"));
  126. if(FAILED(StringCchCopy(sz_iCurrency, MAX_ICURRENCY+1, TEXT("0"))))
  127. {
  128. // This should be impossible, but we need to avoid PREfast complaints.
  129. }
  130. }
  131. if (!GetLocaleInfo( UserLocaleID,
  132. LOCALE_INEGCURR,
  133. sz_iNegCurr,
  134. MAX_INEGCURR + 1 ))
  135. {
  136. //_tcscpy(sz_iNegCurr, TEXT("0"));
  137. if(FAILED(StringCchCopy(sz_iNegCurr, MAX_INEGCURR+1, TEXT("0"))))
  138. {
  139. // This should be impossible, but we need to avoid PREfast complaints.
  140. }
  141. }
  142. if (!GetLocaleInfo( UserLocaleID,
  143. LOCALE_SCURRENCY,
  144. sz_sCurrency,
  145. MAX_SCURRENCY + 1 ))
  146. {
  147. //_tcscpy(sz_sCurrency, TEXT("$"));
  148. if(FAILED(StringCchCopy(sz_sCurrency, MAX_SCURRENCY+1, TEXT("$"))))
  149. {
  150. // This should be impossible, but we need to avoid PREfast complaints.
  151. }
  152. }
  153. if (!GetLocaleInfo( UserLocaleID,
  154. LOCALE_SMONDECIMALSEP,
  155. sz_sMonDecimalSep,
  156. MAX_SMONDECSEP + 1 ))
  157. {
  158. //_tcscpy(sz_sMonDecimalSep, TEXT("."));
  159. if(FAILED(StringCchCopy(sz_sMonDecimalSep, MAX_SMONDECSEP+1, TEXT("."))))
  160. {
  161. // This should be impossible, but we need to avoid PREfast complaints.
  162. }
  163. }
  164. if (!GetLocaleInfo( UserLocaleID,
  165. LOCALE_SMONGROUPING,
  166. sz_sMonGrouping,
  167. MAX_SMONGROUPING + 1 ))
  168. {
  169. //_tcscpy(sz_sMonGrouping, TEXT("3;0"));
  170. if(FAILED(StringCchCopy(sz_sMonGrouping, MAX_SMONGROUPING+1, TEXT("3;0"))))
  171. {
  172. // This should be impossible, but we need to avoid PREfast complaints.
  173. }
  174. }
  175. if (!GetLocaleInfo( UserLocaleID,
  176. LOCALE_SMONTHOUSANDSEP,
  177. sz_sMonThousandSep,
  178. MAX_SMONTHOUSEP + 1 ))
  179. {
  180. //_tcscpy(sz_sMonThousandSep, TEXT(","));
  181. if(FAILED(StringCchCopy(sz_sMonThousandSep, MAX_SMONTHOUSEP+1, TEXT(","))))
  182. {
  183. // This should be impossible, but we need to avoid PREfast complaints.
  184. }
  185. }
  186. }
  187. ////////////////////////////////////////////////////////////////////////////
  188. //
  189. // Currency_RestoreValues
  190. //
  191. ////////////////////////////////////////////////////////////////////////////
  192. void Currency_RestoreValues()
  193. {
  194. if (g_dwCustChange & Process_Curr)
  195. {
  196. SetLocaleInfo(UserLocaleID, LOCALE_ICURRDIGITS, sz_iCurrDigits);
  197. SetLocaleInfo(UserLocaleID, LOCALE_ICURRENCY, sz_iCurrency);
  198. SetLocaleInfo(UserLocaleID, LOCALE_INEGCURR, sz_iNegCurr);
  199. SetLocaleInfo(UserLocaleID, LOCALE_SCURRENCY, sz_sCurrency);
  200. SetLocaleInfo(UserLocaleID, LOCALE_SMONDECIMALSEP, sz_sMonDecimalSep);
  201. SetLocaleInfo(UserLocaleID, LOCALE_SMONGROUPING, sz_sMonGrouping);
  202. SetLocaleInfo(UserLocaleID, LOCALE_SMONTHOUSANDSEP, sz_sMonThousandSep);
  203. }
  204. }
  205. ////////////////////////////////////////////////////////////////////////////
  206. //
  207. // Currency_ClearValues
  208. //
  209. // Reset each of the list boxes in the currency property sheet page.
  210. //
  211. ////////////////////////////////////////////////////////////////////////////
  212. void Currency_ClearValues(
  213. HWND hDlg)
  214. {
  215. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_CURRENCY_SYMBOL));
  216. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_POS_CURRENCY_SYM));
  217. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_NEG_NUM_FORMAT));
  218. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_DECIMAL_SYMBOL));
  219. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_NUM_DECIMAL_DIGITS));
  220. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_DIGIT_GROUP_SYMBOL));
  221. ComboBox_ResetContent(GetDlgItem(hDlg, IDC_NUM_DIGITS_GROUP));
  222. }
  223. ////////////////////////////////////////////////////////////////////////////
  224. //
  225. // Currency_SetValues
  226. //
  227. // Initialize all of the controls in the currency property sheet page.
  228. //
  229. ////////////////////////////////////////////////////////////////////////////
  230. void Currency_SetValues(
  231. HWND hDlg)
  232. {
  233. HWND hCtrl1, hCtrl2;
  234. TCHAR szBuf[SIZE_128];
  235. int Index;
  236. const nMax_Array_Fill = (cInt_Str >= 10 ? 10 : cInt_Str);
  237. CURRENCYFMT cfmt;
  238. TCHAR szThousandSep[SIZE_128];
  239. TCHAR szEmpty[] = TEXT("");
  240. TCHAR szSample[] = TEXT("123456789");
  241. //
  242. // Initialize the dropdown box for the current locale setting for:
  243. // Currency Symbol
  244. // Currency Decimal Symbol
  245. // Currency Grouping Symbol
  246. //
  247. DropDown_Use_Locale_Values(hDlg, LOCALE_SCURRENCY, IDC_CURRENCY_SYMBOL);
  248. DropDown_Use_Locale_Values(hDlg, LOCALE_SMONDECIMALSEP, IDC_DECIMAL_SYMBOL);
  249. DropDown_Use_Locale_Values(hDlg, LOCALE_SMONTHOUSANDSEP, IDC_DIGIT_GROUP_SYMBOL);
  250. //
  251. // Fill in the Number of Digits after Decimal Symbol drop down list
  252. // with the values of 0 through 10. Get the user locale value and
  253. // make it the current selection. If GetLocaleInfo fails, simply
  254. // select the first item in the list.
  255. //
  256. hCtrl1 = GetDlgItem(hDlg, IDC_NUM_DECIMAL_DIGITS);
  257. hCtrl2 = GetDlgItem(hDlg, IDC_NUM_DIGITS_GROUP);
  258. for (Index = 0; Index < nMax_Array_Fill; Index++)
  259. {
  260. ComboBox_InsertString(hCtrl1, -1, aInt_Str[Index]);
  261. }
  262. if (GetLocaleInfo(UserLocaleID, LOCALE_ICURRDIGITS, szBuf, SIZE_128))
  263. {
  264. ComboBox_SelectString(hCtrl1, -1, szBuf);
  265. }
  266. else
  267. {
  268. ComboBox_SetCurSel(hCtrl1, 0);
  269. }
  270. //
  271. // Fill in the Number of Digits in "Thousands" Grouping's drop down
  272. // list with the appropriate options. Get the user locale value and
  273. // make it the current selection. If GetLocaleInfo fails, simply
  274. // select the first item in the list.
  275. //
  276. cfmt.NumDigits = 0; // no decimal in sample string
  277. cfmt.LeadingZero = 0; // no decimal in sample string
  278. cfmt.lpDecimalSep = szEmpty; // no decimal in sample string
  279. cfmt.NegativeOrder = 0; // not a negative value
  280. cfmt.PositiveOrder = 0; // prefix, no separation
  281. cfmt.lpCurrencySymbol = szEmpty; // no currency symbol
  282. cfmt.lpThousandSep = szThousandSep;
  283. GetLocaleInfo(UserLocaleID, LOCALE_SMONTHOUSANDSEP, szThousandSep, SIZE_128);
  284. cfmt.Grouping = 0;
  285. if (GetCurrencyFormat(UserLocaleID, 0, szSample, &cfmt, szBuf, SIZE_128))
  286. {
  287. ComboBox_InsertString(hCtrl2, -1, szBuf);
  288. }
  289. cfmt.Grouping = 3;
  290. if (GetCurrencyFormat(UserLocaleID, 0, szSample, &cfmt, szBuf, SIZE_128))
  291. {
  292. ComboBox_InsertString(hCtrl2, -1, szBuf);
  293. }
  294. cfmt.Grouping = 32;
  295. if (GetCurrencyFormat(UserLocaleID, 0, szSample, &cfmt, szBuf, SIZE_128))
  296. {
  297. ComboBox_InsertString(hCtrl2, -1, szBuf);
  298. }
  299. if (GetLocaleInfo(UserLocaleID, LOCALE_SMONGROUPING, szBuf, SIZE_128) &&
  300. (szBuf[0]))
  301. {
  302. //
  303. // Since only the values 0, 3;0, and 3;2;0 are allowed, simply
  304. // ignore the ";#"s for subsequent groupings.
  305. //
  306. Index = 0;
  307. if (szBuf[0] == TEXT('3'))
  308. {
  309. if ((szBuf[1] == CHAR_SEMICOLON) && (szBuf[2] == TEXT('2')))
  310. {
  311. Index = 2;
  312. }
  313. else
  314. {
  315. Index = 1;
  316. }
  317. }
  318. else
  319. {
  320. //
  321. // We used to allow the user to set #;0, where # is a value from
  322. // 0 - 9. If it's 0, then fall through so that Index is 0.
  323. //
  324. if ((szBuf[0] > CHAR_ZERO) && (szBuf[0] <= CHAR_NINE) &&
  325. ((szBuf[1] == 0) || (lstrcmp(szBuf + 1, TEXT(";0")) == 0)))
  326. {
  327. cfmt.Grouping = szBuf[0] - CHAR_ZERO;
  328. if (GetCurrencyFormat(UserLocaleID, 0, szSample, &cfmt, szBuf, SIZE_128))
  329. {
  330. Index = ComboBox_InsertString(hCtrl2, -1, szBuf);
  331. if (Index >= 0)
  332. {
  333. ComboBox_SetItemData( hCtrl2,
  334. Index,
  335. (LPARAM)((DWORD)cfmt.Grouping) );
  336. }
  337. else
  338. {
  339. Index = 0;
  340. }
  341. }
  342. }
  343. }
  344. ComboBox_SetCurSel(hCtrl2, Index);
  345. }
  346. else
  347. {
  348. ComboBox_SetCurSel(hCtrl2, 0);
  349. }
  350. //
  351. // Initialize and Lock function. If it succeeds, call enum function to
  352. // enumerate all possible values for the list box via a call to EnumProc.
  353. // EnumProc will call Set_List_Values for each of the string values it
  354. // receives. When the enumeration of values is complete, call
  355. // Set_List_Values to clear the dialog item specific data and to clear the
  356. // lock on the function. Perform this set of operations for:
  357. // Position of Currency Symbol and Negative Currency Format.
  358. //
  359. if (Set_List_Values(hDlg, IDC_POS_CURRENCY_SYM, 0))
  360. {
  361. EnumPosCurrency(EnumProcEx, UserLocaleID, 0);
  362. Set_List_Values(0, IDC_POS_CURRENCY_SYM, 0);
  363. if (GetLocaleInfo(UserLocaleID, LOCALE_ICURRENCY, szBuf, SIZE_128))
  364. {
  365. ComboBox_SetCurSel( GetDlgItem(hDlg, IDC_POS_CURRENCY_SYM),
  366. Intl_StrToLong(szBuf) );
  367. }
  368. else
  369. {
  370. MessageBox(hDlg, szLocaleGetError, NULL, MB_OK | MB_ICONINFORMATION);
  371. }
  372. }
  373. if (Set_List_Values(hDlg, IDC_NEG_NUM_FORMAT, 0))
  374. {
  375. EnumNegCurrency(EnumProcEx, UserLocaleID, 0);
  376. Set_List_Values(0, IDC_NEG_NUM_FORMAT, 0);
  377. if (GetLocaleInfo(UserLocaleID, LOCALE_INEGCURR, szBuf, SIZE_128))
  378. {
  379. ComboBox_SetCurSel( GetDlgItem(hDlg, IDC_NEG_NUM_FORMAT),
  380. Intl_StrToLong(szBuf) );
  381. }
  382. else
  383. {
  384. MessageBox(hDlg, szLocaleGetError, NULL, MB_OK | MB_ICONINFORMATION);
  385. }
  386. }
  387. //
  388. // Display the current sample that represents all of the locale settings.
  389. //
  390. Currency_DisplaySample(hDlg);
  391. }
  392. ////////////////////////////////////////////////////////////////////////////
  393. //
  394. // Currency_ApplySettings
  395. //
  396. // For every control that has changed (that affects the Locale settings),
  397. // call Set_Locale_Values to update the user locale information. Notify
  398. // the parent of changes and reset the change flag stored in the property
  399. // sheet page structure appropriately. Redisplay the currency sample
  400. // if bRedisplay is TRUE.
  401. //
  402. ////////////////////////////////////////////////////////////////////////////
  403. BOOL Currency_ApplySettings(
  404. HWND hDlg,
  405. BOOL bRedisplay)
  406. {
  407. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE)(GetWindowLongPtr(hDlg, DWLP_USER));
  408. LPARAM Changes = lpPropSheet->lParam;
  409. if (Changes & CC_SCurrency)
  410. {
  411. if (!Set_Locale_Values( hDlg,
  412. LOCALE_SCURRENCY,
  413. IDC_CURRENCY_SYMBOL,
  414. TEXT("sCurrency"),
  415. FALSE,
  416. 0,
  417. 0,
  418. NULL ))
  419. {
  420. return (FALSE);
  421. }
  422. }
  423. if (Changes & CC_CurrSymPos)
  424. {
  425. if (!Set_Locale_Values( hDlg,
  426. LOCALE_ICURRENCY,
  427. IDC_POS_CURRENCY_SYM,
  428. TEXT("iCurrency"),
  429. TRUE,
  430. 0,
  431. 0,
  432. NULL ))
  433. {
  434. return (FALSE);
  435. }
  436. }
  437. if (Changes & CC_NegCurrFmt)
  438. {
  439. if (!Set_Locale_Values( hDlg,
  440. LOCALE_INEGCURR,
  441. IDC_NEG_NUM_FORMAT,
  442. TEXT("iNegCurr"),
  443. TRUE,
  444. 0,
  445. 0,
  446. NULL ))
  447. {
  448. return (FALSE);
  449. }
  450. }
  451. if (Changes & CC_SMonDec)
  452. {
  453. if (!Set_Locale_Values( hDlg,
  454. LOCALE_SMONDECIMALSEP,
  455. IDC_DECIMAL_SYMBOL,
  456. 0,
  457. FALSE,
  458. 0,
  459. 0,
  460. NULL ))
  461. {
  462. return (FALSE);
  463. }
  464. }
  465. if (Changes & CC_ICurrDigits)
  466. {
  467. if (!Set_Locale_Values( hDlg,
  468. LOCALE_ICURRDIGITS,
  469. IDC_NUM_DECIMAL_DIGITS,
  470. TEXT("iCurrDigits"),
  471. TRUE,
  472. 0,
  473. 0,
  474. NULL ))
  475. {
  476. return (FALSE);
  477. }
  478. }
  479. if (Changes & CC_SMonThousand)
  480. {
  481. if (!Set_Locale_Values( hDlg,
  482. LOCALE_SMONTHOUSANDSEP,
  483. IDC_DIGIT_GROUP_SYMBOL,
  484. 0,
  485. FALSE,
  486. 0,
  487. 0,
  488. NULL ))
  489. {
  490. return (FALSE);
  491. }
  492. }
  493. if (Changes & CC_DMonGroup)
  494. {
  495. if (!Set_Locale_Values( hDlg,
  496. LOCALE_SMONGROUPING,
  497. IDC_NUM_DIGITS_GROUP,
  498. 0,
  499. TRUE,
  500. 0,
  501. TEXT(";0"),
  502. NULL ))
  503. {
  504. return (FALSE);
  505. }
  506. }
  507. PropSheet_UnChanged(GetParent(hDlg), hDlg);
  508. lpPropSheet->lParam = CC_EverChg;
  509. //
  510. // Display the current sample that represents all of the locale settings.
  511. //
  512. if (bRedisplay)
  513. {
  514. Currency_ClearValues(hDlg);
  515. Currency_SetValues(hDlg);
  516. }
  517. //
  518. // Changes made in the second level.
  519. //
  520. if (Changes)
  521. {
  522. g_dwCustChange |= Process_Curr;
  523. }
  524. //
  525. // Return success.
  526. //
  527. return (TRUE);
  528. }
  529. ////////////////////////////////////////////////////////////////////////////
  530. //
  531. // Currency_ValidatePPS
  532. //
  533. // Validate each of the combo boxes whose values are constrained.
  534. // If any of the input fails, notify the user and then return FALSE
  535. // to indicate validation failure.
  536. //
  537. ////////////////////////////////////////////////////////////////////////////
  538. BOOL Currency_ValidatePPS(
  539. HWND hDlg,
  540. LPARAM Changes)
  541. {
  542. //
  543. // If nothing has changed, return TRUE immediately.
  544. //
  545. if (Changes <= CC_EverChg)
  546. {
  547. return (TRUE);
  548. }
  549. //
  550. // If the currency symbol has changed, ensure that there are no digits
  551. // contained in the new symbol.
  552. //
  553. if ((Changes & CC_SCurrency) &&
  554. Item_Has_Digits(hDlg, IDC_CURRENCY_SYMBOL, FALSE))
  555. {
  556. No_Numerals_Error(hDlg, IDC_CURRENCY_SYMBOL, IDS_LOCALE_CURR_SYM);
  557. return (FALSE);
  558. }
  559. //
  560. // If the currency's decimal symbol has changed, ensure that there are
  561. // no digits contained in the new symbol.
  562. //
  563. if ((Changes & CC_SMonDec) &&
  564. Item_Has_Digits(hDlg, IDC_DECIMAL_SYMBOL, FALSE))
  565. {
  566. No_Numerals_Error(hDlg, IDC_DECIMAL_SYMBOL, IDS_LOCALE_CDECIMAL_SYM);
  567. return (FALSE);
  568. }
  569. //
  570. // If the currency's thousands grouping symbol has changed, ensure that
  571. // there are no digits contained in the new symbol.
  572. //
  573. if ((Changes & CC_SMonThousand) &&
  574. Item_Has_Digits(hDlg, IDC_DIGIT_GROUP_SYMBOL, FALSE))
  575. {
  576. No_Numerals_Error(hDlg, IDC_DIGIT_GROUP_SYMBOL, IDS_LOCALE_CGROUP_SYM);
  577. return (FALSE);
  578. }
  579. //
  580. // Return success.
  581. //
  582. return (TRUE);
  583. }
  584. ////////////////////////////////////////////////////////////////////////////
  585. //
  586. // Currency_InitPropSheet
  587. //
  588. // The extra long value for the property sheet page is used as a set of
  589. // state or change flags for each of the list boxes in the property sheet.
  590. // Initialize this value to 0. Call Currency_SetValues with the property
  591. // sheet handle to initialize all of the property sheet controls. Limit
  592. // the length of the text in some of the ComboBoxes.
  593. //
  594. ////////////////////////////////////////////////////////////////////////////
  595. void Currency_InitPropSheet(
  596. HWND hDlg,
  597. LPARAM lParam)
  598. {
  599. //
  600. // The lParam holds a pointer to the property sheet page, save it
  601. // for later reference.
  602. //
  603. SetWindowLongPtr(hDlg, DWLP_USER, lParam);
  604. Currency_SetValues(hDlg);
  605. ComboBox_LimitText(GetDlgItem(hDlg, IDC_CURRENCY_SYMBOL), MAX_SCURRENCY);
  606. ComboBox_LimitText(GetDlgItem(hDlg, IDC_DECIMAL_SYMBOL), MAX_SMONDECSEP);
  607. ComboBox_LimitText(GetDlgItem(hDlg, IDC_DIGIT_GROUP_SYMBOL), MAX_SMONTHOUSEP);
  608. }
  609. ////////////////////////////////////////////////////////////////////////////
  610. //
  611. // CurrencyDlgProc
  612. //
  613. ////////////////////////////////////////////////////////////////////////////
  614. INT_PTR CALLBACK CurrencyDlgProc(
  615. HWND hDlg,
  616. UINT message,
  617. WPARAM wParam,
  618. LPARAM lParam)
  619. {
  620. NMHDR *lpnm;
  621. LPPROPSHEETPAGE lpPropSheet = (LPPROPSHEETPAGE)(GetWindowLongPtr(hDlg, DWLP_USER));
  622. switch (message)
  623. {
  624. case ( WM_NOTIFY ) :
  625. {
  626. lpnm = (NMHDR *)lParam;
  627. switch (lpnm->code)
  628. {
  629. case ( PSN_SETACTIVE ) :
  630. {
  631. //
  632. // If there has been a change in the regional Locale
  633. // setting, clear all of the current info in the
  634. // property sheet, get the new values, and update the
  635. // appropriate registry values.
  636. //
  637. if (Verified_Regional_Chg & Process_Curr)
  638. {
  639. Verified_Regional_Chg &= ~Process_Curr;
  640. Currency_ClearValues(hDlg);
  641. Currency_SetValues(hDlg);
  642. lpPropSheet->lParam = 0;
  643. }
  644. break;
  645. }
  646. case ( PSN_KILLACTIVE ) :
  647. {
  648. //
  649. // Validate the entries on the property page.
  650. //
  651. SetWindowLongPtr( hDlg,
  652. DWLP_MSGRESULT,
  653. !Currency_ValidatePPS( hDlg,
  654. lpPropSheet->lParam) );
  655. break;
  656. }
  657. case ( PSN_APPLY ) :
  658. {
  659. //
  660. // Apply the settings.
  661. //
  662. if (Currency_ApplySettings(hDlg, TRUE))
  663. {
  664. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, PSNRET_NOERROR);
  665. //
  666. // Zero out the CC_EverChg bit.
  667. //
  668. lpPropSheet->lParam = 0;
  669. }
  670. else
  671. {
  672. SetWindowLongPtr( hDlg,
  673. DWLP_MSGRESULT,
  674. PSNRET_INVALID_NOCHANGEPAGE );
  675. }
  676. break;
  677. }
  678. default :
  679. {
  680. return (FALSE);
  681. }
  682. }
  683. break;
  684. }
  685. case ( WM_INITDIALOG ) :
  686. {
  687. Currency_InitPropSheet(hDlg, lParam);
  688. Currency_SaveValues();
  689. break;
  690. }
  691. case ( WM_DESTROY ) :
  692. {
  693. break;
  694. }
  695. case ( WM_HELP ) :
  696. {
  697. WinHelp( (HWND)((LPHELPINFO)lParam)->hItemHandle,
  698. szHelpFile,
  699. HELP_WM_HELP,
  700. (DWORD_PTR)(LPTSTR)aCurrencyHelpIds );
  701. break;
  702. }
  703. case ( WM_CONTEXTMENU ) : // right mouse click
  704. {
  705. WinHelp( (HWND)wParam,
  706. szHelpFile,
  707. HELP_CONTEXTMENU,
  708. (DWORD_PTR)(LPTSTR)aCurrencyHelpIds );
  709. break;
  710. }
  711. case ( WM_COMMAND ) :
  712. {
  713. switch ( LOWORD(wParam) )
  714. {
  715. case ( IDC_CURRENCY_SYMBOL ) :
  716. {
  717. if (HIWORD(wParam) == CBN_SELCHANGE ||
  718. HIWORD(wParam) == CBN_EDITCHANGE)
  719. {
  720. lpPropSheet->lParam |= CC_SCurrency;
  721. }
  722. break;
  723. }
  724. case ( IDC_POS_CURRENCY_SYM ) :
  725. {
  726. if (HIWORD(wParam) == CBN_SELCHANGE)
  727. {
  728. lpPropSheet->lParam |= CC_CurrSymPos;
  729. }
  730. break;
  731. }
  732. case ( IDC_NEG_NUM_FORMAT ) :
  733. {
  734. if (HIWORD(wParam) == CBN_SELCHANGE)
  735. {
  736. lpPropSheet->lParam |= CC_NegCurrFmt;
  737. }
  738. break;
  739. }
  740. case ( IDC_DECIMAL_SYMBOL ) :
  741. {
  742. if (HIWORD(wParam) == CBN_SELCHANGE ||
  743. HIWORD(wParam) == CBN_EDITCHANGE)
  744. {
  745. lpPropSheet->lParam |= CC_SMonDec;
  746. }
  747. break;
  748. }
  749. case ( IDC_NUM_DECIMAL_DIGITS ) :
  750. {
  751. if (HIWORD(wParam) == CBN_SELCHANGE)
  752. {
  753. lpPropSheet->lParam |= CC_ICurrDigits;
  754. }
  755. break;
  756. }
  757. case ( IDC_DIGIT_GROUP_SYMBOL ) :
  758. {
  759. if (HIWORD(wParam) == CBN_SELCHANGE ||
  760. HIWORD(wParam) == CBN_EDITCHANGE)
  761. {
  762. lpPropSheet->lParam |= CC_SMonThousand;
  763. }
  764. break;
  765. }
  766. case ( IDC_NUM_DIGITS_GROUP ) :
  767. {
  768. if (HIWORD(wParam) == CBN_SELCHANGE)
  769. {
  770. lpPropSheet->lParam |= CC_DMonGroup;
  771. }
  772. break;
  773. }
  774. }
  775. //
  776. // Turn on ApplyNow button.
  777. //
  778. if (lpPropSheet->lParam > CC_EverChg)
  779. {
  780. PropSheet_Changed(GetParent(hDlg), hDlg);
  781. }
  782. break;
  783. }
  784. default :
  785. {
  786. return (FALSE);
  787. }
  788. }
  789. //
  790. // Return success.
  791. //
  792. return (TRUE);
  793. }