ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

numbers.c
Go to the documentation of this file.
00001 /*
00002  *  ReactOS
00003  *  Copyright (C) 2004 ReactOS Team
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License along
00016  *  with this program; if not, write to the Free Software Foundation, Inc.,
00017  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00018  */
00019 /* $Id: numbers.c 54535 2011-11-29 14:55:58Z dgorbachev $
00020  *
00021  * PROJECT:         ReactOS International Control Panel
00022  * FILE:            dll/cpl/intl/numbers.c
00023  * PURPOSE:         Numbers property page
00024  * PROGRAMMER:      Eric Kohl
00025  */
00026 
00027 #include "intl.h"
00028 
00029 #define SAMPLE_NUMBER               _T("123456789")
00030 #define SAMPLE_NEG_NUMBER           _T("-123456789")
00031 #define MAX_NUM_SEP_SAMPLES         2
00032 #define MAX_FRAC_NUM_SAMPLES        10
00033 #define MAX_FIELD_SEP_SAMPLES       1
00034 #define MAX_FIELD_DIG_SAMPLES       3
00035 #define MAX_NEG_SIGN_SAMPLES        1
00036 #define MAX_NEG_NUMBERS_SAMPLES     5
00037 #define MAX_LEAD_ZEROES_SAMPLES     2
00038 #define MAX_LIST_SEP_SAMPLES        1
00039 #define MAX_UNITS_SYS_SAMPLES       2
00040 
00041 static LPTSTR lpNumSepSamples[MAX_NUM_SEP_SAMPLES] =
00042     {_T(","), _T(".")};
00043 static LPTSTR lpFieldSepSamples[MAX_FIELD_SEP_SAMPLES] =
00044     {_T(" ")};
00045 static LPTSTR lpFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES] =
00046     {_T("0;0"), _T("3;0"), _T("3;2;0")};
00047 static LPTSTR lpNegSignSamples[MAX_NEG_SIGN_SAMPLES] =
00048     {_T("-")};
00049 static LPTSTR lpNegNumFmtSamples[MAX_NEG_NUMBERS_SAMPLES] =
00050     {_T("(1,1)"), _T("-1,1"), _T("- 1,1"), _T("1,1-"), _T("1,1 -")};
00051 static LPTSTR lpLeadNumFmtSamples[MAX_LEAD_ZEROES_SAMPLES] =
00052     {_T(",7"), _T("0,7")};
00053 static LPTSTR lpListSepSamples[MAX_LIST_SEP_SAMPLES] =
00054     {_T(";")};
00055 
00056 
00057 /* Init num decimal separator control box */
00058 static VOID
00059 InitNumDecimalSepCB(HWND hwndDlg, LCID lcid)
00060 {
00061     TCHAR szNumSep[MAX_SAMPLES_STR_SIZE];
00062     INT nCBIndex;
00063     INT nRetCode;
00064 
00065     /* Limit text length */
00066     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00067                 CB_LIMITTEXT,
00068                 MAX_NUMBERDSYMBOL,
00069                 0);
00070 
00071     /* Get current decimal separator */
00072     GetLocaleInfo(lcid,
00073                   LOCALE_SDECIMAL,
00074                   szNumSep,
00075                   MAX_SAMPLES_STR_SIZE);
00076 
00077     /* Clear all box content */
00078     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00079                 CB_RESETCONTENT,
00080                 (WPARAM)0,
00081                 (LPARAM)0);
00082 
00083     /* Create standard list of decimal separators */
00084     for (nCBIndex = 0; nCBIndex < MAX_NUM_SEP_SAMPLES; nCBIndex++)
00085     {
00086         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00087                     CB_ADDSTRING,
00088                     0,
00089                     (LPARAM)lpNumSepSamples[nCBIndex]);
00090     }
00091 
00092     /* Set current item to value from registry */
00093     nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00094                            CB_SELECTSTRING,
00095                            -1,
00096                            (LPARAM)(LPCSTR)szNumSep);
00097 
00098     /* If it is not successful, add new values to list and select them */
00099     if (nRetCode == CB_ERR)
00100     {
00101         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00102                     CB_ADDSTRING,
00103                     MAX_NUM_SEP_SAMPLES,
00104                     (LPARAM)szNumSep);
00105         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00106                     CB_SELECTSTRING,
00107                     -1,
00108                     (LPARAM)szNumSep);
00109     }
00110 }
00111 
00112 /* Init number of fractional symbols control box */
00113 static VOID
00114 InitNumOfFracSymbCB(HWND hwndDlg, LCID lcid)
00115 {
00116     TCHAR szFracNum[MAX_SAMPLES_STR_SIZE];
00117     TCHAR szFracCount[MAX_SAMPLES_STR_SIZE];
00118     INT nCBIndex;
00119 
00120     /* Get current number of fractional symbols */
00121     GetLocaleInfo(lcid,
00122                   LOCALE_IDIGITS,
00123                   szFracNum,
00124                   MAX_SAMPLES_STR_SIZE);
00125 
00126     /* Clear all box content */
00127     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
00128                 CB_RESETCONTENT,
00129                 (WPARAM)0,
00130                 (LPARAM)0);
00131 
00132     /* Create standard list of fractional symbols */
00133     for (nCBIndex = 0; nCBIndex < MAX_FRAC_NUM_SAMPLES; nCBIndex++)
00134     {
00135         /* Convert to wide char */
00136         _itot(nCBIndex, szFracCount, DECIMAL_RADIX);
00137 
00138         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
00139                     CB_ADDSTRING,
00140                     0,
00141                     (LPARAM)szFracCount);
00142     }
00143 
00144     /* Set current item to value from registry */
00145     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
00146                 CB_SETCURSEL,
00147                 (WPARAM)_ttoi(szFracNum),
00148                 (LPARAM)0);
00149 }
00150 
00151 /* Init field separator control box */
00152 static VOID
00153 InitNumFieldSepCB(HWND hwndDlg, LCID lcid)
00154 {
00155     TCHAR szFieldSep[MAX_SAMPLES_STR_SIZE];
00156     INT nCBIndex;
00157     INT nRetCode;
00158 
00159     /* Limit text length */
00160     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00161                 CB_LIMITTEXT,
00162                 MAX_NUMBERSDIGITGRSYM,
00163                 0);
00164 
00165     /* Get current field separator */
00166     GetLocaleInfo(lcid,
00167                   LOCALE_STHOUSAND,
00168                   szFieldSep,
00169                   MAX_SAMPLES_STR_SIZE);
00170 
00171     /* Clear all box content */
00172     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00173                 CB_RESETCONTENT,
00174                 (WPARAM)0,
00175                 (LPARAM)0);
00176 
00177     /* Create standard list of field separators */
00178     for (nCBIndex = 0; nCBIndex < MAX_FIELD_SEP_SAMPLES; nCBIndex++)
00179     {
00180         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00181                     CB_ADDSTRING,
00182                     0,
00183                     (LPARAM)lpFieldSepSamples[nCBIndex]);
00184     }
00185 
00186     /* Set current item to value from registry */
00187     nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00188                            CB_SELECTSTRING,
00189                            -1,
00190                            (LPARAM)szFieldSep);
00191 
00192     /* If it is not success, add new values to list and select them */
00193     if (nRetCode == CB_ERR)
00194     {
00195         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00196                     CB_ADDSTRING,
00197                     0,
00198                     (LPARAM)szFieldSep);
00199         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00200                     CB_SELECTSTRING,
00201                     -1,
00202                     (LPARAM)szFieldSep);
00203     }
00204 }
00205 
00206 /* Init number of digits in field control box */
00207 static VOID
00208 InitFieldDigNumCB(HWND hwndDlg, LCID lcid)
00209 {
00210     TCHAR szFieldDigNum[MAX_SAMPLES_STR_SIZE];
00211     LPTSTR pszFieldDigNumSmpl;
00212     INT nCBIndex;
00213     INT nRetCode;
00214 
00215     /* Get current field digits num */
00216     GetLocaleInfo(lcid,
00217                   LOCALE_SGROUPING,
00218                   szFieldDigNum,
00219                   MAX_SAMPLES_STR_SIZE);
00220 
00221     /* Clear all box content */
00222     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
00223                 CB_RESETCONTENT,
00224                 (WPARAM)0,
00225                 (LPARAM)0);
00226 
00227     /* Create standard list of field digits num */
00228     for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
00229     {
00230 
00231         pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
00232         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
00233                     CB_ADDSTRING,
00234                     0,
00235                     (LPARAM)pszFieldDigNumSmpl);
00236         free(pszFieldDigNumSmpl);
00237     }
00238 
00239     pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, szFieldDigNum);
00240     /* Set current item to value from registry */
00241     nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
00242                            CB_SELECTSTRING,
00243                            -1,
00244                            (LPARAM)pszFieldDigNumSmpl);
00245 
00246     /* If it is not successful, add new values to list and select them */
00247     if (nRetCode == CB_ERR)
00248     {
00249         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
00250                     CB_ADDSTRING,
00251                     0,
00252                     (LPARAM)pszFieldDigNumSmpl);
00253         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
00254                     CB_SELECTSTRING,
00255                     -1,
00256                     (LPARAM)pszFieldDigNumSmpl);
00257     }
00258 
00259     free(pszFieldDigNumSmpl);
00260 }
00261 
00262 /* Init negative sign control box */
00263 static VOID
00264 InitNegSignCB(HWND hwndDlg, LCID lcid)
00265 {
00266     TCHAR szNegSign[MAX_SAMPLES_STR_SIZE];
00267     INT nCBIndex;
00268     INT nRetCode;
00269 
00270     /* Limit text length */
00271     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00272                 CB_LIMITTEXT,
00273                 MAX_NUMBERSNSIGNSYM,
00274                 0);
00275 
00276     /* Get current negative sign */
00277     GetLocaleInfo(lcid,
00278                   LOCALE_SNEGATIVESIGN,
00279                   szNegSign,
00280                   MAX_SAMPLES_STR_SIZE);
00281 
00282     /* Clear all box content */
00283     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00284                 CB_RESETCONTENT,
00285                 (WPARAM)0,
00286                 (LPARAM)0);
00287 
00288     /* Create standard list of signs */
00289     for (nCBIndex = 0; nCBIndex < MAX_NEG_SIGN_SAMPLES; nCBIndex++)
00290     {
00291         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00292                     CB_ADDSTRING,
00293                     0,
00294                     (LPARAM)lpNegSignSamples[nCBIndex]);
00295     }
00296 
00297     /* Set current item to value from registry */
00298     nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00299                            CB_SELECTSTRING,
00300                            -1,
00301                            (LPARAM)szNegSign);
00302 
00303     /* If  it is not successful, add new values to list and select them */
00304     if (nRetCode == CB_ERR)
00305     {
00306         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00307                     CB_ADDSTRING,
00308                     0,
00309                     (LPARAM)szNegSign);
00310         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00311                     CB_SELECTSTRING,
00312                     -1,
00313                     (LPARAM)szNegSign);
00314     }
00315 }
00316 
00317 /* Init negative numbers format control box */
00318 static VOID
00319 InitNegNumFmtCB(HWND hwndDlg, LCID lcid)
00320 {
00321     TCHAR szNegNumFmt[MAX_SAMPLES_STR_SIZE];
00322     TCHAR szNumSep[MAX_SAMPLES_STR_SIZE];
00323     TCHAR szNegSign[MAX_SAMPLES_STR_SIZE];
00324     TCHAR szNewSample[MAX_SAMPLES_STR_SIZE];
00325     LPTSTR pszResultStr;
00326     INT nCBIndex;
00327 
00328     /* Get current negative numbers format */
00329     GetLocaleInfo(lcid,
00330                   LOCALE_INEGNUMBER,
00331                   szNegNumFmt,
00332                   MAX_SAMPLES_STR_SIZE);
00333 
00334     /* Clear all box content */
00335     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
00336                 CB_RESETCONTENT,
00337                 (WPARAM)0,
00338                 (LPARAM)0);
00339 
00340     /* Get current decimal separator */
00341     GetLocaleInfo(lcid,
00342                   LOCALE_SDECIMAL,
00343                   szNumSep,
00344                   MAX_SAMPLES_STR_SIZE);
00345 
00346     /* Get current negative sign */
00347     GetLocaleInfo(lcid,
00348                   LOCALE_SNEGATIVESIGN,
00349                   szNegSign,
00350                   MAX_SAMPLES_STR_SIZE);
00351 
00352     /* Create standard list of negative numbers formats */
00353     for (nCBIndex = 0; nCBIndex < MAX_NEG_NUMBERS_SAMPLES; nCBIndex++)
00354     {
00355         /* Replace standard separator to setted */
00356         pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
00357                                      szNumSep,
00358                                      _T(","));
00359         _tcscpy(szNewSample, pszResultStr);
00360         free(pszResultStr);
00361         /* Replace standard negative sign to setted */
00362         pszResultStr = ReplaceSubStr(szNewSample,
00363                                      szNegSign,
00364                                      _T("-"));
00365         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
00366                     CB_ADDSTRING,
00367                     0,
00368                     (LPARAM)pszResultStr);
00369         free(pszResultStr);
00370     }
00371 
00372     /* Set current item to value from registry */
00373     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
00374                 CB_SETCURSEL,
00375                 (WPARAM)_ttoi(szNegNumFmt),
00376                 (LPARAM)0);
00377 }
00378 
00379 /* Init leading zeroes control box */
00380 static VOID
00381 InitLeadingZeroesCB(HWND hwndDlg, LCID lcid)
00382 {
00383     TCHAR szLeadNumFmt[MAX_SAMPLES_STR_SIZE];
00384     TCHAR szNumSep[MAX_SAMPLES_STR_SIZE];
00385     LPTSTR pszResultStr;
00386     INT nCBIndex;
00387 
00388     /* Get current leading zeroes format */
00389     GetLocaleInfo(lcid,
00390                   LOCALE_ILZERO,
00391                   szLeadNumFmt,
00392                   MAX_SAMPLES_STR_SIZE);
00393 
00394     /* Clear all box content */
00395     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
00396                 CB_RESETCONTENT,
00397                 (WPARAM)0,
00398                 (LPARAM)0);
00399 
00400     /* Get current decimal separator */
00401     GetLocaleInfo(lcid,
00402                   LOCALE_SDECIMAL,
00403                   szNumSep,
00404                   MAX_SAMPLES_STR_SIZE);
00405 
00406     /* Create list of standard leading zeroes formats */
00407     for (nCBIndex = 0; nCBIndex < MAX_LEAD_ZEROES_SAMPLES; nCBIndex++)
00408     {
00409         pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
00410                                      szNumSep,
00411                                      _T(","));
00412         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
00413                     CB_ADDSTRING,
00414                     0,
00415                     (LPARAM)pszResultStr);
00416         free(pszResultStr);
00417     }
00418 
00419     /* Set current item to value from registry */
00420     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
00421                 CB_SETCURSEL,
00422                 (WPARAM)_ttoi(szLeadNumFmt),
00423                 (LPARAM)0);
00424 }
00425 
00426 static VOID
00427 InitListSepCB(HWND hwndDlg,
00428               LCID lcid)
00429 {
00430     TCHAR szListSep[MAX_SAMPLES_STR_SIZE];
00431     INT nCBIndex;
00432     INT nRetCode;
00433 
00434     /* Limit text length */
00435     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00436                 CB_LIMITTEXT,
00437                 MAX_NUMBERSLSEP,
00438                 0);
00439 
00440     /* Get current list separator */
00441     GetLocaleInfo(lcid,
00442                   LOCALE_SLIST,
00443                   szListSep,
00444                   MAX_SAMPLES_STR_SIZE);
00445 
00446     /* Clear all box content */
00447     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00448                 CB_RESETCONTENT,
00449                 (WPARAM)0,
00450                 (LPARAM)0);
00451 
00452     /* Create standard list of signs */
00453     for (nCBIndex = 0; nCBIndex < MAX_LIST_SEP_SAMPLES; nCBIndex++)
00454     {
00455         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00456                     CB_ADDSTRING,
00457                     0,
00458                     (LPARAM)lpListSepSamples[nCBIndex]);
00459     }
00460 
00461     /* Set current item to value from registry */
00462     nRetCode = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00463                            CB_SELECTSTRING,
00464                            -1,
00465                            (LPARAM)szListSep);
00466 
00467     /* If it is not successful, add new values to list and select them */
00468     if (nRetCode == CB_ERR)
00469     {
00470         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00471                     CB_ADDSTRING,
00472                     0,
00473                     (LPARAM)szListSep);
00474         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00475                     CB_SELECTSTRING,
00476                     -1,
00477                     (LPARAM)szListSep);
00478     }
00479 }
00480 
00481 /* Init system of units control box */
00482 static VOID
00483 InitUnitsSysCB(HWND hwndDlg,
00484                LCID lcid)
00485 {
00486     TCHAR szUnitsSys[MAX_SAMPLES_STR_SIZE];
00487     TCHAR szUnitName[128];
00488     INT nCBIndex;
00489 
00490     /* Get current system of units */
00491     GetLocaleInfo(lcid,
00492                   LOCALE_IMEASURE,
00493                   szUnitsSys,
00494                   MAX_SAMPLES_STR_SIZE);
00495 
00496     /* Clear all box content */
00497     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
00498                 CB_RESETCONTENT,
00499                 (WPARAM)0,
00500                 (LPARAM)0);
00501 
00502     /* Create list of standard system of units */
00503     for (nCBIndex = 0; nCBIndex < MAX_UNITS_SYS_SAMPLES; nCBIndex++)
00504     {
00505         LoadString(hApplet, IDS_METRIC + nCBIndex, szUnitName, 128);
00506 
00507         SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
00508                     CB_ADDSTRING,
00509                     0,
00510                     (LPARAM)szUnitName);
00511     }
00512 
00513     /* Set current item to value from registry */
00514     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
00515                 CB_SETCURSEL,
00516                 (WPARAM)_ttoi(szUnitsSys),
00517                 (LPARAM)0);
00518 }
00519 
00520 /* Update all numbers locale samples */
00521 static VOID
00522 UpdateNumSamples(HWND hwndDlg,
00523                  LCID lcid)
00524 {
00525     TCHAR OutBuffer[MAX_FMT_SIZE];
00526 
00527     /* Get positive number format sample */
00528     GetNumberFormat(lcid,
00529                     0,
00530                     SAMPLE_NUMBER,
00531                     NULL,
00532                     OutBuffer,
00533                     MAX_FMT_SIZE);
00534 
00535     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSPOSSAMPLE),
00536                 WM_SETTEXT,
00537                 0,
00538                 (LPARAM)OutBuffer);
00539 
00540     /* Get positive number format sample */
00541     GetNumberFormat(lcid,
00542                     0,
00543                     SAMPLE_NEG_NUMBER,
00544                     NULL,
00545                     OutBuffer,
00546                     MAX_FMT_SIZE);
00547 
00548     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNEGSAMPLE),
00549                 WM_SETTEXT,
00550                 0,
00551                 (LPARAM)OutBuffer);
00552 }
00553 
00554 /* Set num decimal separator */
00555 static BOOL
00556 SetNumDecimalSep(HWND hwndDlg,
00557                  LCID lcid)
00558 {
00559     TCHAR szDecimalSep[MAX_SAMPLES_STR_SIZE];
00560 
00561     /* Get setted decimal separator */
00562     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERDSYMBOL),
00563                 WM_GETTEXT,
00564                 (WPARAM)MAX_SAMPLES_STR_SIZE,
00565                 (LPARAM)szDecimalSep);
00566 
00567     /* Save decimal separator */
00568     SetLocaleInfo(lcid, LOCALE_SDECIMAL, szDecimalSep);
00569 
00570     return TRUE;
00571 }
00572 
00573 /* Set number of fractional symbols */
00574 static BOOL
00575 SetFracSymNum(HWND hwndDlg,
00576                  LCID lcid)
00577 {
00578     TCHAR szFracSymNum[MAX_SAMPLES_STR_SIZE];
00579     INT nCurrSel;
00580 
00581     /* Get setted number of fractional symbols */
00582     nCurrSel = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNDIGDEC),
00583                            CB_GETCURSEL,
00584                            (WPARAM)0,
00585                            (LPARAM)0);
00586 
00587     /* Convert to wide char */
00588     _itot(nCurrSel, szFracSymNum, DECIMAL_RADIX);
00589 
00590     /* Save number of fractional symbols */
00591     SetLocaleInfo(lcid, LOCALE_IDIGITS, szFracSymNum);
00592 
00593     return TRUE;
00594 }
00595 
00596 /* Set field separator */
00597 static BOOL
00598 SetNumFieldSep(HWND hwndDlg,
00599                LCID lcid)
00600 {
00601     TCHAR szFieldSep[MAX_SAMPLES_STR_SIZE];
00602 
00603     /* Get setted field separator */
00604     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDIGITGRSYM),
00605                 WM_GETTEXT,
00606                 (WPARAM)MAX_SAMPLES_STR_SIZE,
00607                 (LPARAM)szFieldSep);
00608 
00609     /* Save field separator */
00610     SetLocaleInfo(lcid, LOCALE_STHOUSAND, szFieldSep);
00611 
00612     return TRUE;
00613 }
00614 
00615 /* Set number of digits in field  */
00616 static BOOL
00617 SetFieldDigNum(HWND hwndDlg,
00618                LCID lcid)
00619 {
00620     TCHAR szFieldDigNum[MAX_SAMPLES_STR_SIZE];
00621 
00622     /* Get setted number of digidts in field */
00623     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSDGROUPING),
00624                 WM_GETTEXT,
00625                 (WPARAM)MAX_SAMPLES_STR_SIZE,
00626                 (LPARAM)szFieldDigNum);
00627 
00628     /* Save number of digits in field */
00629     SetLocaleInfo(lcid, LOCALE_SGROUPING, szFieldDigNum);
00630 
00631     return TRUE;
00632 }
00633 
00634 /* Set negative sign */
00635 static BOOL
00636 SetNumNegSign(HWND hwndDlg,
00637               LCID lcid)
00638 {
00639     TCHAR szNegSign[MAX_SAMPLES_STR_SIZE];
00640 
00641     /* Get setted negative sign */
00642     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNSIGNSYM),
00643                 WM_GETTEXT,
00644                 (WPARAM)MAX_SAMPLES_STR_SIZE,
00645                 (LPARAM)szNegSign);
00646 
00647     /* Save negative sign */
00648     SetLocaleInfo(lcid, LOCALE_SNEGATIVESIGN, szNegSign);
00649 
00650     return TRUE;
00651 }
00652 
00653 /* Set negative sum format */
00654 static BOOL
00655 SetNegSumFmt(HWND hwndDlg,
00656              LCID lcid)
00657 {
00658     TCHAR szNegSumFmt[MAX_SAMPLES_STR_SIZE];
00659     INT nCurrSel;
00660 
00661     /* Get setted negative sum format */
00662     nCurrSel = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSNNUMFORMAT),
00663                            CB_GETCURSEL,
00664                            (WPARAM)0,
00665                            (LPARAM)0);
00666 
00667     /* convert to wide char */
00668     _itot(nCurrSel, szNegSumFmt,DECIMAL_RADIX);
00669 
00670     /* Save negative sum format */
00671     SetLocaleInfo(lcid, LOCALE_INEGNUMBER, szNegSumFmt);
00672 
00673     return TRUE;
00674 }
00675 
00676 /* Set leading zero */
00677 static BOOL
00678 SetNumLeadZero(HWND hwndDlg,
00679                  LCID lcid)
00680 {
00681     TCHAR szLeadZero[MAX_SAMPLES_STR_SIZE];
00682     INT nCurrSel;
00683 
00684     /* Get setted leading zero format */
00685     nCurrSel = SendMessageW(GetDlgItem(hwndDlg, IDC_NUMBERSDISPLEADZER),
00686                             CB_GETCURSEL,
00687                             (WPARAM)0,
00688                             (LPARAM)0);
00689 
00690     /* Convert to wide char */
00691     _itot(nCurrSel, szLeadZero, DECIMAL_RADIX);
00692 
00693     /* Save leading zero format */
00694     SetLocaleInfo(lcid, LOCALE_ILZERO, szLeadZero);
00695 
00696     return TRUE;
00697 }
00698 
00699 /* Set elements list separator */
00700 static BOOL
00701 SetNumListSep(HWND hwndDlg,
00702                  LCID lcid)
00703 {
00704     TCHAR szListSep[MAX_SAMPLES_STR_SIZE];
00705 
00706     /* Get setted list separator */
00707     SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSLSEP),
00708                 WM_GETTEXT,
00709                 (WPARAM)MAX_SAMPLES_STR_SIZE,
00710                 (LPARAM)szListSep);
00711 
00712     /* Save list separator */
00713     SetLocaleInfo(lcid, LOCALE_SLIST, szListSep);
00714 
00715     return TRUE;
00716 }
00717 
00718 /* Set units system */
00719 static BOOL
00720 SetNumUnitsSys(HWND hwndDlg,
00721                LCID lcid)
00722 {
00723     TCHAR szUnitsSys[MAX_SAMPLES_STR_SIZE];
00724     INT nCurrSel;
00725 
00726     /* Get setted units system */
00727     nCurrSel = SendMessage(GetDlgItem(hwndDlg, IDC_NUMBERSMEASSYS),
00728                            CB_GETCURSEL,
00729                            (WPARAM)0,
00730                            (LPARAM)0);
00731 
00732     /* convert to wide char */
00733     _itot(nCurrSel, szUnitsSys, DECIMAL_RADIX);
00734 
00735     /* Save units system */
00736     SetLocaleInfo(lcid, LOCALE_IMEASURE, szUnitsSys);
00737 
00738     return TRUE;
00739 }
00740 
00741 /* Property page dialog callback */
00742 INT_PTR CALLBACK
00743 NumbersPageProc(HWND hwndDlg,
00744                 UINT uMsg,
00745                 WPARAM wParam,
00746                 LPARAM lParam)
00747 {
00748     PGLOBALDATA pGlobalData;
00749 
00750     pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
00751 
00752     switch (uMsg)
00753     {
00754         case WM_INITDIALOG:
00755             pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
00756             SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
00757 
00758             InitNumDecimalSepCB(hwndDlg, pGlobalData->lcid);
00759             InitNumOfFracSymbCB(hwndDlg, pGlobalData->lcid);
00760             InitNumFieldSepCB(hwndDlg, pGlobalData->lcid);
00761             InitFieldDigNumCB(hwndDlg, pGlobalData->lcid);
00762             InitNegSignCB(hwndDlg, pGlobalData->lcid);
00763             InitNegNumFmtCB(hwndDlg, pGlobalData->lcid);
00764             InitLeadingZeroesCB(hwndDlg, pGlobalData->lcid);
00765             InitListSepCB(hwndDlg, pGlobalData->lcid);
00766             InitUnitsSysCB(hwndDlg, pGlobalData->lcid);
00767             UpdateNumSamples(hwndDlg, pGlobalData->lcid);
00768             break;
00769 
00770         case WM_COMMAND:
00771             switch (LOWORD(wParam))
00772             {
00773                 case IDC_NUMBERDSYMBOL:
00774                 case IDC_NUMBERSNDIGDEC:
00775                 case IDC_NUMBERSDIGITGRSYM:
00776                 case IDC_NUMBERSDGROUPING:
00777                 case IDC_NUMBERSNSIGNSYM:
00778                 case IDC_NUMBERSNNUMFORMAT:
00779                 case IDC_NUMBERSDISPLEADZER:
00780                 case IDC_NUMBERSLSEP:
00781                 case IDC_NUMBERSMEASSYS:
00782                     if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
00783                     {
00784                         /* Set "Apply" button enabled */
00785                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
00786                     }
00787             }
00788             break;
00789 
00790         case WM_NOTIFY:
00791             /* If push apply button */
00792             if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
00793             {
00794                 if (!SetNumDecimalSep(hwndDlg, pGlobalData->lcid))
00795                     break;
00796 
00797                 if (!SetFracSymNum(hwndDlg, pGlobalData->lcid))
00798                     break;
00799 
00800                 if (!SetNumFieldSep(hwndDlg, pGlobalData->lcid))
00801                     break;
00802 
00803                 if (!SetFieldDigNum(hwndDlg, pGlobalData->lcid))
00804                     break;
00805 
00806                 if (!SetNumNegSign(hwndDlg, pGlobalData->lcid))
00807                     break;
00808 
00809                 if (!SetNegSumFmt(hwndDlg, pGlobalData->lcid))
00810                     break;
00811 
00812                 if (!SetNumLeadZero(hwndDlg, pGlobalData->lcid))
00813                     break;
00814 
00815                 if (!SetNumListSep(hwndDlg, pGlobalData->lcid))
00816                     break;
00817 
00818                 if (!SetNumUnitsSys(hwndDlg, pGlobalData->lcid))
00819                     break;
00820 
00821                 UpdateNumSamples(hwndDlg, pGlobalData->lcid);
00822             }
00823             break;
00824     }
00825     return FALSE;
00826 }
00827 
00828 /* EOF */

Generated on Sat May 26 2012 04:18:26 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.