Alexey Zavyalov: Add functionally Numbers, Currency, Time, Date tabs. Fix some bugs.
[reactos.git] / reactos / dll / cpl / intl_new / currency.c
1 /*
2 * PROJECT: ReactOS International Control Panel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/intl/monetary.c
5 * PURPOSE: ReactOS International Control Panel
6 * PROGRAMMERS: Alexey Zavyalov (gen_x@mail.ru)
7 */
8
9 /* INCLUDES *****************************************************************/
10
11 #include <windows.h>
12 #include <commctrl.h>
13 #include <cpl.h>
14
15 #include "intl.h"
16 #include "resource.h"
17
18 /* GLOBALS ******************************************************************/
19
20 #define SAMPLE_NUMBER L"123456789"
21 #define SAMPLE_NEG_NUMBER L"-123456789"
22 #define MAX_CURRENCY_UNIT_SAMPLES 2
23 #define MAX_POS_CURRENCY_SAMPLES 4
24 #define MAX_NEG_CURRENCY_SAMPLES 16
25 #define MAX_CURRENCY_SEP_SAMPLES 2
26 #define MAX_CURRENCY_FRAC_SAMPLES 10
27 #define MAX_FIELD_SEP_SAMPLES 1
28 #define MAX_FIELD_DIG_SAMPLES 3
29 #define EOLN_SIZE sizeof(WCHAR)
30
31 /* FUNCTIONS ****************************************************************/
32
33 /* Init number of digidts in field control box */
34 VOID
35 InitCurrencyDigNumCB(HWND hwndDlg)
36 {
37 WCHAR wszFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES][MAX_SAMPLES_STR_SIZE]=
38 {
39 L"0;0",
40 L"3;0",
41 L"3;2;0"
42 };
43
44 int nCBIndex;
45 int nRetCode;
46
47 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
48 WCHAR wszFieldDigNum[MAX_SAMPLES_STR_SIZE];
49 WCHAR* pwszFieldDigNumSmpl;
50
51 /* Get current field digits num */
52 GetLocaleInfoW(LOCALE_USER_DEFAULT,
53 LOCALE_SMONGROUPING,
54 wszFieldDigNum,
55 dwValueSize);
56
57 /* Clear all box content */
58 SendMessageW(GetDlgItem(hwndDlg, IDC_DIGINFIELDNUM_COMBO),
59 CB_RESETCONTENT,
60 (WPARAM)0,
61 (LPARAM)0);
62
63 /* Create standart list of field digits num */
64 for(nCBIndex=0;nCBIndex<MAX_FIELD_DIG_SAMPLES;nCBIndex++)
65 {
66
67 pwszFieldDigNumSmpl=InsSpacesFmt(SAMPLE_NUMBER,wszFieldDigNumSamples[nCBIndex]);
68 SendMessageW(GetDlgItem(hwndDlg, IDC_DIGINFIELDNUM_COMBO),
69 CB_ADDSTRING,
70 nCBIndex,
71 (LPARAM)pwszFieldDigNumSmpl);
72 free(pwszFieldDigNumSmpl);
73 }
74
75 pwszFieldDigNumSmpl=InsSpacesFmt(SAMPLE_NUMBER,wszFieldDigNum);
76 /* Set current item to value from registry */
77 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_DIGINFIELDNUM_COMBO),
78 CB_SELECTSTRING,
79 -1,
80 (LPARAM)(LPCSTR)pwszFieldDigNumSmpl);
81
82 /* if is not success, add new value to list and select them */
83 if(nRetCode == CB_ERR)
84 {
85 SendMessageW(GetDlgItem(hwndDlg, IDC_DIGINFIELDNUM_COMBO),
86 CB_ADDSTRING,
87 MAX_FIELD_DIG_SAMPLES+1,
88 (LPARAM)pwszFieldDigNumSmpl);
89 SendMessageW(GetDlgItem(hwndDlg, IDC_DIGINFIELDNUM_COMBO),
90 CB_SELECTSTRING,
91 -1,
92 (LPARAM)(LPCSTR)pwszFieldDigNumSmpl);
93 }
94
95 free(pwszFieldDigNumSmpl);
96 }
97
98
99 /* Init currency field separator control box */
100 VOID
101 InitCurrencyFieldSepCB(HWND hwndDlg)
102 {
103 WCHAR wszFieldSepSamples[MAX_FIELD_SEP_SAMPLES][MAX_SAMPLES_STR_SIZE]=
104 {
105 L" "
106 };
107
108 int nCBIndex;
109 int nRetCode;
110
111 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
112 WCHAR wszFieldSep[MAX_SAMPLES_STR_SIZE];
113
114 /* Get current field separator */
115 GetLocaleInfoW(LOCALE_USER_DEFAULT,
116 LOCALE_SMONTHOUSANDSEP,
117 wszFieldSep,
118 dwValueSize);
119
120 /* Clear all box content */
121 SendMessageW(GetDlgItem(hwndDlg, IDC_FIELDSEP_COMBO),
122 CB_RESETCONTENT,
123 (WPARAM)0,
124 (LPARAM)0);
125
126 /* Create standart list of field separators */
127 for(nCBIndex=0;nCBIndex<MAX_FIELD_SEP_SAMPLES;nCBIndex++)
128 {
129 SendMessageW(GetDlgItem(hwndDlg, IDC_FIELDSEP_COMBO),
130 CB_ADDSTRING,
131 nCBIndex,
132 (LPARAM)wszFieldSepSamples[nCBIndex]);
133 }
134
135 /* Set current item to value from registry */
136 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_FIELDSEP_COMBO),
137 CB_SELECTSTRING,
138 -1,
139 (LPARAM)(LPCSTR)wszFieldSep);
140
141 /* if is not success, add new value to list and select them */
142 if(nRetCode == CB_ERR)
143 {
144 SendMessageW(GetDlgItem(hwndDlg, IDC_FIELDSEP_COMBO),
145 CB_ADDSTRING,
146 MAX_FIELD_SEP_SAMPLES+1,
147 (LPARAM)wszFieldSep);
148 SendMessageW(GetDlgItem(hwndDlg, IDC_FIELDSEP_COMBO),
149 CB_SELECTSTRING,
150 -1,
151 (LPARAM)(LPCSTR)wszFieldSep);
152 }
153 }
154
155 /* Init number of fractional symbols control box */
156 VOID
157 InitCurrencyFracNumCB(HWND hwndDlg)
158 {
159 int nCBIndex;
160 int nRetCode;
161
162 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
163 WCHAR wszCurrencyFracNum[MAX_SAMPLES_STR_SIZE];
164 WCHAR wszFracCount[MAX_SAMPLES_STR_SIZE];
165
166 /* Get current number of fractional symbols */
167 GetLocaleInfoW(LOCALE_USER_DEFAULT,
168 LOCALE_ICURRDIGITS,
169 wszCurrencyFracNum,
170 dwValueSize);
171
172 /* Clear all box content */
173 SendMessageW(GetDlgItem(hwndDlg, IDC_FRACSYMBSNUM_COMBO),
174 CB_RESETCONTENT,
175 (WPARAM)0,
176 (LPARAM)0);
177
178 /* Create standart list of fractional symbols */
179 for(nCBIndex=0;nCBIndex<MAX_CURRENCY_FRAC_SAMPLES;nCBIndex++)
180 {
181 /* convert to wide char */
182 _itow(nCBIndex,wszFracCount,DECIMAL_RADIX);
183
184 SendMessageW(GetDlgItem(hwndDlg, IDC_FRACSYMBSNUM_COMBO),
185 CB_ADDSTRING,
186 nCBIndex,
187 (LPARAM)wszFracCount);
188 }
189
190 /* Set current item to value from registry */
191 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_FRACSYMBSNUM_COMBO),
192 CB_SETCURSEL,
193 (WPARAM)_wtoi(wszCurrencyFracNum),
194 (LPARAM)0);
195 }
196
197
198 /* Init positive currency sum format control box */
199 VOID
200 InitPosCurrencySumCB(HWND hwndDlg)
201 {
202 WCHAR wszPosCurrencySumSamples[MAX_POS_CURRENCY_SAMPLES][MAX_SAMPLES_STR_SIZE]=
203 {
204 L"$1,1",
205 L"1,1$",
206 L"$ 1,1",
207 L"1,1 $"
208 };
209
210 int nCBIndex;
211 int nRetCode;
212
213 WCHAR wszCurrPosFmt[MAX_SAMPLES_STR_SIZE];
214 WCHAR wszCurrencyUnit[MAX_SAMPLES_STR_SIZE];
215 WCHAR wszNewSample[MAX_SAMPLES_STR_SIZE];
216 WCHAR wszCurrencySep[MAX_SAMPLES_STR_SIZE];
217 WCHAR* pwszResultStr;
218 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
219
220 /* Get current currency sum format */
221 GetLocaleInfoW(LOCALE_USER_DEFAULT,
222 LOCALE_ICURRENCY,
223 wszCurrPosFmt,
224 dwValueSize);
225
226 /* Clear all box content */
227 SendMessageW(GetDlgItem(hwndDlg, IDC_POSCURRENCYSUM_COMBO),
228 CB_RESETCONTENT,
229 (WPARAM)0,
230 (LPARAM)0);
231
232 /* Get current currency separator */
233 GetLocaleInfoW(LOCALE_USER_DEFAULT,
234 LOCALE_SMONDECIMALSEP,
235 wszCurrencySep,
236 dwValueSize);
237
238 /* Get current currency unit */
239 GetLocaleInfoW(LOCALE_USER_DEFAULT,
240 LOCALE_SCURRENCY,
241 wszCurrencyUnit,
242 dwValueSize);
243
244 /* Create standart list of currency sum formats */
245 for(nCBIndex=0;nCBIndex<MAX_POS_CURRENCY_SAMPLES;nCBIndex++)
246 {
247 pwszResultStr = ReplaceSubStr(wszPosCurrencySumSamples[nCBIndex],
248 wszCurrencyUnit,
249 L"$");
250 wcscpy(wszNewSample,pwszResultStr);
251 free(pwszResultStr);
252 pwszResultStr = ReplaceSubStr(wszNewSample,
253 wszCurrencySep,
254 L",");
255 SendMessageW(GetDlgItem(hwndDlg, IDC_POSCURRENCYSUM_COMBO),
256 CB_ADDSTRING,
257 nCBIndex,
258 (LPARAM)pwszResultStr);
259 free(pwszResultStr);
260 }
261
262 /* Set current item to value from registry */
263 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_POSCURRENCYSUM_COMBO),
264 CB_SETCURSEL,
265 (WPARAM)_wtoi(wszCurrPosFmt),
266 (LPARAM)0);
267 }
268
269 /* Init negative currency sum format control box */
270 VOID
271 InitNegCurrencySumCB(HWND hwndDlg)
272 {
273 WCHAR wszNegCurrencySumSamples[MAX_NEG_CURRENCY_SAMPLES][MAX_SAMPLES_STR_SIZE]=
274 {
275 L"(?1,1)",
276 L"-?1,1",
277 L"?-1,1",
278 L"?1,1-",
279 L"(1,1?)",
280 L"-1,1?",
281 L"1,1-?",
282 L"1,1?-",
283 L"-1,1 ?",
284 L"-? 1,1",
285 L"1,1 ?-",
286 L"? 1,1-",
287 L"? -1,1",
288 L"1,1- ?",
289 L"(? 1,1)",
290 L"(1,1 ?)" /* 16 */
291 };
292
293 int nCBIndex;
294 int nRetCode;
295
296 WCHAR wszCurrNegFmt[MAX_SAMPLES_STR_SIZE];
297 WCHAR wszCurrencyUnit[MAX_SAMPLES_STR_SIZE];
298 WCHAR wszCurrencySep[MAX_SAMPLES_STR_SIZE];
299 WCHAR wszNewSample[MAX_SAMPLES_STR_SIZE];
300 WCHAR* pwszResultStr;
301 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
302
303 /* Get current currency sum format */
304 GetLocaleInfoW(LOCALE_USER_DEFAULT,
305 LOCALE_INEGCURR,
306 wszCurrNegFmt,
307 dwValueSize);
308
309 /* Clear all box content */
310 SendMessageW(GetDlgItem(hwndDlg, IDC_NEGCURRENCYSUM_COMBO),
311 CB_RESETCONTENT,
312 (WPARAM)0,
313 (LPARAM)0);
314
315 /* Get current currency unit */
316 GetLocaleInfoW(LOCALE_USER_DEFAULT,
317 LOCALE_SCURRENCY,
318 wszCurrencyUnit,
319 dwValueSize);
320
321 /* Get current currency separator */
322 GetLocaleInfoW(LOCALE_USER_DEFAULT,
323 LOCALE_SMONDECIMALSEP,
324 wszCurrencySep,
325 dwValueSize);
326
327 /* Create standart list of currency sum formats */
328 for(nCBIndex=0;nCBIndex<MAX_NEG_CURRENCY_SAMPLES;nCBIndex++)
329 {
330 pwszResultStr = ReplaceSubStr(wszNegCurrencySumSamples[nCBIndex],
331 wszCurrencyUnit,
332 L"?");
333 wcscpy(wszNewSample,pwszResultStr);
334 free(pwszResultStr);
335 pwszResultStr = ReplaceSubStr(wszNewSample,
336 wszCurrencySep,
337 L",");
338 SendMessageW(GetDlgItem(hwndDlg, IDC_NEGCURRENCYSUM_COMBO),
339 CB_ADDSTRING,
340 nCBIndex,
341 (LPARAM)pwszResultStr);
342 free(pwszResultStr);
343 }
344
345 /* Set current item to value from registry */
346 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_NEGCURRENCYSUM_COMBO),
347 CB_SETCURSEL,
348 (WPARAM)_wtoi(wszCurrNegFmt),
349 (LPARAM)0);
350 }
351
352 /* Init currency separator control box */
353 VOID
354 InitCurrencySepCB(HWND hwndDlg)
355 {
356 WCHAR wszCurrencySepSamples[MAX_CURRENCY_SEP_SAMPLES][MAX_SAMPLES_STR_SIZE]=
357 {
358 L",",
359 L"."
360 };
361
362 int nCBIndex;
363 int nRetCode;
364
365 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
366 WCHAR wszCurrencySep[MAX_SAMPLES_STR_SIZE];
367
368 /* Get current currency separator */
369 GetLocaleInfoW(LOCALE_USER_DEFAULT,
370 LOCALE_SMONDECIMALSEP,
371 wszCurrencySep,
372 dwValueSize);
373
374 /* Clear all box content */
375 SendMessageW(GetDlgItem(hwndDlg, IDC_WHOLEFRACTSEP_COMBO),
376 CB_RESETCONTENT,
377 (WPARAM)0,
378 (LPARAM)0);
379
380 /* Create standart list of currency separators */
381 for(nCBIndex=0;nCBIndex<MAX_CURRENCY_SEP_SAMPLES;nCBIndex++)
382 {
383 SendMessageW(GetDlgItem(hwndDlg, IDC_WHOLEFRACTSEP_COMBO),
384 CB_ADDSTRING,
385 nCBIndex,
386 (LPARAM)wszCurrencySepSamples[nCBIndex]);
387 }
388
389 /* Set current item to value from registry */
390 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_WHOLEFRACTSEP_COMBO),
391 CB_SELECTSTRING,
392 -1,
393 (LPARAM)(LPCSTR)wszCurrencySep);
394
395 /* if is not success, add new value to list and select them */
396 if(nRetCode == CB_ERR)
397 {
398 SendMessageW(GetDlgItem(hwndDlg, IDC_WHOLEFRACTSEP_COMBO),
399 CB_ADDSTRING,
400 MAX_CURRENCY_SEP_SAMPLES+1,
401 (LPARAM)wszCurrencySep);
402 SendMessageW(GetDlgItem(hwndDlg, IDC_WHOLEFRACTSEP_COMBO),
403 CB_SELECTSTRING,
404 -1,
405 (LPARAM)(LPCSTR)wszCurrencySep);
406 }
407 }
408
409 /* Init currency unit control box */
410 VOID
411 InitCurrencyUnitCB(HWND hwndDlg)
412 {
413 WCHAR wszCurrencyUnitSamples[MAX_CURRENCY_UNIT_SAMPLES][MAX_SAMPLES_STR_SIZE]=
414 {
415 L"$"
416 };
417
418 int nCBIndex;
419 int nRetCode;
420
421 DWORD dwValueSize=MAX_SAMPLES_STR_SIZE*sizeof(WCHAR)+EOLN_SIZE;
422 WCHAR wszCurrencyUnit[MAX_SAMPLES_STR_SIZE];
423
424 /* Get current currency unit */
425 GetLocaleInfoW(LOCALE_USER_DEFAULT,
426 LOCALE_SCURRENCY,
427 wszCurrencyUnit,
428 dwValueSize);
429
430 /* Clear all box content */
431 SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCYUNIT_COMBO),
432 CB_RESETCONTENT,
433 (WPARAM)0,
434 (LPARAM)0);
435
436 /* Create standart list of currency units */
437 for(nCBIndex=0;nCBIndex<MAX_CURRENCY_UNIT_SAMPLES;nCBIndex++)
438 {
439 SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCYUNIT_COMBO),
440 CB_ADDSTRING,
441 nCBIndex,
442 (LPARAM)wszCurrencyUnitSamples[nCBIndex]);
443 }
444
445 /* Set current item to value from registry */
446 nRetCode = SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCYUNIT_COMBO),
447 CB_SELECTSTRING,
448 -1,
449 (LPARAM)(LPCSTR)wszCurrencyUnit);
450
451 /* if is not success, add new value to list and select them */
452 if(nRetCode == CB_ERR)
453 {
454 SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCYUNIT_COMBO),
455 CB_ADDSTRING,
456 MAX_CURRENCY_UNIT_SAMPLES+1,
457 (LPARAM)wszCurrencyUnit);
458 SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCYUNIT_COMBO),
459 CB_SELECTSTRING,
460 -1,
461 (LPARAM)(LPCSTR)wszCurrencyUnit);
462 }
463 }
464
465 /* Set number of digidts in field */
466 BOOL
467 SetCurrencyDigNum(HWND hwndDlg)
468 {
469 WCHAR wszFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES][MAX_SAMPLES_STR_SIZE]=
470 {
471 L"0;0",
472 L"3;0",
473 L"3;2;0"
474 };
475
476 int nCurrSel;
477
478 /* Get setted number of digidts in field */
479 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_DIGINFIELDNUM_COMBO),
480 CB_GETCURSEL,
481 (WPARAM)0,
482 (LPARAM)0);
483
484 /* Save number of digidts in field */
485 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONGROUPING, wszFieldDigNumSamples[nCurrSel]);
486
487
488 return TRUE;
489 }
490
491 /* Set currency field separator */
492 BOOL
493 SetCurrencyFieldSep(HWND hwndDlg)
494 {
495 WCHAR wszCurrencyFieldSep[MAX_SAMPLES_STR_SIZE];
496
497 /* Get setted currency field separator */
498 SendMessageW(GetDlgItem(hwndDlg, IDC_FIELDSEP_COMBO),
499 WM_GETTEXT,
500 (WPARAM)MAX_SAMPLES_STR_SIZE,
501 (LPARAM)(LPCSTR)wszCurrencyFieldSep);
502
503 /* Save currency field separator */
504 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONTHOUSANDSEP, wszCurrencyFieldSep);
505
506 return TRUE;
507 }
508
509 /* Set number of fractional symbols */
510 BOOL
511 SetCurrencyFracSymNum(HWND hwndDlg)
512 {
513 WCHAR wszCurrencyFracSymNum[MAX_SAMPLES_STR_SIZE];
514 INT nCurrSel;
515
516 /* Get setted number of fractional symbols */
517 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_FRACSYMBSNUM_COMBO),
518 CB_GETCURSEL,
519 (WPARAM)0,
520 (LPARAM)0);
521
522 /* convert to wide char */
523 _itow(nCurrSel,wszCurrencyFracSymNum,DECIMAL_RADIX);
524
525 /* Save number of fractional symbols */
526 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ICURRDIGITS, wszCurrencyFracSymNum);
527
528 return TRUE;
529 }
530
531 /* Set currency separator */
532 BOOL
533 SetCurrencySep(HWND hwndDlg)
534 {
535 WCHAR wszCurrencySep[MAX_SAMPLES_STR_SIZE];
536
537 /* Get setted currency decimal separator */
538 SendMessageW(GetDlgItem(hwndDlg, IDC_WHOLEFRACTSEP_COMBO),
539 WM_GETTEXT,
540 (WPARAM)MAX_SAMPLES_STR_SIZE,
541 (LPARAM)(LPCSTR)wszCurrencySep);
542
543 /* TODO: Add check for correctly input */
544
545 /* Save currency separator */
546 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SMONDECIMALSEP, wszCurrencySep);
547
548 return TRUE;
549 }
550
551 /* Set negative currency sum format */
552 BOOL
553 SetNegCurrencySumFmt(HWND hwndDlg)
554 {
555 WCHAR wszNegCurrencySumFmt[MAX_SAMPLES_STR_SIZE];
556 INT nCurrSel;
557
558 /* Get setted currency unit */
559 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_NEGCURRENCYSUM_COMBO),
560 CB_GETCURSEL,
561 (WPARAM)0,
562 (LPARAM)0);
563
564 /* convert to wide char */
565 _itow(nCurrSel,wszNegCurrencySumFmt,DECIMAL_RADIX);
566
567 /* Save currency sum format */
568 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_INEGCURR, wszNegCurrencySumFmt);
569
570 return TRUE;
571 }
572
573 /* Set positive currency sum format */
574 BOOL
575 SetPosCurrencySumFmt(HWND hwndDlg)
576 {
577 WCHAR wszPosCurrencySumFmt[MAX_SAMPLES_STR_SIZE];
578 INT nCurrSel;
579
580 /* Get setted currency unit */
581 nCurrSel=SendMessageW(GetDlgItem(hwndDlg, IDC_POSCURRENCYSUM_COMBO),
582 CB_GETCURSEL,
583 (WPARAM)0,
584 (LPARAM)0);
585
586 /* convert to wide char */
587 _itow(nCurrSel,wszPosCurrencySumFmt,DECIMAL_RADIX);
588
589 /* Save currency sum format */
590 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_ICURRENCY, wszPosCurrencySumFmt);
591
592 return TRUE;
593 }
594
595 /* Set currency unit */
596 BOOL
597 SetCurrencyUnit(HWND hwndDlg)
598 {
599 WCHAR wszCurrencyUnit[MAX_SAMPLES_STR_SIZE];
600
601 /* Get setted currency unit */
602 SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCYUNIT_COMBO),
603 WM_GETTEXT,
604 (WPARAM)MAX_SAMPLES_STR_SIZE,
605 (LPARAM)(LPCSTR)wszCurrencyUnit);
606
607 /* Save currency unit */
608 SetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SCURRENCY, wszCurrencyUnit);
609
610 return TRUE;
611 }
612
613 /* Update all currency locale samples */
614 static
615 VOID
616 UpdateCurrencyLocaleSamples(HWND hwndDlg,
617 LCID lcidLocale)
618 {
619 WCHAR OutBuffer[MAX_FMT_SIZE];
620
621 /* Get currency format sample */
622 GetCurrencyFormatW(lcidLocale,
623 LOCALE_USE_CP_ACP,
624 SAMPLE_NUMBER,
625 NULL,
626 OutBuffer,
627 MAX_FMT_SIZE);
628
629 SendMessageW(GetDlgItem(hwndDlg, IDC_CURRENCY_EDIT),
630 WM_SETTEXT,
631 (WPARAM)0,
632 (LPARAM)OutBuffer);
633
634 /* Get negative currency format sample */
635 GetCurrencyFormatW(lcidLocale,
636 LOCALE_USE_CP_ACP,
637 SAMPLE_NEG_NUMBER,
638 NULL,
639 OutBuffer,
640 MAX_FMT_SIZE);
641
642 SendMessageW(GetDlgItem(hwndDlg, IDC_NEGCURRENCY_EDIT),
643 WM_SETTEXT,
644 (WPARAM)0,
645 (LPARAM)OutBuffer);
646 }
647
648 /* Currency options setup page dialog callback */
649 INT_PTR
650 CALLBACK
651 CurrencyOptsSetProc(HWND hwndDlg,
652 UINT uMsg,
653 WPARAM wParam,
654 LPARAM lParam)
655 {
656 UNREFERENCED_PARAMETER(lParam);
657 UNREFERENCED_PARAMETER(wParam);
658 UNREFERENCED_PARAMETER(hwndDlg);
659 switch(uMsg)
660 {
661 case WM_INITDIALOG:
662 {
663 InitCurrencyUnitCB(hwndDlg);
664 InitCurrencySepCB(hwndDlg);
665 InitCurrencyFieldSepCB(hwndDlg);
666 InitCurrencyFracNumCB(hwndDlg);
667 InitPosCurrencySumCB(hwndDlg);
668 InitNegCurrencySumCB(hwndDlg);
669 InitCurrencyDigNumCB(hwndDlg);
670
671 UpdateCurrencyLocaleSamples(hwndDlg, LOCALE_USER_DEFAULT);
672 }
673 break;
674
675 case WM_COMMAND:
676 {
677 switch (LOWORD(wParam))
678 {
679 case IDC_CURRENCYUNIT_COMBO:
680 case IDC_POSCURRENCYSUM_COMBO:
681 case IDC_NEGCURRENCYSUM_COMBO:
682 case IDC_WHOLEFRACTSEP_COMBO:
683 case IDC_FRACSYMBSNUM_COMBO:
684 case IDC_FIELDSEP_COMBO:
685 case IDC_DIGINFIELDNUM_COMBO:
686 {
687 if (HIWORD(wParam) == CBN_SELCHANGE ||
688 HIWORD(wParam) == CBN_EDITCHANGE)
689 {
690 /* Set "Apply" button enabled */
691 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
692 }
693 }
694 break;
695 }
696 }
697 break;
698
699 case WM_NOTIFY:
700 {
701 LPNMHDR lpnm = (LPNMHDR)lParam;
702 /* If push apply button */
703 if (lpnm->code == (UINT)PSN_APPLY)
704 {
705 if(!SetCurrencyUnit(hwndDlg)) break;
706 if(!SetPosCurrencySumFmt(hwndDlg)) break;
707 if(!SetNegCurrencySumFmt(hwndDlg)) break;
708 if(!SetCurrencySep(hwndDlg)) break;
709 if(!SetCurrencyFracSymNum(hwndDlg)) break;
710 if(!SetCurrencyFieldSep(hwndDlg)) break;
711 if(!SetCurrencyDigNum(hwndDlg)) break;
712
713 /* Update sum format samples */
714 InitPosCurrencySumCB(hwndDlg);
715 InitNegCurrencySumCB(hwndDlg);
716
717 /* FIXME: */
718 _sleep(15);
719 UpdateCurrencyLocaleSamples(hwndDlg, LOCALE_USER_DEFAULT);
720 }
721 }
722 break;
723 }
724 return FALSE;
725 }
726
727 /* EOF */