Source code of Windows XP (NT5)
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.

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