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