Create a branch for network fixes.
[reactos.git] / dll / cpl / intl / numbers.c
1 /*
2 * ReactOS
3 * Copyright (C) 2004 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id$
20 *
21 * PROJECT: ReactOS International Control Panel
22 * FILE: lib/cpl/intl/numbers.c
23 * PURPOSE: Numbers property page
24 * PROGRAMMER: Eric Kohl
25 */
26
27 #include <windows.h>
28 #include <commctrl.h>
29 #include <cpl.h>
30 #include <tchar.h>
31
32 #include "intl.h"
33 #include "resource.h"
34
35 #define SAMPLE_NUMBER _T("123456789")
36 #define SAMPLE_NEG_NUMBER _T("-123456789")
37 #define MAX_NUM_SEP_SAMPLES 2
38 #define MAX_FRAC_NUM_SAMPLES 10
39 #define MAX_FIELD_SEP_SAMPLES 1
40 #define MAX_FIELD_DIG_SAMPLES 3
41 #define MAX_NEG_SIGN_SAMPLES 1
42 #define MAX_NEG_NUMBERS_SAMPLES 5
43 #define MAX_LEAD_ZEROES_SAMPLES 2
44 #define MAX_LIST_SEP_SAMPLES 1
45 #define MAX_UNITS_SYS_SAMPLES 2
46
47 static LPTSTR lpNumSepSamples[MAX_NUM_SEP_SAMPLES] =
48 {_T(","), _T(".")};
49 static LPTSTR lpFieldSepSamples[MAX_FIELD_SEP_SAMPLES] =
50 {_T(" ")};
51 static LPTSTR lpFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES] =
52 {_T("0;0"), _T("3;0"), _T("3;2;0")};
53 static LPTSTR lpNegSignSamples[MAX_NEG_SIGN_SAMPLES] =
54 {_T("-")};
55 static LPTSTR lpNegNumFmtSamples[MAX_NEG_NUMBERS_SAMPLES] =
56 {_T("(1,1)"), _T("-1,1"), _T("- 1,1"), _T("1,1-"), _T("1,1 -")};
57 static LPTSTR lpLeadNumFmtSamples[MAX_LEAD_ZEROES_SAMPLES] =
58 {_T(",7"), _T("0,7")};
59 static LPTSTR lpListSepSamples[MAX_LIST_SEP_SAMPLES] =
60 {_T(";")};
61 static LPTSTR lpUnitsSysSamples[MAX_UNITS_SYS_SAMPLES] =
62 {_T("Metrics"), _T("Americans")};
63
64
65 /* Init num decimal separator control box */
66 static VOID
67 InitNumDecimalSepCB(HWND hwndDlg, LCID lcid)
68 {
69 TCHAR szNumSep[MAX_SAMPLES_STR_SIZE];
70 INT nCBIndex;
71 INT nRetCode;
72
73 /* Get current decimal separator */
74 GetLocaleInfo(lcid,
75 LOCALE_SDECIMAL,
76 szNumSep,
77 MAX_SAMPLES_STR_SIZE);
78
79 /* Clear all box content */
80 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
81 CB_RESETCONTENT,
82 (WPARAM)0,
83 (LPARAM)0);
84
85 /* Create standard list of decimal separators */
86 for (nCBIndex = 0; nCBIndex < MAX_NUM_SEP_SAMPLES; nCBIndex++)
87 {
88 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
89 CB_ADDSTRING,
90 nCBIndex,
91 (LPARAM)lpNumSepSamples[nCBIndex]);
92 }
93
94 /* Set current item to value from registry */
95 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
96 CB_SELECTSTRING,
97 -1,
98 (LPARAM)(LPCSTR)szNumSep);
99
100 /* if is not success, add new value to list and select them */
101 if (nRetCode == CB_ERR)
102 {
103 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
104 CB_ADDSTRING,
105 MAX_NUM_SEP_SAMPLES,
106 (LPARAM)szNumSep);
107 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
108 CB_SELECTSTRING,
109 -1,
110 (LPARAM)szNumSep);
111 }
112 }
113
114 /* Init number of fractional symbols control box */
115 static VOID
116 InitNumOfFracSymbCB(HWND hwndDlg, LCID lcid)
117 {
118 TCHAR szFracNum[MAX_SAMPLES_STR_SIZE];
119 TCHAR szFracCount[MAX_SAMPLES_STR_SIZE];
120 INT nCBIndex;
121 INT nRetCode;
122
123 /* Get current number of fractional symbols */
124 GetLocaleInfo(lcid,
125 LOCALE_IDIGITS,
126 szFracNum,
127 MAX_SAMPLES_STR_SIZE);
128
129 /* Clear all box content */
130 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
131 CB_RESETCONTENT,
132 (WPARAM)0,
133 (LPARAM)0);
134
135 /* Create standard list of fractional symbols */
136 for (nCBIndex = 0; nCBIndex < MAX_FRAC_NUM_SAMPLES; nCBIndex++)
137 {
138 /* convert to wide char */
139 _itot(nCBIndex, szFracCount, DECIMAL_RADIX);
140
141 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
142 CB_ADDSTRING,
143 nCBIndex,
144 (LPARAM)szFracCount);
145 }
146
147 /* Set current item to value from registry */
148 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
149 CB_SETCURSEL,
150 (WPARAM)_ttoi(szFracNum),
151 (LPARAM)0);
152 }
153
154 /* Init field separator control box */
155 static VOID
156 InitNumFieldSepCB(HWND hwndDlg, LCID lcid)
157 {
158 TCHAR szFieldSep[MAX_SAMPLES_STR_SIZE];
159 INT nCBIndex;
160 INT nRetCode;
161
162 /* Get current field separator */
163 GetLocaleInfo(lcid,
164 LOCALE_STHOUSAND,
165 szFieldSep,
166 MAX_SAMPLES_STR_SIZE);
167
168 /* Clear all box content */
169 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
170 CB_RESETCONTENT,
171 (WPARAM)0,
172 (LPARAM)0);
173
174 /* Create standart list of field separators */
175 for (nCBIndex = 0; nCBIndex < MAX_FIELD_SEP_SAMPLES; nCBIndex++)
176 {
177 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
178 CB_ADDSTRING,
179 nCBIndex,
180 (LPARAM)lpFieldSepSamples[nCBIndex]);
181 }
182
183 /* Set current item to value from registry */
184 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
185 CB_SELECTSTRING,
186 -1,
187 (LPARAM)szFieldSep);
188
189 /* if is not success, add new value to list and select them */
190 if (nRetCode == CB_ERR)
191 {
192 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
193 CB_ADDSTRING,
194 MAX_FIELD_SEP_SAMPLES+1,
195 (LPARAM)szFieldSep);
196 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
197 CB_SELECTSTRING,
198 -1,
199 (LPARAM)szFieldSep);
200 }
201 }
202
203 /* Init number of digidts in field control box */
204 static VOID
205 InitFieldDigNumCB(HWND hwndDlg, LCID lcid)
206 {
207 TCHAR szFieldDigNum[MAX_SAMPLES_STR_SIZE];
208 LPTSTR pszFieldDigNumSmpl;
209 INT nCBIndex;
210 INT nRetCode;
211
212 /* Get current field digits num */
213 GetLocaleInfo(lcid,
214 LOCALE_SGROUPING,
215 szFieldDigNum,
216 MAX_SAMPLES_STR_SIZE);
217
218 /* Clear all box content */
219 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
220 CB_RESETCONTENT,
221 (WPARAM)0,
222 (LPARAM)0);
223
224 /* Create standart list of field digits num */
225 for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
226 {
227
228 pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
229 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
230 CB_ADDSTRING,
231 nCBIndex,
232 (LPARAM)pszFieldDigNumSmpl);
233 free(pszFieldDigNumSmpl);
234 }
235
236 pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, szFieldDigNum);
237 /* Set current item to value from registry */
238 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
239 CB_SELECTSTRING,
240 -1,
241 (LPARAM)pszFieldDigNumSmpl);
242
243 /* if is not success, add new value to list and select them */
244 if (nRetCode == CB_ERR)
245 {
246 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
247 CB_ADDSTRING,
248 MAX_FIELD_DIG_SAMPLES+1,
249 (LPARAM)pszFieldDigNumSmpl);
250 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
251 CB_SELECTSTRING,
252 -1,
253 (LPARAM)pszFieldDigNumSmpl);
254 }
255
256 free(pszFieldDigNumSmpl);
257 }
258
259 /* Init negative sign control box */
260 static VOID
261 InitNegSignCB(HWND hwndDlg, LCID lcid)
262 {
263 TCHAR szNegSign[MAX_SAMPLES_STR_SIZE];
264 INT nCBIndex;
265 INT nRetCode;
266
267 /* Get current negative sign */
268 GetLocaleInfoW(lcid,
269 LOCALE_SNEGATIVESIGN,
270 szNegSign,
271 MAX_SAMPLES_STR_SIZE);
272
273 /* Clear all box content */
274 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
275 CB_RESETCONTENT,
276 (WPARAM)0,
277 (LPARAM)0);
278
279 /* Create standart list of signs */
280 for (nCBIndex = 0; nCBIndex < MAX_NEG_SIGN_SAMPLES; nCBIndex++)
281 {
282 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
283 CB_ADDSTRING,
284 nCBIndex,
285 (LPARAM)lpNegSignSamples[nCBIndex]);
286 }
287
288 /* Set current item to value from registry */
289 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
290 CB_SELECTSTRING,
291 -1,
292 (LPARAM)szNegSign);
293
294 /* if is not success, add new value to list and select them */
295 if (nRetCode == CB_ERR)
296 {
297 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
298 CB_ADDSTRING,
299 MAX_NUM_SEP_SAMPLES+1,
300 (LPARAM)szNegSign);
301 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
302 CB_SELECTSTRING,
303 -1,
304 (LPARAM)szNegSign);
305 }
306 }
307
308 /* Init negative numbers format control box */
309 static VOID
310 InitNegNumFmtCB(HWND hwndDlg, LCID lcid)
311 {
312 TCHAR szNegNumFmt[MAX_SAMPLES_STR_SIZE];
313 TCHAR szNumSep[MAX_SAMPLES_STR_SIZE];
314 TCHAR szNegSign[MAX_SAMPLES_STR_SIZE];
315 TCHAR szNewSample[MAX_SAMPLES_STR_SIZE];
316 LPTSTR pszResultStr;
317 INT nCBIndex;
318 INT nRetCode;
319
320 /* Get current negative numbers format */
321 GetLocaleInfo(lcid,
322 LOCALE_INEGNUMBER,
323 szNegNumFmt,
324 MAX_SAMPLES_STR_SIZE);
325
326 /* Clear all box content */
327 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
328 CB_RESETCONTENT,
329 (WPARAM)0,
330 (LPARAM)0);
331
332 /* Get current decimal separator */
333 GetLocaleInfo(lcid,
334 LOCALE_SDECIMAL,
335 szNumSep,
336 MAX_SAMPLES_STR_SIZE);
337
338 /* Get current negative sign */
339 GetLocaleInfo(lcid,
340 LOCALE_SNEGATIVESIGN,
341 szNegSign,
342 MAX_SAMPLES_STR_SIZE);
343
344 /* Create standart list of negative numbers formats */
345 for (nCBIndex = 0; nCBIndex < MAX_NEG_NUMBERS_SAMPLES; nCBIndex++)
346 {
347 /* Replace standart separator to setted */
348 pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
349 szNumSep,
350 _T(","));
351 _tcscpy(szNewSample, pszResultStr);
352 free(pszResultStr);
353 /* Replace standart negative sign to setted */
354 pszResultStr = ReplaceSubStr(szNewSample,
355 szNegSign,
356 _T("-"));
357 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
358 CB_ADDSTRING,
359 nCBIndex,
360 (LPARAM)pszResultStr);
361 free(pszResultStr);
362 }
363
364 /* Set current item to value from registry */
365 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
366 CB_SETCURSEL,
367 (WPARAM)_ttoi(szNegNumFmt),
368 (LPARAM)0);
369 }
370
371 /* Init leading zeroes control box */
372 static VOID
373 InitLeadingZeroesCB(HWND hwndDlg, LCID lcid)
374 {
375 TCHAR szLeadNumFmt[MAX_SAMPLES_STR_SIZE];
376 TCHAR szNumSep[MAX_SAMPLES_STR_SIZE];
377 LPTSTR pszResultStr;
378 INT nCBIndex;
379 INT nRetCode;
380
381 /* Get current leading zeroes format */
382 GetLocaleInfo(lcid,
383 LOCALE_ILZERO,
384 szLeadNumFmt,
385 MAX_SAMPLES_STR_SIZE);
386
387 /* Clear all box content */
388 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
389 CB_RESETCONTENT,
390 (WPARAM)0,
391 (LPARAM)0);
392
393 /* Get current decimal separator */
394 GetLocaleInfo(lcid,
395 LOCALE_SDECIMAL,
396 szNumSep,
397 MAX_SAMPLES_STR_SIZE);
398
399 /* Create list of standart leading zeroes formats */
400 for (nCBIndex = 0; nCBIndex < MAX_LEAD_ZEROES_SAMPLES; nCBIndex++)
401 {
402 pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
403 szNumSep,
404 _T(","));
405 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
406 CB_ADDSTRING,
407 nCBIndex,
408 (LPARAM)pszResultStr);
409 free(pszResultStr);
410 }
411
412 /* Set current item to value from registry */
413 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
414 CB_SETCURSEL,
415 (WPARAM)_ttoi(szLeadNumFmt),
416 (LPARAM)0);
417 }
418
419 static VOID
420 InitListSepCB(HWND hwndDlg,
421 LCID lcid)
422 {
423 TCHAR szListSep[MAX_SAMPLES_STR_SIZE];
424 INT nCBIndex;
425 INT nRetCode;
426
427 /* Get current list separator */
428 GetLocaleInfo(lcid,
429 LOCALE_SLIST,
430 szListSep,
431 MAX_SAMPLES_STR_SIZE);
432
433 /* Clear all box content */
434 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
435 CB_RESETCONTENT,
436 (WPARAM)0,
437 (LPARAM)0);
438
439 /* Create standart list of signs */
440 for (nCBIndex = 0; nCBIndex < MAX_LIST_SEP_SAMPLES; nCBIndex++)
441 {
442 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
443 CB_ADDSTRING,
444 nCBIndex,
445 (LPARAM)lpListSepSamples[nCBIndex]);
446 }
447
448 /* Set current item to value from registry */
449 nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
450 CB_SELECTSTRING,
451 -1,
452 (LPARAM)szListSep);
453
454 /* if is not success, add new value to list and select them */
455 if (nRetCode == CB_ERR)
456 {
457 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
458 CB_ADDSTRING,
459 MAX_LIST_SEP_SAMPLES+1,
460 (LPARAM)szListSep);
461 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
462 CB_SELECTSTRING,
463 -1,
464 (LPARAM)szListSep);
465 }
466 }
467
468 /* Init system of units control box */
469 static VOID
470 InitUnitsSysCB(HWND hwndDlg,
471 LCID lcid)
472 {
473 TCHAR szUnitsSys[MAX_SAMPLES_STR_SIZE];
474 INT nCBIndex;
475
476 /* Get current system of units */
477 GetLocaleInfo(lcid,
478 LOCALE_IMEASURE,
479 szUnitsSys,
480 MAX_SAMPLES_STR_SIZE);
481
482 /* Clear all box content */
483 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
484 CB_RESETCONTENT,
485 (WPARAM)0,
486 (LPARAM)0);
487
488 /* Create list of standart system of units */
489 for (nCBIndex = 0; nCBIndex < MAX_UNITS_SYS_SAMPLES; nCBIndex++)
490 {
491 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
492 CB_ADDSTRING,
493 0, //nCBIndex,
494 (LPARAM)lpUnitsSysSamples[nCBIndex]);
495 }
496
497 /* Set current item to value from registry */
498 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
499 CB_SETCURSEL,
500 (WPARAM)_ttoi(szUnitsSys),
501 (LPARAM)0);
502 }
503
504 /* Update all numbers locale samples */
505 static VOID
506 UpdateNumSamples(HWND hwndDlg,
507 LCID lcid)
508 {
509 TCHAR OutBuffer[MAX_FMT_SIZE];
510
511 /* Get positive number format sample */
512 GetNumberFormat(lcid,
513 0,
514 SAMPLE_NUMBER,
515 NULL,
516 OutBuffer,
517 MAX_FMT_SIZE);
518
519 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSPOSSAMPLE),
520 WM_SETTEXT,
521 0,
522 (LPARAM)OutBuffer);
523
524 /* Get positive number format sample */
525 GetNumberFormat(lcid,
526 0,
527 SAMPLE_NEG_NUMBER,
528 NULL,
529 OutBuffer,
530 MAX_FMT_SIZE);
531
532 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNEGSAMPLE),
533 WM_SETTEXT,
534 0,
535 (LPARAM)OutBuffer);
536 }
537
538 /* Set num decimal separator */
539 static BOOL
540 SetNumDecimalSep(HWND hwndDlg,
541 LCID lcid)
542 {
543 TCHAR szDecimalSep[MAX_SAMPLES_STR_SIZE];
544
545 /* Get setted decimal separator */
546 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
547 WM_GETTEXT,
548 (WPARAM)MAX_SAMPLES_STR_SIZE,
549 (LPARAM)szDecimalSep);
550
551 /* Save decimal separator */
552 SetLocaleInfo(lcid, LOCALE_SDECIMAL, szDecimalSep);
553
554 return TRUE;
555 }
556
557 /* Set number of fractional symbols */
558 static BOOL
559 SetFracSymNum(HWND hwndDlg,
560 LCID lcid)
561 {
562 TCHAR szFracSymNum[MAX_SAMPLES_STR_SIZE];
563 INT nCurrSel;
564
565 /* Get setted number of fractional symbols */
566 nCurrSel = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
567 CB_GETCURSEL,
568 (WPARAM)0,
569 (LPARAM)0);
570
571 /* convert to wide char */
572 _itot(nCurrSel, szFracSymNum, DECIMAL_RADIX);
573
574 /* Save number of fractional symbols */
575 SetLocaleInfo(lcid, LOCALE_IDIGITS, szFracSymNum);
576
577 return TRUE;
578 }
579
580 /* Set field separator */
581 static BOOL
582 SetNumFieldSep(HWND hwndDlg,
583 LCID lcid)
584 {
585 TCHAR szFieldSep[MAX_SAMPLES_STR_SIZE];
586
587 /* Get setted field separator */
588 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
589 WM_GETTEXT,
590 (WPARAM)MAX_SAMPLES_STR_SIZE,
591 (LPARAM)szFieldSep);
592
593 /* Save field separator */
594 SetLocaleInfo(lcid, LOCALE_STHOUSAND, szFieldSep);
595
596 return TRUE;
597 }
598
599 /* Set number of digidts in field */
600 static BOOL
601 SetFieldDigNum(HWND hwndDlg,
602 LCID lcid)
603 {
604 INT nCurrSel;
605
606 /* Get setted number of digidts in field */
607 nCurrSel=SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
608 CB_GETCURSEL,
609 (WPARAM)0,
610 (LPARAM)0);
611
612 /* Save number of digidts in field */
613 SetLocaleInfo(lcid, LOCALE_SGROUPING, lpFieldDigNumSamples[nCurrSel]);
614
615 return TRUE;
616 }
617
618 /* Set negative sign */
619 static BOOL
620 SetNumNegSign(HWND hwndDlg,
621 LCID lcid)
622 {
623 TCHAR szNegSign[MAX_SAMPLES_STR_SIZE];
624
625 /* Get setted negative sign */
626 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
627 WM_GETTEXT,
628 (WPARAM)MAX_SAMPLES_STR_SIZE,
629 (LPARAM)szNegSign);
630
631 /* Save negative sign */
632 SetLocaleInfo(lcid, LOCALE_SNEGATIVESIGN, szNegSign);
633
634 return TRUE;
635 }
636
637 /* Set negative sum format */
638 static BOOL
639 SetNegSumFmt(HWND hwndDlg,
640 LCID lcid)
641 {
642 TCHAR szNegSumFmt[MAX_SAMPLES_STR_SIZE];
643 INT nCurrSel;
644
645 /* Get setted negative sum format */
646 nCurrSel = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
647 CB_GETCURSEL,
648 (WPARAM)0,
649 (LPARAM)0);
650
651 /* convert to wide char */
652 _itot(nCurrSel, szNegSumFmt,DECIMAL_RADIX);
653
654 /* Save negative sum format */
655 SetLocaleInfo(lcid, LOCALE_INEGNUMBER, szNegSumFmt);
656
657 return TRUE;
658 }
659
660 /* Set leading zero */
661 static BOOL
662 SetNumLeadZero(HWND hwndDlg,
663 LCID lcid)
664 {
665 TCHAR szLeadZero[MAX_SAMPLES_STR_SIZE];
666 INT nCurrSel;
667
668 /* Get setted leading zero format */
669 nCurrSel = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
670 CB_GETCURSEL,
671 (WPARAM)0,
672 (LPARAM)0);
673
674 /* convert to wide char */
675 _itot(nCurrSel, szLeadZero, DECIMAL_RADIX);
676
677 /* Save leading zero format */
678 SetLocaleInfo(lcid, LOCALE_ILZERO, szLeadZero);
679
680 return TRUE;
681 }
682
683 /* Set elements list separator */
684 static BOOL
685 SetNumListSep(HWND hwndDlg,
686 LCID lcid)
687 {
688 TCHAR szListSep[MAX_SAMPLES_STR_SIZE];
689
690 /* Get setted list separator */
691 SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
692 WM_GETTEXT,
693 (WPARAM)MAX_SAMPLES_STR_SIZE,
694 (LPARAM)szListSep);
695
696 /* Save list separator */
697 SetLocaleInfo(lcid, LOCALE_SLIST, szListSep);
698
699 return TRUE;
700 }
701
702 /* Set units system */
703 static BOOL
704 SetNumUnitsSys(HWND hwndDlg,
705 LCID lcid)
706 {
707 TCHAR szUnitsSys[MAX_SAMPLES_STR_SIZE];
708 INT nCurrSel;
709
710 /* Get setted units system */
711 nCurrSel = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
712 CB_GETCURSEL,
713 (WPARAM)0,
714 (LPARAM)0);
715
716 /* convert to wide char */
717 _itot(nCurrSel, szUnitsSys, DECIMAL_RADIX);
718
719 /* Save units system */
720 SetLocaleInfo(lcid, LOCALE_IMEASURE, szUnitsSys);
721
722 return TRUE;
723 }
724
725 /* Property page dialog callback */
726 INT_PTR CALLBACK
727 NumbersPageProc(HWND hwndDlg,
728 UINT uMsg,
729 WPARAM wParam,
730 LPARAM lParam)
731 {
732 PGLOBALDATA pGlobalData;
733
734 pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
735
736 switch (uMsg)
737 {
738 case WM_INITDIALOG:
739 pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
740 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
741
742 InitNumDecimalSepCB(hwndDlg, pGlobalData->lcid);
743 InitNumOfFracSymbCB(hwndDlg, pGlobalData->lcid);
744 InitNumFieldSepCB(hwndDlg, pGlobalData->lcid);
745 InitFieldDigNumCB(hwndDlg, pGlobalData->lcid);
746 InitNegSignCB(hwndDlg, pGlobalData->lcid);
747 InitNegNumFmtCB(hwndDlg, pGlobalData->lcid);
748 InitLeadingZeroesCB(hwndDlg, pGlobalData->lcid);
749 InitListSepCB(hwndDlg, pGlobalData->lcid);
750 InitUnitsSysCB(hwndDlg, pGlobalData->lcid);
751 UpdateNumSamples(hwndDlg, pGlobalData->lcid);
752 break;
753
754 case WM_COMMAND:
755 switch (LOWORD(wParam))
756 {
757 case IDC_NUMBERDSYMBOL:
758 case IDC_NUMBERSNDIGDEC:
759 case IDC_NUMBERSDIGITGRSYM:
760 case IDC_NUMBERSDGROUPING:
761 case IDC_NUMBERSNSIGNSYM:
762 case IDC_NUMBERSNNUMFORMAT:
763 case IDC_NUMBERSDISPLEADZER:
764 case IDC_NUMBERSLSEP:
765 case IDC_NUMBERSMEASSYS:
766 if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
767 {
768 /* Set "Apply" button enabled */
769 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
770 }
771 }
772 break;
773
774 case WM_NOTIFY:
775 /* If push apply button */
776 if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
777 {
778 if (!SetNumDecimalSep(hwndDlg, pGlobalData->lcid))
779 break;
780
781 if (!SetFracSymNum(hwndDlg, pGlobalData->lcid))
782 break;
783
784 if (!SetNumFieldSep(hwndDlg, pGlobalData->lcid))
785 break;
786
787 if (!SetFieldDigNum(hwndDlg, pGlobalData->lcid))
788 break;
789
790 if (!SetNumNegSign(hwndDlg, pGlobalData->lcid))
791 break;
792
793 if (!SetNegSumFmt(hwndDlg, pGlobalData->lcid))
794 break;
795
796 if (!SetNumLeadZero(hwndDlg, pGlobalData->lcid))
797 break;
798
799 if (!SetNumListSep(hwndDlg, pGlobalData->lcid))
800 break;
801
802 if (!SetNumUnitsSys(hwndDlg, pGlobalData->lcid))
803 break;
804
805 UpdateNumSamples(hwndDlg, pGlobalData->lcid);
806 }
807 break;
808 }
809 return FALSE;
810 }
811
812 /* EOF */