From b099514289eb7fc15e71d25fa7a51059ee2e78d7 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 4 Oct 2015 21:57:03 +0000 Subject: [PATCH] [INTL] - Improve the internal locale storage. Replace the array of strings by a customized struct. - Implement the locale customization properly. The customization property sheet modifies the internal locale storage rather than the registry. Now, cancelling changes works properly. CORE-10074 svn path=/trunk/; revision=69449 --- reactos/dll/cpl/intl/currency.c | 303 ++------ reactos/dll/cpl/intl/date.c | 175 ++--- reactos/dll/cpl/intl/generalp.c | 1160 +++++++++++++++++++++++++------ reactos/dll/cpl/intl/intl.h | 96 ++- reactos/dll/cpl/intl/misc.c | 57 -- reactos/dll/cpl/intl/numbers.c | 255 ++----- reactos/dll/cpl/intl/sort.c | 47 +- reactos/dll/cpl/intl/time.c | 227 +++--- 8 files changed, 1393 insertions(+), 927 deletions(-) diff --git a/reactos/dll/cpl/intl/currency.c b/reactos/dll/cpl/intl/currency.c index b2e83107800..860356b3e7c 100644 --- a/reactos/dll/cpl/intl/currency.c +++ b/reactos/dll/cpl/intl/currency.c @@ -27,7 +27,6 @@ #define POSITIVE_EXAMPLE L"123456789.00" #define NEGATIVE_EXAMPLE L"-123456789.00" -#define MAX_FIELD_DIG_SAMPLES 3 static VOID @@ -36,14 +35,14 @@ UpdateExamples(HWND hwndDlg, PGLOBALDATA pGlobalData) WCHAR szBuffer[MAX_FMT_SIZE]; /* Positive example */ - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, POSITIVE_EXAMPLE, NULL, szBuffer, MAX_FMT_SIZE); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYPOSSAMPLE, WM_SETTEXT, 0, (LPARAM)szBuffer); /* Negative example */ - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, NEGATIVE_EXAMPLE, NULL, szBuffer, MAX_FMT_SIZE); @@ -54,23 +53,17 @@ UpdateExamples(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitCurrencySymbols(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szBuffer[MAX_FMT_SIZE]; - /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYSYMBOL, CB_LIMITTEXT, - MAX_CURRENCYSYMBOL, + MAX_CURRSYMBOL - 1, 0); /* Set currency symbols */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SCURRENCY, - szBuffer, MAX_FMT_SIZE); - SendDlgItemMessageW(hwndDlg, IDC_CURRENCYSYMBOL, CB_ADDSTRING, 0, - (LPARAM)szBuffer); + (LPARAM)pGlobalData->szCurrSymbol); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYSYMBOL, CB_SETCURSEL, @@ -82,65 +75,23 @@ InitCurrencySymbols(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitCurrencyPositiveFormats(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szDecimalSep[MAX_FMT_SIZE]; - WCHAR szThousandSep[MAX_FMT_SIZE]; - WCHAR szCurrencySymbol[MAX_FMT_SIZE]; WCHAR szBuffer[MAX_FMT_SIZE]; CURRENCYFMTW cyFmt; - INT nPositiveOrder = 0; - INT ret; INT i; - - /* Get positive format */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_ICURRENCY, - szBuffer, MAX_FMT_SIZE); - if (ret != 0) - { - nPositiveOrder = _wtoi(szBuffer); - } - - /* Get number of fractional digits */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_ICURRDIGITS, - szBuffer, MAX_FMT_SIZE); - if (ret != 0) - { - cyFmt.NumDigits = _wtoi(szBuffer); - } - else - { - cyFmt.NumDigits = 0; - } - - /* Get decimal separator */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONDECIMALSEP, - szDecimalSep, MAX_FMT_SIZE); - - /* Get group separator */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONTHOUSANDSEP, - szThousandSep, MAX_FMT_SIZE); - - /* Get currency symbol */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SCURRENCY, - szCurrencySymbol, MAX_FMT_SIZE); - /* positive currency values */ + cyFmt.NumDigits = pGlobalData->nCurrDigits; cyFmt.LeadingZero = 0; cyFmt.Grouping = 3; - cyFmt.lpDecimalSep = szDecimalSep; - cyFmt.lpThousandSep = szThousandSep; - cyFmt.lpCurrencySymbol = szCurrencySymbol; + cyFmt.lpDecimalSep = pGlobalData->szCurrDecimalSep; + cyFmt.lpThousandSep = pGlobalData->szCurrThousandSep; + cyFmt.lpCurrencySymbol = pGlobalData->szCurrSymbol; cyFmt.NegativeOrder = 0; for (i = 0; i < 4; i++) { cyFmt.PositiveOrder = i; - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, L"1.1", &cyFmt, szBuffer, MAX_FMT_SIZE); @@ -152,7 +103,7 @@ InitCurrencyPositiveFormats(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_CURRENCYPOSVALUE, CB_SETCURSEL, - nPositiveOrder, + pGlobalData->nCurrPosFormat, 0); } @@ -160,64 +111,23 @@ InitCurrencyPositiveFormats(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitCurrencyNegativeFormats(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szDecimalSep[MAX_FMT_SIZE]; - WCHAR szThousandSep[MAX_FMT_SIZE]; - WCHAR szCurrencySymbol[MAX_FMT_SIZE]; WCHAR szBuffer[MAX_FMT_SIZE]; CURRENCYFMTW cyFmt; - INT nNegativeOrder = 0; - INT ret; int i; - /* Get negative format */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_INEGCURR, - szBuffer, MAX_FMT_SIZE); - if (ret != 0) - { - nNegativeOrder = _wtoi(szBuffer); - } - - /* Get number of fractional digits */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_ICURRDIGITS, - szBuffer, MAX_FMT_SIZE); - if (ret != 0) - { - cyFmt.NumDigits = _wtoi(szBuffer); - } - else - { - cyFmt.NumDigits = 0; - } - - /* Get decimal separator */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONDECIMALSEP, - szDecimalSep, MAX_FMT_SIZE); - - /* Get group separator */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONTHOUSANDSEP, - szThousandSep, MAX_FMT_SIZE); - - /* Get currency symbol */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SCURRENCY, - szCurrencySymbol, MAX_FMT_SIZE); - /* negative currency values */ + cyFmt.NumDigits = pGlobalData->nCurrDigits; cyFmt.LeadingZero = 0; cyFmt.Grouping = 3; - cyFmt.lpDecimalSep = szDecimalSep; - cyFmt.lpThousandSep = szThousandSep; - cyFmt.lpCurrencySymbol = szCurrencySymbol; + cyFmt.lpDecimalSep = pGlobalData->szCurrDecimalSep; + cyFmt.lpThousandSep = pGlobalData->szCurrThousandSep; + cyFmt.lpCurrencySymbol = pGlobalData->szCurrSymbol; cyFmt.PositiveOrder = 0; for (i = 0; i < 16; i++) { cyFmt.NegativeOrder = i; - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, L"-1.1", &cyFmt, szBuffer, MAX_FMT_SIZE); @@ -229,7 +139,7 @@ InitCurrencyNegativeFormats(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_CURRENCYNEGVALUE, CB_SETCURSEL, - nNegativeOrder, + pGlobalData->nCurrNegFormat, 0); } @@ -237,24 +147,17 @@ InitCurrencyNegativeFormats(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitCurrencyDecimalSeparators(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szBuffer[MAX_FMT_SIZE]; - /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECSEP, CB_LIMITTEXT, - MAX_CURRENCYDECSEP, + MAX_CURRDECIMALSEP - 1, 0); - /* Get decimal separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONDECIMALSEP, - szBuffer, MAX_FMT_SIZE); - /* Decimal separator */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECSEP, CB_ADDSTRING, 0, - (LPARAM)szBuffer); + (LPARAM)pGlobalData->szCurrDecimalSep); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECSEP, CB_SETCURSEL, @@ -268,7 +171,6 @@ static VOID InitCurrencyNumFracDigits(HWND hwndDlg, PGLOBALDATA pGlobalData) { WCHAR szBuffer[MAX_FMT_SIZE]; - int ret; int i; /* Create standard list of fractional symbols */ @@ -282,24 +184,10 @@ InitCurrencyNumFracDigits(HWND hwndDlg, PGLOBALDATA pGlobalData) (LPARAM)szBuffer); } - /* Get number of fractional digits */ - ret = GetLocaleInfoW(pGlobalData->lcid, - LOCALE_ICURRDIGITS, - szBuffer, MAX_FMT_SIZE); - if (ret != 0) - { - SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECNUM, - CB_SETCURSEL, - _wtoi(szBuffer), - 0); - } - else - { - SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECNUM, - CB_SETCURSEL, - 0, - 0); - } + SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECNUM, + CB_SETCURSEL, + pGlobalData->nCurrDigits, + 0); } @@ -307,24 +195,17 @@ InitCurrencyNumFracDigits(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitCurrencyGroupSeparators(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szBuffer[MAX_FMT_SIZE]; - /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPSEP, CB_LIMITTEXT, - MAX_CURRENCYGRPSEP, + MAX_CURRTHOUSANDSEP - 1, 0); - /* Get group separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONTHOUSANDSEP, - szBuffer, MAX_FMT_SIZE); - /* Digit group separator */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPSEP, CB_ADDSTRING, 0, - (LPARAM)szBuffer); + (LPARAM)pGlobalData->szCurrThousandSep); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPSEP, CB_SETCURSEL, @@ -336,32 +217,19 @@ InitCurrencyGroupSeparators(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szThousandSep[MAX_FMT_SIZE]; - WCHAR szGrouping[MAX_FMT_SIZE]; WCHAR szBuffer[MAX_FMT_SIZE]; CURRENCYFMTW cyFmt; - INT i; - - /* Get group separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONTHOUSANDSEP, - szThousandSep, MAX_FMT_SIZE); - - /* Get grouping */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SMONGROUPING, - szGrouping, MAX_FMT_SIZE); /* Digit grouping */ cyFmt.NumDigits = 0; cyFmt.LeadingZero = 0; cyFmt.lpDecimalSep = L""; - cyFmt.lpThousandSep = szThousandSep; + cyFmt.lpThousandSep = pGlobalData->szCurrThousandSep; cyFmt.PositiveOrder = 0; cyFmt.NegativeOrder = 0; cyFmt.lpCurrencySymbol = L""; cyFmt.Grouping = 0; - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, L"123456789", &cyFmt, szBuffer, MAX_FMT_SIZE); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM, @@ -370,7 +238,7 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData) (LPARAM)szBuffer); cyFmt.Grouping = 3; - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, L"123456789", &cyFmt, szBuffer, MAX_FMT_SIZE); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM, @@ -379,7 +247,7 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData) (LPARAM)szBuffer); cyFmt.Grouping = 32; - GetCurrencyFormatW(pGlobalData->lcid, 0, + GetCurrencyFormatW(pGlobalData->UserLCID, 0, L"123456789", &cyFmt, szBuffer, MAX_FMT_SIZE); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM, @@ -387,19 +255,9 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData) -1, (LPARAM)szBuffer); - i = 0; - if (szGrouping[0] == L'3') - { - if ((szGrouping[1] == L';') && - (szGrouping[2] == L'2')) - i = 2; - else - i = 1; - } - SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM, CB_SETCURSEL, - i, /* Index */ + pGlobalData->nCurrGrouping, /* Index */ 0); } @@ -408,14 +266,7 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static BOOL SetCurrencyDigNum(HWND hwndDlg, PGLOBALDATA pGlobalData) { - PWSTR szFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES]= - { - L"0;0", - L"3;0", - L"3;2;0" - }; - - int nCurrSel; + INT nCurrSel; /* Get setted number of digits in field */ nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM, @@ -425,7 +276,7 @@ SetCurrencyDigNum(HWND hwndDlg, PGLOBALDATA pGlobalData) /* Save number of digits in field */ if (nCurrSel != CB_ERR) - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SMONGROUPING, szFieldDigNumSamples[nCurrSel]); + pGlobalData->nCurrGrouping = nCurrSel; return TRUE; } @@ -434,16 +285,11 @@ SetCurrencyDigNum(HWND hwndDlg, PGLOBALDATA pGlobalData) static BOOL SetCurrencyFieldSep(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szCurrencyFieldSep[MAX_SAMPLES_STR_SIZE]; - /* Get setted currency field separator */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPSEP, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szCurrencyFieldSep); - - /* Save currency field separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SMONTHOUSANDSEP, szCurrencyFieldSep); + (LPARAM)pGlobalData->szCurrThousandSep); return TRUE; } @@ -452,7 +298,6 @@ SetCurrencyFieldSep(HWND hwndDlg, PGLOBALDATA pGlobalData) static BOOL SetCurrencyFracSymNum(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szCurrencyFracSymNum[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted number of fractional symbols */ @@ -460,12 +305,10 @@ SetCurrencyFracSymNum(HWND hwndDlg, PGLOBALDATA pGlobalData) CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* Convert to wide char */ - _itow(nCurrSel, szCurrencyFracSymNum, DECIMAL_RADIX); - - /* Save number of fractional symbols */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_ICURRDIGITS, szCurrencyFracSymNum); + pGlobalData->nCurrDigits = nCurrSel; return TRUE; } @@ -474,18 +317,11 @@ SetCurrencyFracSymNum(HWND hwndDlg, PGLOBALDATA pGlobalData) static BOOL SetCurrencySep(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szCurrencySep[MAX_SAMPLES_STR_SIZE]; - /* Get setted currency decimal separator */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECSEP, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szCurrencySep); - - /* TODO: Add check for correctly input */ - - /* Save currency separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SMONDECIMALSEP, szCurrencySep); + (LPARAM)pGlobalData->szCurrDecimalSep); return TRUE; } @@ -494,7 +330,6 @@ SetCurrencySep(HWND hwndDlg, PGLOBALDATA pGlobalData) static BOOL SetNegCurrencySumFmt(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szNegCurrencySumFmt[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted currency unit */ @@ -502,12 +337,10 @@ SetNegCurrencySumFmt(HWND hwndDlg, PGLOBALDATA pGlobalData) CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* Convert to wide char */ - _itow(nCurrSel, szNegCurrencySumFmt, DECIMAL_RADIX); - - /* Save currency sum format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_INEGCURR, szNegCurrencySumFmt); + pGlobalData->nCurrNegFormat = nCurrSel; return TRUE; } @@ -516,7 +349,6 @@ SetNegCurrencySumFmt(HWND hwndDlg, PGLOBALDATA pGlobalData) static BOOL SetPosCurrencySumFmt(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szPosCurrencySumFmt[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted currency unit */ @@ -524,30 +356,23 @@ SetPosCurrencySumFmt(HWND hwndDlg, PGLOBALDATA pGlobalData) CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* Convert to wide char */ - _itow(nCurrSel, szPosCurrencySumFmt, DECIMAL_RADIX); - - /* Save currency sum format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_ICURRENCY, szPosCurrencySumFmt); + pGlobalData->nCurrPosFormat = nCurrSel; return TRUE; } -/* Set currency unit */ +/* Set currency symbol */ static BOOL -SetCurrencyUnit(HWND hwndDlg, PGLOBALDATA pGlobalData) +SetCurrencySymbol(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szCurrencyUnit[MAX_SAMPLES_STR_SIZE]; - /* Get setted currency unit */ SendDlgItemMessageW(hwndDlg, IDC_CURRENCYSYMBOL, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)(PCWSTR)szCurrencyUnit); - - /* Save currency unit */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SCURRENCY, szCurrencyUnit); + (LPARAM)(PCWSTR)pGlobalData->szCurrSymbol); return TRUE; } @@ -598,34 +423,32 @@ CurrencyPageProc(HWND hwndDlg, break; case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - LPNMHDR lpnm = (LPNMHDR)lParam; - /* If push apply button */ - if (lpnm->code == (UINT)PSN_APPLY) - { - if (!SetCurrencyDigNum(hwndDlg, pGlobalData)) - break; + if (!SetCurrencySymbol(hwndDlg, pGlobalData)) + break; - if (!SetCurrencyUnit(hwndDlg, pGlobalData)) - break; + if (!SetCurrencyDigNum(hwndDlg, pGlobalData)) + break; - if (!SetPosCurrencySumFmt(hwndDlg, pGlobalData)) - break; + if (!SetPosCurrencySumFmt(hwndDlg, pGlobalData)) + break; - if (!SetNegCurrencySumFmt(hwndDlg, pGlobalData)) - break; + if (!SetNegCurrencySumFmt(hwndDlg, pGlobalData)) + break; - if (!SetCurrencySep(hwndDlg, pGlobalData)) - break; + if (!SetCurrencySep(hwndDlg, pGlobalData)) + break; - if (!SetCurrencyFracSymNum(hwndDlg, pGlobalData)) - break; + if (!SetCurrencyFracSymNum(hwndDlg, pGlobalData)) + break; - if (!SetCurrencyFieldSep(hwndDlg, pGlobalData)) - break; + if (!SetCurrencyFieldSep(hwndDlg, pGlobalData)) + break; - UpdateExamples(hwndDlg, pGlobalData); - } + pGlobalData->fUserLocaleChanged = TRUE; + + UpdateExamples(hwndDlg, pGlobalData); } break; } diff --git a/reactos/dll/cpl/intl/date.c b/reactos/dll/cpl/intl/date.c index 43fba69b1f2..c82023884f9 100644 --- a/reactos/dll/cpl/intl/date.c +++ b/reactos/dll/cpl/intl/date.c @@ -93,13 +93,13 @@ SetShortDateSep(HWND hwndDlg, PGLOBALDATA pGlobalData) INT nSepStrSize; INT nSepCount; - /* Get setted separator */ + /* Get separator */ SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, (LPARAM)szShortDateSep); - /* Get setted separator string size */ + /* Get separator string size */ nSepStrSize = wcslen(szShortDateSep); /* Check date components */ @@ -113,7 +113,7 @@ SetShortDateSep(HWND hwndDlg, PGLOBALDATA pGlobalData) } /* Save date separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SDATE, szShortDateSep); + wcscpy(pGlobalData->szDateSep, szShortDateSep); return TRUE; } @@ -131,19 +131,19 @@ SetShortDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData) INT nFmtStrSize; INT nDateCompCount; - /* Get setted format */ + /* Get format */ SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, (LPARAM)szShortDateFmt); - /* Get setted separator */ + /* Get separator */ SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, (LPARAM)szShortDateSep); - /* Get setted format-string size */ + /* Get format-string size */ nFmtStrSize = wcslen(szShortDateFmt); /* Check date components */ @@ -178,11 +178,11 @@ SetShortDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData) wcscpy(szShortDateFmt, pszResultStr); free(pszResultStr); - if(pszFoundSep) + if (pszFoundSep) free(pszFoundSep); /* Save short date format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SSHORTDATE, szShortDateFmt); + wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt); return TRUE; } @@ -196,13 +196,13 @@ SetLongDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData) INT nFmtStrSize; INT nDateCompCount; - /* Get setted format */ + /* Get format */ SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO, WM_GETTEXT, (WPARAM)MAX_SAMPLES_STR_SIZE, (LPARAM)szLongDateFmt); - /* Get setted format string size */ + /* Get format string size */ nFmtStrSize = wcslen(szLongDateFmt); /* Check date components */ @@ -229,8 +229,8 @@ SetLongDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData) return FALSE; } - /* Save short date format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SLONGDATE, szLongDateFmt); + /* Save long date format */ + wcscpy(pGlobalData->szLongDateFormat, szLongDateFmt); return TRUE; } @@ -245,16 +245,9 @@ InitShortDateSepSamples(HWND hwndDlg, PGLOBALDATA pGlobalData) L"/", L"-" }; - WCHAR szShortDateSep[MAX_SAMPLES_STR_SIZE]; INT nCBIndex; INT nRetCode; - /* Get current short date separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SDATE, - szShortDateSep, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, CB_RESETCONTENT, @@ -274,7 +267,7 @@ InitShortDateSepSamples(HWND hwndDlg, PGLOBALDATA pGlobalData) nRetCode = SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, CB_SELECTSTRING, -1, - (LPARAM)szShortDateSep); + (LPARAM)pGlobalData->szDateSep); /* If it is not successful, add new value to list and select them */ if (nRetCode == CB_ERR) @@ -282,11 +275,11 @@ InitShortDateSepSamples(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, CB_ADDSTRING, 0, - (LPARAM)szShortDateSep); + (LPARAM)pGlobalData->szDateSep); SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, CB_SELECTSTRING, -1, - (LPARAM)szShortDateSep); + (LPARAM)pGlobalData->szDateSep); } } @@ -305,25 +298,18 @@ ShortDateFormatEnumProc(PWSTR lpTimeFormatString) VOID InitShortDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE]; INT nRetCode; /* Limit text lengths */ SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO, CB_LIMITTEXT, - MAX_SHRTDATEFMT, + MAX_SHORTDATEFORMAT, 0); SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESEP_COMBO, CB_LIMITTEXT, - MAX_SHRTDATESEP, + MAX_DATESEPARATOR, 0); - /* Get current short date format */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SSHORTDATE, - szShortDateFmt, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO, CB_RESETCONTENT, @@ -332,13 +318,13 @@ InitShortDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) /* Enumerate short date formats */ hwndEnum = GetDlgItem(hwndDlg, IDC_SHRTDATEFMT_COMBO); - EnumDateFormatsW(ShortDateFormatEnumProc, pGlobalData->lcid, DATE_SHORTDATE); + EnumDateFormatsW(ShortDateFormatEnumProc, pGlobalData->UserLCID, DATE_SHORTDATE); /* Set current item to value from registry */ nRetCode = SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO, CB_SELECTSTRING, -1, - (LPARAM)szShortDateFmt); + (LPARAM)pGlobalData->szShortDateFormat); /* If it is not successful, add new value to list and select them */ if (nRetCode == CB_ERR) @@ -346,11 +332,11 @@ InitShortDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO, CB_ADDSTRING, 0, - (LPARAM)szShortDateFmt); + (LPARAM)pGlobalData->szShortDateFormat); SendDlgItemMessageW(hwndDlg, IDC_SHRTDATEFMT_COMBO, CB_SELECTSTRING, -1, - (LPARAM)szShortDateFmt); + (LPARAM)pGlobalData->szShortDateFormat); } } @@ -358,21 +344,14 @@ InitShortDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitLongDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szLongDateFmt[MAX_SAMPLES_STR_SIZE]; INT nRetCode; /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO, CB_LIMITTEXT, - MAX_LONGDATEFMT, + MAX_LONGDATEFORMAT, 0); - /* Get current long date format */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SLONGDATE, - szLongDateFmt, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO, CB_RESETCONTENT, @@ -381,13 +360,13 @@ InitLongDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) /* Enumerate short long formats */ hwndEnum = GetDlgItem(hwndDlg, IDC_LONGDATEFMT_COMBO); - EnumDateFormatsW(ShortDateFormatEnumProc, pGlobalData->lcid, DATE_LONGDATE); + EnumDateFormatsW(ShortDateFormatEnumProc, pGlobalData->UserLCID, DATE_LONGDATE); /* Set current item to value from registry */ nRetCode = SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO, CB_SELECTSTRING, -1, - (LPARAM)szLongDateFmt); + (LPARAM)pGlobalData->szLongDateFormat); /* If it is not successful, add new value to list and select them */ if (nRetCode == CB_ERR) @@ -395,11 +374,11 @@ InitLongDateCB(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO, CB_ADDSTRING, 0, - (LPARAM)szLongDateFmt); + (LPARAM)pGlobalData->szLongDateFormat); SendDlgItemMessageW(hwndDlg, IDC_LONGDATEFMT_COMBO, CB_SELECTSTRING, -1, - (LPARAM)szLongDateFmt); + (LPARAM)pGlobalData->szLongDateFormat); } } @@ -447,7 +426,7 @@ GetMaxDate(LCID lcid) /* Set's MIN data edit control value to MAX-99 */ static VOID -SetMinData(HWND hwndDlg) +SetMinDate(HWND hwndDlg) { WCHAR OutBuffer[YEAR_STR_MAX_SIZE]; HWND hWndYearSpin; @@ -489,14 +468,14 @@ InitMinMaxDateSpin(HWND hwndDlg, PGLOBALDATA pGlobalData) hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR); /* Init max date value */ - wsprintf(OutBuffer, L"%04d", (DWORD)GetMaxDate(pGlobalData->lcid)); + wsprintf(OutBuffer, L"%04d", (DWORD)GetMaxDate(pGlobalData->UserLCID)); SendDlgItemMessageW(hwndDlg, IDC_SECONDYEAR_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); /* Init min date value */ - wsprintf(OutBuffer, L"%04d", (DWORD)GetMaxDate(pGlobalData->lcid) - YEAR_DIFF); + wsprintf(OutBuffer, L"%04d", (DWORD)GetMaxDate(pGlobalData->UserLCID) - YEAR_DIFF); SendDlgItemMessageW(hwndDlg, IDC_FIRSTYEAR_EDIT, WM_SETTEXT, 0, @@ -513,7 +492,7 @@ InitMinMaxDateSpin(HWND hwndDlg, PGLOBALDATA pGlobalData) SendMessageW(hWndYearSpin, UDM_SETPOS, 0, - MAKELONG(GetMaxDate(pGlobalData->lcid),0)); + MAKELONG(GetMaxDate(pGlobalData->UserLCID),0)); } /* Update all date locale samples */ @@ -524,13 +503,13 @@ UpdateDateLocaleSamples(HWND hwndDlg, WCHAR OutBuffer[MAX_SAMPLES_STR_SIZE]; /* Get short date format sample */ - GetDateFormatW(pGlobalData->lcid, DATE_SHORTDATE, NULL, NULL, OutBuffer, + GetDateFormatW(pGlobalData->UserLCID, DATE_SHORTDATE, NULL, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_SHRTDATESAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); /* Get long date sample */ - GetDateFormatW(pGlobalData->lcid, DATE_LONGDATE, NULL, NULL, OutBuffer, + GetDateFormatW(pGlobalData->UserLCID, DATE_LONGDATE, NULL, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_LONGDATESAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); @@ -562,56 +541,54 @@ DatePageProc(HWND hwndDlg, break; case WM_COMMAND: - { - switch (LOWORD(wParam)) - { - case IDC_SECONDYEAR_EDIT: + switch (LOWORD(wParam)) { - if(HIWORD(wParam)==EN_CHANGE) - { - SetMinData(hwndDlg); - } - } - case IDC_SCR_MAX_YEAR: - { - /* Set "Apply" button enabled */ - /* FIXME */ - //PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } - break; - case IDC_CALTYPE_COMBO: - case IDC_HIJCHRON_COMBO: - case IDC_SHRTDATEFMT_COMBO: - case IDC_SHRTDATESEP_COMBO: - case IDC_LONGDATEFMT_COMBO: - { - if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) - { + case IDC_SECONDYEAR_EDIT: + if (HIWORD(wParam) == EN_CHANGE) + { + SetMinDate(hwndDlg); + } + break; + + case IDC_SCR_MAX_YEAR: /* Set "Apply" button enabled */ - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); - } + /* FIXME */ + //PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + break; + + case IDC_CALTYPE_COMBO: + case IDC_HIJCHRON_COMBO: + case IDC_SHRTDATEFMT_COMBO: + case IDC_LONGDATEFMT_COMBO: + case IDC_SHRTDATESEP_COMBO: + if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE) + { + /* Set "Apply" button enabled */ + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + } + break; + } + break; + + case WM_NOTIFY: + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) + { + if (!SetLongDateFormat(hwndDlg, pGlobalData)) + break; + + if (!SetShortDateFormat(hwndDlg, pGlobalData)) + break; + + if (!SetShortDateSep(hwndDlg, pGlobalData)) + break; + + pGlobalData->fUserLocaleChanged = TRUE; + + SetMaxDate(hwndDlg, pGlobalData->UserLCID); + InitShortDateCB(hwndDlg, pGlobalData); + UpdateDateLocaleSamples(hwndDlg, pGlobalData); } break; - } - } - break; - case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; - /* If push apply button */ - if (lpnm->code == (UINT)PSN_APPLY) - { - SetMaxDate(hwndDlg, pGlobalData->lcid); - if(!SetShortDateSep(hwndDlg, pGlobalData)) break; - if(!SetShortDateFormat(hwndDlg, pGlobalData)) break; - if(!SetLongDateFormat(hwndDlg, pGlobalData)) break; - InitShortDateCB(hwndDlg, pGlobalData); - /* FIXME: */ - //Sleep(15); - UpdateDateLocaleSamples(hwndDlg, pGlobalData); - } - } - break; } return FALSE; diff --git a/reactos/dll/cpl/intl/generalp.c b/reactos/dll/cpl/intl/generalp.c index dcd9babe36b..aa1c66017c4 100644 --- a/reactos/dll/cpl/intl/generalp.c +++ b/reactos/dll/cpl/intl/generalp.c @@ -32,6 +32,10 @@ #define SAMPLE_NUMBER L"123456789" #define NO_FLAG 0 +#define NUM_SHEETS 4 + +#define MAX_FIELD_DIG_SAMPLES 3 + typedef struct { LCTYPE lcType; @@ -42,46 +46,13 @@ HWND hList; HWND hLocaleList, hGeoList; BOOL bSpain = FALSE; -LOCALE_KEY_DATA LocaleKeyData[] = -{ - {LOCALE_ICALENDARTYPE, L"iCalendarType"}, - {LOCALE_ICOUNTRY, L"iCountry"}, - {LOCALE_ICURRDIGITS, L"iCurrDigits"}, - {LOCALE_ICURRENCY, L"iCurrency"}, - {LOCALE_IDATE, L"iDate"}, - {LOCALE_IDIGITS, L"iDigits"}, - {LOCALE_IFIRSTDAYOFWEEK, L"iFirstDayOfWeek"}, - {LOCALE_IFIRSTWEEKOFYEAR, L"iFirstWeekOfYear"}, - {LOCALE_ILZERO, L"iLZero"}, - {LOCALE_IMEASURE, L"iMeasure"}, - {LOCALE_INEGCURR, L"iNegCurr"}, - {LOCALE_INEGNUMBER, L"iNegNumber"}, - {LOCALE_ITIME, L"iTime"}, - {LOCALE_ITIMEMARKPOSN, L"iTimePrefix"}, - {LOCALE_ITLZERO, L"iTLZero"}, - {LOCALE_IDIGITSUBSTITUTION, L"NumShape"}, - {LOCALE_S1159, L"s1159"}, - {LOCALE_S2359, L"s2359"}, - {LOCALE_SCOUNTRY, L"sCountry"}, - {LOCALE_SCURRENCY, L"sCurrency"}, - {LOCALE_SDATE, L"sDate"}, - {LOCALE_SDECIMAL, L"sDecimal"}, - {LOCALE_SGROUPING, L"sGrouping"}, - {LOCALE_SABBREVLANGNAME, L"sLanguage"}, - {LOCALE_SLIST, L"sList"}, - {LOCALE_SLONGDATE, L"sLongDate"}, - {LOCALE_SMONDECIMALSEP, L"sMonDecimalSep"}, - {LOCALE_SMONGROUPING, L"sMonGrouping"}, - {LOCALE_SMONTHOUSANDSEP, L"sMonThousandSep"}, - {LOCALE_SNATIVEDIGITS, L"sNativeDigits"}, - {LOCALE_SNEGATIVESIGN, L"sNegativeSign"}, - {LOCALE_SPOSITIVESIGN, L"sPositiveSign"}, - {LOCALE_SSHORTDATE, L"sShortDate"}, - {LOCALE_STHOUSAND, L"sThousand"}, - {LOCALE_STIME, L"sTime"}, - {LOCALE_STIMEFORMAT, L"sTimeFormat"} -}; +PWSTR szCurrencyGrouping[3] = +{ + L"0;0", + L"3;0", + L"3;2;0" +}; static BOOL CALLBACK LocalesEnumProc(LPTSTR lpLocale) @@ -132,24 +103,6 @@ LocalesEnumProc(LPTSTR lpLocale) } -PWSTR -GetLocaleString( - PWSTR *pLocaleArray, - LCTYPE lcType) -{ - DWORD dwDataCount, i; - - dwDataCount = sizeof(LocaleKeyData) / sizeof(LOCALE_KEY_DATA); - for (i = 0; i < dwDataCount; i++) - { - if (LocaleKeyData[i].lcType == lcType) - return pLocaleArray[i]; - } - - return NULL; -} - - /* Update all locale samples */ static VOID @@ -160,34 +113,34 @@ UpdateLocaleSample( WCHAR OutBuffer[MAX_SAMPLES_STR_SIZE]; /* Get number format sample */ - GetNumberFormatW(pGlobalData->lcid, NO_FLAG, SAMPLE_NUMBER, NULL, + GetNumberFormatW(pGlobalData->UserLCID, NO_FLAG, SAMPLE_NUMBER, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_NUMSAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); ZeroMemory(OutBuffer, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR)); /* Get monetary format sample */ - GetCurrencyFormatW(pGlobalData->lcid, NO_FLAG, SAMPLE_NUMBER, NULL, + GetCurrencyFormatW(pGlobalData->UserLCID, NO_FLAG, SAMPLE_NUMBER, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_MONEYSAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); ZeroMemory(OutBuffer, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR)); /* Get time format sample */ - GetTimeFormatW(pGlobalData->lcid, NO_FLAG, NULL, NULL, + GetTimeFormatW(pGlobalData->UserLCID, NO_FLAG, NULL, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_TIMESAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); ZeroMemory(OutBuffer, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR)); /* Get short date format sample */ - GetDateFormatW(pGlobalData->lcid, DATE_SHORTDATE, NULL, NULL, + GetDateFormatW(pGlobalData->UserLCID, DATE_SHORTDATE, NULL, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_SHORTTIMESAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); /* Get long date sample */ - GetDateFormatW(pGlobalData->lcid, DATE_LONGDATE, NULL, NULL, + GetDateFormatW(pGlobalData->UserLCID, DATE_LONGDATE, NULL, NULL, OutBuffer, MAX_SAMPLES_STR_SIZE); SendDlgItemMessageW(hwndDlg, IDC_FULLTIMESAMPLE_EDIT, WM_SETTEXT, 0, (LPARAM)OutBuffer); @@ -217,12 +170,11 @@ BOOL LoadCurrentLocale( PGLOBALDATA pGlobalData) { - WCHAR szValue[9]; + WCHAR szBuffer[16]; PWSTR ptr; HKEY hLocaleKey; DWORD ret; DWORD dwSize; - DWORD i; ret = RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\International", @@ -235,106 +187,904 @@ LoadCurrentLocale( return FALSE; } - pGlobalData->dwLocaleCount = sizeof(LocaleKeyData) / sizeof(LOCALE_KEY_DATA); - - pGlobalData->pLocaleArray = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - pGlobalData->dwLocaleCount * sizeof(PWSTR)); - if (pGlobalData->pLocaleArray == NULL) - { - RegCloseKey(hLocaleKey); - return FALSE; - } - dwSize = 9 * sizeof(WCHAR); RegQueryValueExW(hLocaleKey, L"Locale", NULL, NULL, - (PBYTE)szValue, + (PBYTE)szBuffer, &dwSize); - pGlobalData->lcid = (LCID)wcstoul(szValue, &ptr, 16); + pGlobalData->UserLCID = (LCID)wcstoul(szBuffer, &ptr, 16); - for (i = 0; i < pGlobalData->dwLocaleCount; i++) + /* Number */ + dwSize = MAX_NUMDECIMALSEP * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sDecimal", + NULL, + NULL, + (PBYTE)pGlobalData->szNumDecimalSep, + &dwSize); + + dwSize = MAX_NUMTHOUSANDSEP * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sThousand", + NULL, + NULL, + (PBYTE)pGlobalData->szNumThousandSep, + &dwSize); + + dwSize = MAX_NUMNEGATIVESIGN * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sNegativeSign", + NULL, + NULL, + (PBYTE)pGlobalData->szNumNegativeSign, + &dwSize); + + dwSize = MAX_NUMPOSITIVESIGN * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sPositiveSign", + NULL, + NULL, + (PBYTE)pGlobalData->szNumPositiveSign, + &dwSize); + + dwSize = MAX_NUMLISTSEP * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sList", + NULL, + NULL, + (PBYTE)pGlobalData->szNumListSep, + &dwSize); + + dwSize = MAX_NUMNATIVEDIGITS * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sNativeDigits", + NULL, + NULL, + (PBYTE)pGlobalData->szNumNativeDigits, + &dwSize); + + pGlobalData->nNumNegFormat = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iNegNumber", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nNumNegFormat = _wtoi(szBuffer); + + pGlobalData->nNumDigits = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iDigits", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nNumDigits = _wtoi(szBuffer); + + pGlobalData->nNumLeadingZero = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iLZero", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nNumLeadingZero = _wtoi(szBuffer); + + pGlobalData->nNumMeasure = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iMeasure", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nNumMeasure = _wtoi(szBuffer); + + pGlobalData->nNumShape = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"NumShape", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nNumShape = _wtoi(szBuffer); + + pGlobalData->nNumGrouping = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"sGrouping", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) { - RegQueryValueExW(hLocaleKey, - LocaleKeyData[i].pKeyName, - NULL, - NULL, - NULL, - &dwSize); - if (dwSize > 0) + pGlobalData->nNumGrouping = 0; + if (szBuffer[0] == L'3') { - pGlobalData->pLocaleArray[i] = HeapAlloc(GetProcessHeap(), 0, dwSize); - if (pGlobalData->pLocaleArray[i]) - { - RegQueryValueExW(hLocaleKey, - LocaleKeyData[i].pKeyName, - NULL, - NULL, - (LPVOID)pGlobalData->pLocaleArray[i], - &dwSize); - } + if ((szBuffer[1] == L';') && + (szBuffer[2] == L'2')) + pGlobalData->nNumGrouping = 2; + else + pGlobalData->nNumGrouping = 1; } } + /* Currency */ + dwSize = MAX_CURRSYMBOL * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sCurrency", + NULL, + NULL, + (PBYTE)pGlobalData->szCurrSymbol, + &dwSize); + + dwSize = MAX_CURRDECIMALSEP * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sMonDecimalSep", + NULL, + NULL, + (PBYTE)pGlobalData->szCurrDecimalSep, + &dwSize); + + dwSize = MAX_CURRTHOUSANDSEP * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sMonThousandSep", + NULL, + NULL, + (PBYTE)pGlobalData->szCurrThousandSep, + &dwSize); + + pGlobalData->nCurrGrouping = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"sMonGrouping", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + { + pGlobalData->nCurrGrouping = 0; + if (szBuffer[0] == L'3') + { + if ((szBuffer[1] == L';') && + (szBuffer[2] == L'2')) + pGlobalData->nCurrGrouping = 2; + else + pGlobalData->nCurrGrouping = 1; + } + } + + pGlobalData->nCurrPosFormat = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iCurrency", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nCurrPosFormat = _wtoi(szBuffer); + + pGlobalData->nCurrNegFormat = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iNegCurr", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nCurrNegFormat = _wtoi(szBuffer); + + pGlobalData->nCurrDigits = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iCurrDigits", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nCurrDigits = _wtoi(szBuffer); + + /* Time */ + dwSize = MAX_TIMEFORMAT * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sTimeFormat", + NULL, + NULL, + (PBYTE)pGlobalData->szTimeFormat, + &dwSize); + + dwSize = MAX_TIMESEPARATOR * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sTime", + NULL, + NULL, + (PBYTE)pGlobalData->szTimeSep, + &dwSize); + + dwSize = MAX_TIMEAMSYMBOL * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"s1159", + NULL, + NULL, + (PBYTE)pGlobalData->szTimeAM, + &dwSize); + + dwSize = MAX_TIMEPMSYMBOL * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"s2359", + NULL, + NULL, + (PBYTE)pGlobalData->szTimePM, + &dwSize); + + pGlobalData->nTime = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iTime", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nTime = _wtoi(szBuffer); + + pGlobalData->nTimePrefix = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iTimePrefix", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nTimePrefix = _wtoi(szBuffer); + + pGlobalData->nTimeLeadingZero = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iTLZero", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nTimeLeadingZero = _wtoi(szBuffer); + + /* Date */ + dwSize = MAX_LONGDATEFORMAT * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sLongDate", + NULL, + NULL, + (PBYTE)pGlobalData->szLongDateFormat, + &dwSize); + + dwSize = MAX_SHORTDATEFORMAT * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sShortDate", + NULL, + NULL, + (PBYTE)pGlobalData->szShortDateFormat, + &dwSize); + + dwSize = MAX_DATESEPARATOR * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sDate", + NULL, + NULL, + (PBYTE)pGlobalData->szDateSep, + &dwSize); + + pGlobalData->nFirstDayOfWeek = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iFirstDayOfWeek", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nFirstDayOfWeek = _wtoi(szBuffer); + + pGlobalData->nFirstWeekOfYear = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iFirstWeekOfYear", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nFirstWeekOfYear = _wtoi(szBuffer); + + pGlobalData->nDate = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iDate", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nDate = _wtoi(szBuffer); + + pGlobalData->nCalendarType = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iCalendarType", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nCalendarType = _wtoi(szBuffer); + + /* Misc */ + dwSize = MAX_MISCCOUNTRY * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sCountry", + NULL, + NULL, + (PBYTE)pGlobalData->szMiscCountry, + &dwSize); + + dwSize = MAX_MISCLANGUAGE * sizeof(WCHAR); + RegQueryValueExW(hLocaleKey, + L"sLanguage", + NULL, + NULL, + (PBYTE)pGlobalData->szMiscLanguage, + &dwSize); + + pGlobalData->nMiscCountry = 0; + dwSize = 16 * sizeof(WCHAR); + if (RegQueryValueExW(hLocaleKey, + L"iCountry", + NULL, + NULL, + (PBYTE)szBuffer, + &dwSize) == ERROR_SUCCESS) + pGlobalData->nMiscCountry = _wtoi(szBuffer); + RegCloseKey(hLocaleKey); return TRUE; } -VOID -FreeCurrentLocale( - PGLOBALDATA pGlobalData) -{ - DWORD i; - - if (pGlobalData == NULL || pGlobalData->pLocaleArray == NULL) - return; - - for (i = 0; i < pGlobalData->dwLocaleCount; i++) - { - if (pGlobalData->pLocaleArray[i]) - HeapFree(GetProcessHeap(), 0, pGlobalData->pLocaleArray[i]); - } - HeapFree(GetProcessHeap(), 0, pGlobalData->pLocaleArray); - pGlobalData->pLocaleArray = NULL; -} - - VOID SetNewLocale( PGLOBALDATA pGlobalData, LCID lcid) { - DWORD i, dwSize; + WCHAR szBuffer[16]; - pGlobalData->lcid = lcid; + pGlobalData->UserLCID = lcid; - for (i = 0; i < pGlobalData->dwLocaleCount; i++) + /* Number */ + GetLocaleInfo(lcid, + LOCALE_SDECIMAL | LOCALE_NOUSEROVERRIDE, + pGlobalData->szNumDecimalSep, + MAX_NUMDECIMALSEP * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_STHOUSAND | LOCALE_NOUSEROVERRIDE, + pGlobalData->szNumThousandSep, + MAX_NUMTHOUSANDSEP * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SNEGATIVESIGN | LOCALE_NOUSEROVERRIDE, + pGlobalData->szNumNegativeSign, + MAX_NUMNEGATIVESIGN * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SPOSITIVESIGN | LOCALE_NOUSEROVERRIDE, + pGlobalData->szNumPositiveSign, + MAX_NUMPOSITIVESIGN * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SLIST | LOCALE_NOUSEROVERRIDE, + pGlobalData->szNumListSep, + MAX_NUMLISTSEP * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SNATIVEDIGITS | LOCALE_NOUSEROVERRIDE, + pGlobalData->szNumNativeDigits, + MAX_NUMNATIVEDIGITS * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_INEGNUMBER | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nNumNegFormat = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_IDIGITS | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nNumDigits = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_ILZERO | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nNumLeadingZero = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_IMEASURE | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nNumMeasure = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_IDIGITSUBSTITUTION | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nNumShape = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_SGROUPING | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nNumGrouping = 0; + if (szBuffer[0] == L'3') { - if (pGlobalData->pLocaleArray[i]) - { - HeapFree(GetProcessHeap(), 0, pGlobalData->pLocaleArray[i]); - pGlobalData->pLocaleArray[i] = NULL; - } - - dwSize = GetLocaleInfo(lcid, - LocaleKeyData[i].lcType | LOCALE_NOUSEROVERRIDE, - NULL, - 0); - if (dwSize > 0) - { - pGlobalData->pLocaleArray[i] = HeapAlloc(GetProcessHeap(), 0, dwSize * sizeof(WCHAR)); - if (pGlobalData->pLocaleArray[i]) - { - GetLocaleInfo(lcid, - LocaleKeyData[i].lcType | LOCALE_NOUSEROVERRIDE, - pGlobalData->pLocaleArray[i], - dwSize); - } - } + if ((szBuffer[1] == L';') && + (szBuffer[2] == L'2')) + pGlobalData->nNumGrouping = 2; + else + pGlobalData->nNumGrouping = 1; } + + /* Currency */ + GetLocaleInfo(lcid, + LOCALE_SCURRENCY | LOCALE_NOUSEROVERRIDE, + pGlobalData->szCurrSymbol, + MAX_CURRSYMBOL * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SMONDECIMALSEP | LOCALE_NOUSEROVERRIDE, + pGlobalData->szCurrDecimalSep, + MAX_CURRDECIMALSEP * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SMONTHOUSANDSEP | LOCALE_NOUSEROVERRIDE, + pGlobalData->szCurrThousandSep, + MAX_CURRTHOUSANDSEP * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SMONGROUPING | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nCurrGrouping = 0; + if (szBuffer[0] == L'3') + { + if ((szBuffer[1] == L';') && + (szBuffer[2] == L'2')) + pGlobalData->nCurrGrouping = 2; + else + pGlobalData->nCurrGrouping = 1; + } + + GetLocaleInfo(lcid, + LOCALE_ICURRENCY | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nCurrPosFormat = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_INEGCURR | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nCurrNegFormat = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_ICURRDIGITS | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nCurrDigits = _wtoi(szBuffer); + + /* Time */ + GetLocaleInfo(lcid, + LOCALE_STIMEFORMAT | LOCALE_NOUSEROVERRIDE, + pGlobalData->szTimeFormat, + MAX_TIMEFORMAT * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_STIME | LOCALE_NOUSEROVERRIDE, + pGlobalData->szTimeSep, + MAX_TIMESEPARATOR * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_S1159 | LOCALE_NOUSEROVERRIDE, + pGlobalData->szTimeAM, + MAX_TIMEAMSYMBOL * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_S2359 | LOCALE_NOUSEROVERRIDE, + pGlobalData->szTimePM, + MAX_TIMEPMSYMBOL * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_ITIME | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nTime = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_ITIMEMARKPOSN | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nTimePrefix = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_ITLZERO | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nTimeLeadingZero = _wtoi(szBuffer); + + /* Date */ + GetLocaleInfo(lcid, + LOCALE_SLONGDATE | LOCALE_NOUSEROVERRIDE, + pGlobalData->szLongDateFormat, + MAX_LONGDATEFORMAT * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SSHORTDATE | LOCALE_NOUSEROVERRIDE, + pGlobalData->szShortDateFormat, + MAX_SHORTDATEFORMAT * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SDATE | LOCALE_NOUSEROVERRIDE, + pGlobalData->szDateSep, + MAX_DATESEPARATOR * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_IFIRSTDAYOFWEEK | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nFirstDayOfWeek = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_IFIRSTWEEKOFYEAR | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nFirstWeekOfYear = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_IDATE | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nDate = _wtoi(szBuffer); + + GetLocaleInfo(lcid, + LOCALE_ICALENDARTYPE | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nCalendarType = _wtoi(szBuffer); + + /* Misc */ + GetLocaleInfo(lcid, + LOCALE_SCOUNTRY | LOCALE_NOUSEROVERRIDE, + pGlobalData->szMiscCountry, + MAX_MISCCOUNTRY * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_SLANGUAGE | LOCALE_NOUSEROVERRIDE, + pGlobalData->szMiscLanguage, + MAX_MISCLANGUAGE * sizeof(WCHAR)); + + GetLocaleInfo(lcid, + LOCALE_ICOUNTRY | LOCALE_NOUSEROVERRIDE, + szBuffer, + 16 * sizeof(WCHAR)); + pGlobalData->nMiscCountry = _wtoi(szBuffer); +} + + +static +VOID +SaveUserLocale( + PGLOBALDATA pGlobalData, + HKEY hLocaleKey) +{ + WCHAR szBuffer[16]; + + wsprintf(szBuffer, L"%08lx", (DWORD)pGlobalData->UserLCID); + RegSetValueExW(hLocaleKey, + L"Locale", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + /* Number */ + RegSetValueExW(hLocaleKey, + L"sDecimal", + 0, + REG_SZ, + (PBYTE)pGlobalData->szNumDecimalSep, + (wcslen(pGlobalData->szNumDecimalSep) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sThousand", + 0, + REG_SZ, + (PBYTE)pGlobalData->szNumThousandSep, + (wcslen(pGlobalData->szNumThousandSep) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sNegativeSign", + 0, + REG_SZ, + (PBYTE)pGlobalData->szNumNegativeSign, + (wcslen(pGlobalData->szNumNegativeSign) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sPositiveSign", + 0, + REG_SZ, + (PBYTE)pGlobalData->szNumPositiveSign, + (wcslen(pGlobalData->szNumPositiveSign) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sGrouping", + 0, + REG_SZ, + (PBYTE)szCurrencyGrouping[pGlobalData->nNumGrouping], + (wcslen(szCurrencyGrouping[pGlobalData->nNumGrouping]) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sList", + 0, + REG_SZ, + (PBYTE)pGlobalData->szNumListSep, + (wcslen(pGlobalData->szNumListSep) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sNativeDigits", + 0, + REG_SZ, + (PBYTE)pGlobalData->szNumNativeDigits, + (wcslen(pGlobalData->szNumNativeDigits) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nNumNegFormat, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iNegNumber", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nNumDigits, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iDigits", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nNumLeadingZero, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iLZero", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nNumMeasure, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iMeasure", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nNumShape, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"NumShape", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + /* Currency */ + RegSetValueExW(hLocaleKey, + L"sCurrency", + 0, + REG_SZ, + (PBYTE)pGlobalData->szCurrSymbol, + (wcslen(pGlobalData->szCurrSymbol) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sMonDecimalSep", + 0, + REG_SZ, + (PBYTE)pGlobalData->szCurrDecimalSep, + (wcslen(pGlobalData->szCurrDecimalSep) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sMonThousandSep", + 0, + REG_SZ, + (PBYTE)pGlobalData->szCurrThousandSep, + (wcslen(pGlobalData->szCurrThousandSep) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sMonGrouping", + 0, + REG_SZ, + (PBYTE)szCurrencyGrouping[pGlobalData->nCurrGrouping], + (wcslen(szCurrencyGrouping[pGlobalData->nCurrGrouping]) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nCurrPosFormat, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iCurrency", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nCurrNegFormat, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iNegCurr", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nCurrDigits, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iCurrDigits", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + /* Time */ + RegSetValueExW(hLocaleKey, + L"sTimeFormat", + 0, + REG_SZ, + (PBYTE)pGlobalData->szTimeFormat, + (wcslen(pGlobalData->szTimeFormat) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sTime", + 0, + REG_SZ, + (PBYTE)pGlobalData->szTimeSep, + (wcslen(pGlobalData->szTimeSep) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"s1159", + 0, + REG_SZ, + (PBYTE)pGlobalData->szTimeAM, + (wcslen(pGlobalData->szTimeAM) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"s2359", + 0, + REG_SZ, + (PBYTE)pGlobalData->szTimePM, + (wcslen(pGlobalData->szTimePM) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nTime, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iTime", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nTimePrefix, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iTimePrefix", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nTimeLeadingZero, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iTLZero", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + /* Date */ + RegSetValueExW(hLocaleKey, + L"sLongDate", + 0, + REG_SZ, + (PBYTE)pGlobalData->szLongDateFormat, + (wcslen(pGlobalData->szLongDateFormat) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sShortDate", + 0, + REG_SZ, + (PBYTE)pGlobalData->szShortDateFormat, + (wcslen(pGlobalData->szShortDateFormat) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sDate", + 0, + REG_SZ, + (PBYTE)pGlobalData->szDateSep, + (wcslen(pGlobalData->szDateSep) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nFirstDayOfWeek, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iFirstDayOfWeek", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nFirstWeekOfYear, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iFirstWeekOfYear", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nDate, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iDate", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nCalendarType, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iCalendarType", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); + + /* Misc */ + RegSetValueExW(hLocaleKey, + L"sCountry", + 0, + REG_SZ, + (PBYTE)pGlobalData->szMiscCountry, + (wcslen(pGlobalData->szMiscCountry) + 1) * sizeof(WCHAR)); + + RegSetValueExW(hLocaleKey, + L"sLanguage", + 0, + REG_SZ, + (PBYTE)pGlobalData->szMiscLanguage, + (wcslen(pGlobalData->szMiscLanguage) + 1) * sizeof(WCHAR)); + + _itow(pGlobalData->nMiscCountry, + szBuffer, DECIMAL_RADIX); + RegSetValueExW(hLocaleKey, + L"iCountry", + 0, + REG_SZ, + (PBYTE)szBuffer, + (wcslen(szBuffer) + 1) * sizeof(WCHAR)); } @@ -343,14 +1093,8 @@ VOID SaveCurrentLocale( PGLOBALDATA pGlobalData) { - HKEY localeKey; + HKEY hLocaleKey; DWORD ret; - WCHAR value[9]; - DWORD valuesize; - DWORD i; - - wsprintf(value, L"%08x", (DWORD)pGlobalData->lcid); - valuesize = (wcslen(value) + 1) * sizeof(WCHAR); if (pGlobalData->bApplyToDefaultUser) { @@ -358,69 +1102,39 @@ SaveCurrentLocale( L".DEFAULT\\Control Panel\\International", 0, KEY_WRITE, - &localeKey); + &hLocaleKey); if (ret != ERROR_SUCCESS) { PrintErrorMsgBox(IDS_ERROR_DEF_INT_KEY_REG); return; } - ret = RegSetValueExW(localeKey, L"Locale", 0, REG_SZ, (PBYTE)value, valuesize); - if (ret != ERROR_SUCCESS) - { - RegCloseKey(localeKey); - PrintErrorMsgBox(IDS_ERROR_INT_KEY_REG); - return; - } - - for (i = 0; i < pGlobalData->dwLocaleCount; i++) - { - RegSetValueExW(localeKey, - LocaleKeyData[i].pKeyName, - 0, - REG_SZ, - (PBYTE)pGlobalData->pLocaleArray[i], - (wcslen(pGlobalData->pLocaleArray[i]) + 1) * sizeof(WCHAR)); - } + SaveUserLocale(pGlobalData, hLocaleKey); /* Flush and close the locale key */ - RegFlushKey(localeKey); - RegCloseKey(localeKey); + RegFlushKey(hLocaleKey); + RegCloseKey(hLocaleKey); } - ret = RegOpenKeyExW(HKEY_CURRENT_USER, L"Control Panel\\International", - 0, KEY_READ | KEY_WRITE, &localeKey); + ret = RegOpenKeyExW(HKEY_CURRENT_USER, + L"Control Panel\\International", + 0, + KEY_WRITE, + &hLocaleKey); if (ret != ERROR_SUCCESS) { PrintErrorMsgBox(IDS_ERROR_INT_KEY_REG); return; } - ret = RegSetValueExW(localeKey, L"Locale", 0, REG_SZ, (PBYTE)value, valuesize); - if (ret != ERROR_SUCCESS) - { - RegCloseKey(localeKey); - PrintErrorMsgBox(IDS_ERROR_INT_KEY_REG); - return; - } - - for (i = 0; i < pGlobalData->dwLocaleCount; i++) - { - RegSetValueExW(localeKey, - LocaleKeyData[i].pKeyName, - 0, - REG_SZ, - (PBYTE)pGlobalData->pLocaleArray[i], - (wcslen(pGlobalData->pLocaleArray[i]) + 1) * sizeof(WCHAR)); - } + SaveUserLocale(pGlobalData, hLocaleKey); /* Flush and close the locale key */ - RegFlushKey(localeKey); - RegCloseKey(localeKey); + RegFlushKey(hLocaleKey); + RegCloseKey(hLocaleKey); /* Set the new locale for the current process */ - NtSetDefaultLocale(TRUE, pGlobalData->lcid); - + NtSetDefaultLocale(TRUE, pGlobalData->UserLCID); } /* Location enumerate procedure */ @@ -576,6 +1290,62 @@ VerifyUnattendLCID(HWND hwndDlg) } +static +VOID +InitPropSheetPage( + PROPSHEETPAGEW *psp, + WORD idDlg, + DLGPROC DlgProc, + PGLOBALDATA pGlobalData) +{ + ZeroMemory(psp, sizeof(PROPSHEETPAGEW)); + psp->dwSize = sizeof(PROPSHEETPAGEW); + psp->dwFlags = PSP_DEFAULT; + psp->hInstance = hApplet; + psp->pszTemplate = MAKEINTRESOURCE(idDlg); + psp->pfnDlgProc = DlgProc; + psp->lParam = (LPARAM)pGlobalData; +} + + +INT_PTR +APIENTRY +CustomizeLocalePropertySheet( + HWND hwndDlg, + PGLOBALDATA pGlobalData) +{ + PROPSHEETPAGEW PsPage[NUM_SHEETS + 1]; + PROPSHEETHEADERW psh; + WCHAR Caption[MAX_STR_SIZE]; + + LoadStringW(hApplet, IDS_CUSTOMIZE_TITLE, Caption, sizeof(Caption) / sizeof(TCHAR)); + + ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); + psh.dwSize = sizeof(PROPSHEETHEADER); + psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK; + psh.hwndParent = hwndDlg; + psh.hInstance = hApplet; + psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON)); + psh.pszCaption = Caption; + psh.nPages = (sizeof(PsPage) / sizeof(PROPSHEETPAGE)) - 1; + psh.nStartPage = 0; + psh.ppsp = PsPage; + + InitPropSheetPage(&PsPage[0], IDD_NUMBERSPAGE, NumbersPageProc, pGlobalData); + InitPropSheetPage(&PsPage[1], IDD_CURRENCYPAGE, CurrencyPageProc, pGlobalData); + InitPropSheetPage(&PsPage[2], IDD_TIMEPAGE, TimePageProc, pGlobalData); + InitPropSheetPage(&PsPage[3], IDD_DATEPAGE, DatePageProc, pGlobalData); + + if (IsSortPageNeeded(pGlobalData->UserLCID)) + { + psh.nPages++; + InitPropSheetPage(&PsPage[4], IDD_SORTPAGE, SortPageProc, pGlobalData); + } + + return PropertySheetW(&psh); +} + + /* Property page dialog callback */ INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, @@ -676,7 +1446,12 @@ GeneralPageProc(HWND hwndDlg, break; case IDC_SETUP_BUTTON: - SetupApplet(GetParent(hwndDlg), pGlobalData); + if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData) > 0) + { + UpdateLocaleSample(hwndDlg, pGlobalData); + pGlobalData->fUserLocaleChanged = TRUE; + PropSheet_Changed(GetParent(hwndDlg), hwndDlg); + } break; } break; @@ -704,17 +1479,10 @@ GeneralPageProc(HWND hwndDlg, pGlobalData->fGeoIdChanged = FALSE; } - AddNewKbLayoutsByLcid(pGlobalData->lcid); + AddNewKbLayoutsByLcid(pGlobalData->UserLCID); } } break; - - case WM_DESTROY: - if (pGlobalData) - { - FreeCurrentLocale(pGlobalData); - } - break; } return FALSE; diff --git a/reactos/dll/cpl/intl/intl.h b/reactos/dll/cpl/intl/intl.h index 1c69e7a53df..b88ed53238b 100644 --- a/reactos/dll/cpl/intl/intl.h +++ b/reactos/dll/cpl/intl/intl.h @@ -24,25 +24,32 @@ #define MAX_STR_SIZE 128 #define MAX_SAMPLES_STR_SIZE 70 -#define MAX_NUMBERDSYMBOL 3 -#define MAX_NUMBERSDIGITGRSYM 3 -#define MAX_NUMBERSNSIGNSYM 4 -#define MAX_NUMBERSLSEP 3 +#define MAX_NUMDECIMALSEP 4 +#define MAX_NUMTHOUSANDSEP 4 +#define MAX_NUMNEGATIVESIGN 5 +#define MAX_NUMPOSITIVESIGN 5 +#define MAX_NUMLISTSEP 4 +#define MAX_NUMNATIVEDIGITS 11 -#define MAX_CURRENCYSYMBOL 5 -#define MAX_CURRENCYDECSEP 3 -#define MAX_CURRENCYGRPSEP 3 +#define MAX_CURRSYMBOL 13 +#define MAX_CURRDECIMALSEP 4 +#define MAX_CURRTHOUSANDSEP 4 +#define MAX_CURRGROUPING 10 #define MAX_TIMEFORMAT 80 -#define MAX_TIMESEPARATOR 3 -#define MAX_TIMEAMSYMBOL 12 -#define MAX_TIMEPMSYMBOL 12 +#define MAX_TIMESEPARATOR 4 +#define MAX_TIMEAMSYMBOL 15 +#define MAX_TIMEPMSYMBOL 15 -#define MAX_SHRTDATEFMT 80 -#define MAX_SHRTDATESEP 3 -#define MAX_LONGDATEFMT 80 +#define MAX_SHORTDATEFORMAT 80 +#define MAX_LONGDATEFORMAT 80 +#define MAX_DATESEPARATOR 4 #define MAX_YEAR_EDIT 4 +#define MAX_MISCCOUNTRY 80 +#define MAX_MISCLANGUAGE 80 + + typedef struct _APPLET { UINT idIcon; @@ -53,15 +60,59 @@ typedef struct _APPLET typedef struct _GLOBALDATA { + /* Number */ + WCHAR szNumDecimalSep[MAX_NUMDECIMALSEP]; + WCHAR szNumThousandSep[MAX_NUMTHOUSANDSEP]; + WCHAR szNumNegativeSign[MAX_NUMNEGATIVESIGN]; + WCHAR szNumPositiveSign[MAX_NUMPOSITIVESIGN]; + WCHAR szNumListSep[MAX_NUMLISTSEP]; + WCHAR szNumNativeDigits[MAX_NUMNATIVEDIGITS]; + INT nNumNegFormat; + INT nNumDigits; + INT nNumLeadingZero; + INT nNumGrouping; + INT nNumMeasure; + INT nNumShape; + + /* Currency */ + WCHAR szCurrSymbol[MAX_CURRSYMBOL]; + WCHAR szCurrDecimalSep[MAX_CURRDECIMALSEP]; + WCHAR szCurrThousandSep[MAX_CURRTHOUSANDSEP]; + INT nCurrPosFormat; + INT nCurrNegFormat; + INT nCurrDigits; + INT nCurrGrouping; + + /* Time */ + WCHAR szTimeFormat[MAX_TIMEFORMAT]; + WCHAR szTimeSep[MAX_TIMESEPARATOR]; + WCHAR szTimeAM[MAX_TIMEAMSYMBOL]; + WCHAR szTimePM[MAX_TIMEPMSYMBOL]; + INT nTime; + INT nTimePrefix; + INT nTimeLeadingZero; + + /* Date */ + WCHAR szLongDateFormat[MAX_LONGDATEFORMAT]; + WCHAR szShortDateFormat[MAX_SHORTDATEFORMAT]; + WCHAR szDateSep[MAX_DATESEPARATOR]; + INT nFirstDayOfWeek; + INT nFirstWeekOfYear; + INT nDate; + INT nCalendarType; + + /* Other */ + WCHAR szMiscCountry[MAX_MISCCOUNTRY]; + WCHAR szMiscLanguage[MAX_MISCLANGUAGE]; + INT nMiscCountry; + + LCID UserLCID; + BOOL fUserLocaleChanged; BOOL bApplyToDefaultUser; GEOID geoid; BOOL fGeoIdChanged; - LCID lcid; - DWORD dwLocaleCount; - PWSTR *pLocaleArray; - BOOL fUserLocaleChanged; } GLOBALDATA, *PGLOBALDATA; extern HINSTANCE hApplet; @@ -85,8 +136,6 @@ LanguagesPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); /* advanced.c */ INT_PTR CALLBACK AdvancedPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); -VOID -SetNonUnicodeLang(HWND hwnd, LCID lcid); /* currency.c */ INT_PTR CALLBACK @@ -100,6 +149,11 @@ DatePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); INT_PTR CALLBACK GeneralPageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); +PWSTR +GetLocaleString( + PWSTR *pLocaleArray, + LCTYPE lcType); + /* locale.c */ INT_PTR CALLBACK InpLocalePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -126,10 +180,6 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr); PWSTR ReplaceSubStr(PCWSTR szSourceStr, PCWSTR szStrToReplace, PCWSTR szTempl); -LONG -APIENTRY -SetupApplet(HWND hwndDlg, PGLOBALDATA pGlobalData); - /* kblayouts.c */ VOID AddNewKbLayoutsByLcid(LCID Lcid); diff --git a/reactos/dll/cpl/intl/misc.c b/reactos/dll/cpl/intl/misc.c index 2b9c1330ff2..451536c08e9 100644 --- a/reactos/dll/cpl/intl/misc.c +++ b/reactos/dll/cpl/intl/misc.c @@ -1,7 +1,5 @@ #include "intl.h" -#define NUM_SHEETS 4 - /* Insert the space */ PWSTR InsSpacePos(PCWSTR szInsStr, const int nPos) @@ -167,59 +165,4 @@ ReplaceSubStr(PCWSTR szSourceStr, return szDestStr; } - -static VOID -InitPropSheetPage(PROPSHEETPAGEW *psp, WORD idDlg, DLGPROC DlgProc, PGLOBALDATA pGlobalData) -{ - ZeroMemory(psp, sizeof(PROPSHEETPAGEW)); - psp->dwSize = sizeof(PROPSHEETPAGEW); - psp->dwFlags = PSP_DEFAULT; - psp->hInstance = hApplet; - psp->pszTemplate = MAKEINTRESOURCE(idDlg); - psp->pfnDlgProc = DlgProc; - psp->lParam = (LPARAM)pGlobalData; -} - - -/* Create applets */ -LONG -APIENTRY -SetupApplet( - HWND hwndDlg, - PGLOBALDATA pGlobalData) -{ - PROPSHEETPAGEW PsPage[NUM_SHEETS + 1]; - PROPSHEETHEADERW psh; - WCHAR Caption[MAX_STR_SIZE]; - INT_PTR ret; - - LoadStringW(hApplet, IDS_CUSTOMIZE_TITLE, Caption, sizeof(Caption) / sizeof(TCHAR)); - - ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); - psh.dwSize = sizeof(PROPSHEETHEADER); - psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK; - psh.hwndParent = hwndDlg; - psh.hInstance = hApplet; - psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON)); - psh.pszCaption = Caption; - psh.nPages = (sizeof(PsPage) / sizeof(PROPSHEETPAGE)) - 1; - psh.nStartPage = 0; - psh.ppsp = PsPage; - - InitPropSheetPage(&PsPage[0], IDD_NUMBERSPAGE, NumbersPageProc, pGlobalData); - InitPropSheetPage(&PsPage[1], IDD_CURRENCYPAGE, CurrencyPageProc, pGlobalData); - InitPropSheetPage(&PsPage[2], IDD_TIMEPAGE, TimePageProc, pGlobalData); - InitPropSheetPage(&PsPage[3], IDD_DATEPAGE, DatePageProc, pGlobalData); - - if (IsSortPageNeeded(pGlobalData->lcid)) - { - psh.nPages++; - InitPropSheetPage(&PsPage[4], IDD_SORTPAGE, SortPageProc, pGlobalData); - } - - ret = PropertySheetW(&psh); - - return (LONG)(ret != -1); -} - /* EOF */ diff --git a/reactos/dll/cpl/intl/numbers.c b/reactos/dll/cpl/intl/numbers.c index 5a97815ddef..3d426220dfc 100644 --- a/reactos/dll/cpl/intl/numbers.c +++ b/reactos/dll/cpl/intl/numbers.c @@ -57,22 +57,15 @@ static PWSTR lpListSepSamples[MAX_LIST_SEP_SAMPLES] = static VOID InitNumDecimalSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szNumSep[MAX_SAMPLES_STR_SIZE]; INT nCBIndex; INT nRetCode; /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL, CB_LIMITTEXT, - MAX_NUMBERDSYMBOL, + MAX_NUMDECIMALSEP - 1, 0); - /* Get current decimal separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SDECIMAL, - szNumSep, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL, CB_RESETCONTENT, @@ -92,7 +85,7 @@ InitNumDecimalSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL, CB_SELECTSTRING, -1, - (LPARAM)(LPCSTR)szNumSep); + (LPARAM)pGlobalData->szNumDecimalSep); /* If it is not successful, add new values to list and select them */ if (nRetCode == CB_ERR) @@ -100,11 +93,11 @@ InitNumDecimalSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL, CB_ADDSTRING, MAX_NUM_SEP_SAMPLES, - (LPARAM)szNumSep); + (LPARAM)pGlobalData->szNumDecimalSep); SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL, CB_SELECTSTRING, -1, - (LPARAM)szNumSep); + (LPARAM)pGlobalData->szNumDecimalSep); } } @@ -112,16 +105,9 @@ InitNumDecimalSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitNumOfFracSymbCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szFracNum[MAX_SAMPLES_STR_SIZE]; WCHAR szFracCount[MAX_SAMPLES_STR_SIZE]; INT nCBIndex; - /* Get current number of fractional symbols */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_IDIGITS, - szFracNum, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNDIGDEC, CB_RESETCONTENT, @@ -143,7 +129,7 @@ InitNumOfFracSymbCB(HWND hwndDlg, PGLOBALDATA pGlobalData) /* Set current item to value from registry */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNDIGDEC, CB_SETCURSEL, - (WPARAM)_wtoi(szFracNum), + (WPARAM)pGlobalData->nNumDigits, (LPARAM)0); } @@ -151,22 +137,15 @@ InitNumOfFracSymbCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitNumFieldSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szFieldSep[MAX_SAMPLES_STR_SIZE]; INT nCBIndex; INT nRetCode; /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM, CB_LIMITTEXT, - MAX_NUMBERSDIGITGRSYM, + MAX_NUMTHOUSANDSEP - 1, 0); - /* Get current field separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_STHOUSAND, - szFieldSep, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM, CB_RESETCONTENT, @@ -186,7 +165,7 @@ InitNumFieldSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM, CB_SELECTSTRING, -1, - (LPARAM)szFieldSep); + (LPARAM)pGlobalData->szNumThousandSep); /* If it is not success, add new values to list and select them */ if (nRetCode == CB_ERR) @@ -194,11 +173,11 @@ InitNumFieldSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM, CB_ADDSTRING, 0, - (LPARAM)szFieldSep); + (LPARAM)pGlobalData->szNumThousandSep); SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM, CB_SELECTSTRING, -1, - (LPARAM)szFieldSep); + (LPARAM)pGlobalData->szNumThousandSep); } } @@ -206,16 +185,8 @@ InitNumFieldSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitFieldDigNumCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szFieldDigNum[MAX_SAMPLES_STR_SIZE]; PWSTR pszFieldDigNumSmpl; INT nCBIndex; - INT nRetCode; - - /* Get current field digits num */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SGROUPING, - szFieldDigNum, - MAX_SAMPLES_STR_SIZE); /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, @@ -234,49 +205,25 @@ InitFieldDigNumCB(HWND hwndDlg, PGLOBALDATA pGlobalData) free(pszFieldDigNumSmpl); } - pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, szFieldDigNum); - /* Set current item to value from registry */ - nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, - CB_SELECTSTRING, - -1, - (LPARAM)pszFieldDigNumSmpl); - - /* If it is not successful, add new values to list and select them */ - if (nRetCode == CB_ERR) - { - SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, - CB_ADDSTRING, - 0, - (LPARAM)pszFieldDigNumSmpl); - SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, - CB_SELECTSTRING, - -1, - (LPARAM)pszFieldDigNumSmpl); - } - - free(pszFieldDigNumSmpl); + SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, + CB_SETCURSEL, + (WPARAM)pGlobalData->nNumGrouping, + (LPARAM)0); } /* Init negative sign control box */ static VOID InitNegSignCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szNegSign[MAX_SAMPLES_STR_SIZE]; INT nCBIndex; INT nRetCode; /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM, CB_LIMITTEXT, - MAX_NUMBERSNSIGNSYM, + MAX_NUMNEGATIVESIGN - 1, 0); - /* Get current negative sign */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SNEGATIVESIGN, - szNegSign, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM, CB_RESETCONTENT, @@ -296,7 +243,7 @@ InitNegSignCB(HWND hwndDlg, PGLOBALDATA pGlobalData) nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM, CB_SELECTSTRING, -1, - (LPARAM)szNegSign); + (LPARAM)pGlobalData->szNumNegativeSign); /* If it is not successful, add new values to list and select them */ if (nRetCode == CB_ERR) @@ -304,11 +251,11 @@ InitNegSignCB(HWND hwndDlg, PGLOBALDATA pGlobalData) SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM, CB_ADDSTRING, 0, - (LPARAM)szNegSign); + (LPARAM)pGlobalData->szNumNegativeSign); SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM, CB_SELECTSTRING, -1, - (LPARAM)szNegSign); + (LPARAM)pGlobalData->szNumNegativeSign); } } @@ -316,50 +263,29 @@ InitNegSignCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szNegNumFmt[MAX_SAMPLES_STR_SIZE]; - WCHAR szNumSep[MAX_SAMPLES_STR_SIZE]; - WCHAR szNegSign[MAX_SAMPLES_STR_SIZE]; WCHAR szNewSample[MAX_SAMPLES_STR_SIZE]; PWSTR pszResultStr; INT nCBIndex; - /* Get current negative numbers format */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_INEGNUMBER, - szNegNumFmt, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); - /* Get current decimal separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SDECIMAL, - szNumSep, - MAX_SAMPLES_STR_SIZE); - - /* Get current negative sign */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SNEGATIVESIGN, - szNegSign, - MAX_SAMPLES_STR_SIZE); - /* Create standard list of negative numbers formats */ for (nCBIndex = 0; nCBIndex < MAX_NEG_NUMBERS_SAMPLES; nCBIndex++) { /* Replace standard separator to setted */ pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex], - szNumSep, + pGlobalData->szNumDecimalSep, L","); wcscpy(szNewSample, pszResultStr); free(pszResultStr); /* Replace standard negative sign to setted */ pszResultStr = ReplaceSubStr(szNewSample, - szNegSign, + pGlobalData->szNumNegativeSign, L"-"); SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT, CB_ADDSTRING, @@ -371,7 +297,7 @@ InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData) /* Set current item to value from registry */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT, CB_SETCURSEL, - (WPARAM)_wtoi(szNegNumFmt), + (WPARAM)pGlobalData->nNumNegFormat, (LPARAM)0); } @@ -379,34 +305,20 @@ InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData) static VOID InitLeadingZeroesCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szLeadNumFmt[MAX_SAMPLES_STR_SIZE]; - WCHAR szNumSep[MAX_SAMPLES_STR_SIZE]; PWSTR pszResultStr; INT nCBIndex; - /* Get current leading zeroes format */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_ILZERO, - szLeadNumFmt, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDISPLEADZER, CB_RESETCONTENT, (WPARAM)0, (LPARAM)0); - /* Get current decimal separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SDECIMAL, - szNumSep, - MAX_SAMPLES_STR_SIZE); - /* Create list of standard leading zeroes formats */ for (nCBIndex = 0; nCBIndex < MAX_LEAD_ZEROES_SAMPLES; nCBIndex++) { pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex], - szNumSep, + pGlobalData->szNumDecimalSep, L","); SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER, CB_ADDSTRING, @@ -418,7 +330,7 @@ InitLeadingZeroesCB(HWND hwndDlg, PGLOBALDATA pGlobalData) /* Set current item to value from registry */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDISPLEADZER, CB_SETCURSEL, - (WPARAM)_wtoi(szLeadNumFmt), + (WPARAM)pGlobalData->nNumLeadingZero, (LPARAM)0); } @@ -426,22 +338,15 @@ static VOID InitListSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szListSep[MAX_SAMPLES_STR_SIZE]; INT nCBIndex; INT nRetCode; /* Limit text length */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP, CB_LIMITTEXT, - MAX_NUMBERSLSEP, + MAX_NUMLISTSEP - 1, 0); - /* Get current list separator */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_SLIST, - szListSep, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP, CB_RESETCONTENT, @@ -461,7 +366,7 @@ InitListSepCB(HWND hwndDlg, nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP, CB_SELECTSTRING, -1, - (LPARAM)szListSep); + (LPARAM)pGlobalData->szNumListSep); /* If it is not successful, add new values to list and select them */ if (nRetCode == CB_ERR) @@ -469,11 +374,11 @@ InitListSepCB(HWND hwndDlg, SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP, CB_ADDSTRING, 0, - (LPARAM)szListSep); + (LPARAM)pGlobalData->szNumListSep); SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP, CB_SELECTSTRING, -1, - (LPARAM)szListSep); + (LPARAM)pGlobalData->szNumListSep); } } @@ -482,16 +387,9 @@ static VOID InitUnitsSysCB(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szUnitsSys[MAX_SAMPLES_STR_SIZE]; WCHAR szUnitName[128]; INT nCBIndex; - /* Get current system of units */ - GetLocaleInfoW(pGlobalData->lcid, - LOCALE_IMEASURE, - szUnitsSys, - MAX_SAMPLES_STR_SIZE); - /* Clear all box content */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSMEASSYS, CB_RESETCONTENT, @@ -512,7 +410,7 @@ InitUnitsSysCB(HWND hwndDlg, /* Set current item to value from registry */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSMEASSYS, CB_SETCURSEL, - (WPARAM)_wtoi(szUnitsSys), + (WPARAM)pGlobalData->nNumMeasure, (LPARAM)0); } @@ -524,7 +422,7 @@ UpdateNumSamples(HWND hwndDlg, WCHAR OutBuffer[MAX_FMT_SIZE]; /* Get positive number format sample */ - GetNumberFormatW(pGlobalData->lcid, + GetNumberFormatW(pGlobalData->UserLCID, 0, SAMPLE_NUMBER, NULL, @@ -537,7 +435,7 @@ UpdateNumSamples(HWND hwndDlg, (LPARAM)OutBuffer); /* Get positive number format sample */ - GetNumberFormatW(pGlobalData->lcid, + GetNumberFormatW(pGlobalData->UserLCID, 0, SAMPLE_NEG_NUMBER, NULL, @@ -555,16 +453,11 @@ static BOOL SetNumDecimalSep(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szDecimalSep[MAX_SAMPLES_STR_SIZE]; - /* Get setted decimal separator */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL, WM_GETTEXT, - (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szDecimalSep); - - /* Save decimal separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SDECIMAL, szDecimalSep); + (WPARAM)MAX_NUMDECIMALSEP, + (LPARAM)pGlobalData->szNumDecimalSep); return TRUE; } @@ -574,7 +467,6 @@ static BOOL SetFracSymNum(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szFracSymNum[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted number of fractional symbols */ @@ -582,12 +474,10 @@ SetFracSymNum(HWND hwndDlg, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* Convert to wide char */ - _itow(nCurrSel, szFracSymNum, DECIMAL_RADIX); - - /* Save number of fractional symbols */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_IDIGITS, szFracSymNum); + pGlobalData->nNumDigits = nCurrSel; return TRUE; } @@ -597,35 +487,31 @@ static BOOL SetNumFieldSep(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szFieldSep[MAX_SAMPLES_STR_SIZE]; - - /* Get setted field separator */ + /* Get thousand separator */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM, WM_GETTEXT, - (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szFieldSep); - - /* Save field separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_STHOUSAND, szFieldSep); + (WPARAM)MAX_NUMTHOUSANDSEP, + (LPARAM)pGlobalData->szNumThousandSep); return TRUE; } -/* Set number of digits in field */ +/* Set number of digits in field */ static BOOL SetFieldDigNum(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szFieldDigNum[MAX_SAMPLES_STR_SIZE]; + INT nCurrSel; - /* Get setted number of digidts in field */ - SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, - WM_GETTEXT, - (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szFieldDigNum); + /* Get setted negative sum format */ + nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING, + CB_GETCURSEL, + (WPARAM)0, + (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* Save number of digits in field */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SGROUPING, szFieldDigNum); + pGlobalData->nNumGrouping = nCurrSel; return TRUE; } @@ -635,16 +521,11 @@ static BOOL SetNumNegSign(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szNegSign[MAX_SAMPLES_STR_SIZE]; - /* Get setted negative sign */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM, WM_GETTEXT, - (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szNegSign); - - /* Save negative sign */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SNEGATIVESIGN, szNegSign); + (WPARAM)MAX_NUMNEGATIVESIGN, + (LPARAM)pGlobalData->szNumNegativeSign); return TRUE; } @@ -654,7 +535,6 @@ static BOOL SetNegSumFmt(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szNegSumFmt[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted negative sum format */ @@ -662,12 +542,10 @@ SetNegSumFmt(HWND hwndDlg, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* convert to wide char */ - _itow(nCurrSel, szNegSumFmt,DECIMAL_RADIX); - - /* Save negative sum format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_INEGNUMBER, szNegSumFmt); + pGlobalData->nNumNegFormat = nCurrSel; return TRUE; } @@ -677,7 +555,6 @@ static BOOL SetNumLeadZero(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szLeadZero[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted leading zero format */ @@ -685,12 +562,10 @@ SetNumLeadZero(HWND hwndDlg, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* Convert to wide char */ - _itow(nCurrSel, szLeadZero, DECIMAL_RADIX); - - /* Save leading zero format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_ILZERO, szLeadZero); + pGlobalData->nNumLeadingZero = nCurrSel; return TRUE; } @@ -700,16 +575,11 @@ static BOOL SetNumListSep(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szListSep[MAX_SAMPLES_STR_SIZE]; - /* Get setted list separator */ SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP, WM_GETTEXT, - (WPARAM)MAX_SAMPLES_STR_SIZE, - (LPARAM)szListSep); - - /* Save list separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_SLIST, szListSep); + (WPARAM)MAX_NUMLISTSEP, + (LPARAM)pGlobalData->szNumListSep); return TRUE; } @@ -719,7 +589,6 @@ static BOOL SetNumUnitsSys(HWND hwndDlg, PGLOBALDATA pGlobalData) { - WCHAR szUnitsSys[MAX_SAMPLES_STR_SIZE]; INT nCurrSel; /* Get setted units system */ @@ -727,12 +596,10 @@ SetNumUnitsSys(HWND hwndDlg, CB_GETCURSEL, (WPARAM)0, (LPARAM)0); + if (nCurrSel == CB_ERR) + return FALSE; - /* convert to wide char */ - _itow(nCurrSel, szUnitsSys, DECIMAL_RADIX); - - /* Save units system */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_IMEASURE, szUnitsSys); + pGlobalData->nNumMeasure = nCurrSel; return TRUE; } @@ -817,6 +684,8 @@ NumbersPageProc(HWND hwndDlg, if (!SetNumUnitsSys(hwndDlg, pGlobalData)) break; + pGlobalData->fUserLocaleChanged = TRUE; + UpdateNumSamples(hwndDlg, pGlobalData); } break; diff --git a/reactos/dll/cpl/intl/sort.c b/reactos/dll/cpl/intl/sort.c index 338e605caad..db02df7a075 100644 --- a/reactos/dll/cpl/intl/sort.c +++ b/reactos/dll/cpl/intl/sort.c @@ -159,7 +159,7 @@ SortPageProc(HWND hwndDlg, pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData); - CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO), pGlobalData->lcid); + CreateSortList(GetDlgItem(hwndDlg, IDC_SORTLIST_COMBO), pGlobalData->UserLCID); break; case WM_COMMAND: @@ -168,28 +168,6 @@ SortPageProc(HWND hwndDlg, case IDC_SORTLIST_COMBO: if (HIWORD(wParam) == CBN_SELCHANGE) { - LCID NewLcid; - INT iCurSel; - - iCurSel = SendDlgItemMessage(hwndDlg, - IDC_SORTLIST_COMBO, - CB_GETCURSEL, - 0, - 0); - if (iCurSel == CB_ERR) - break; - - NewLcid = SendDlgItemMessage(hwndDlg, - IDC_SORTLIST_COMBO, - CB_GETITEMDATA, - iCurSel, - 0); - if (NewLcid == (LCID)CB_ERR) - break; - - /* Save the new LCID */ - pGlobalData->lcid = NewLcid; - PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } break; @@ -199,7 +177,28 @@ SortPageProc(HWND hwndDlg, case WM_NOTIFY: if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - /* FIXME: Set locale ID: pGlobalData->lcid */ + LCID NewLcid; + INT iCurSel; + + iCurSel = SendDlgItemMessage(hwndDlg, + IDC_SORTLIST_COMBO, + CB_GETCURSEL, + 0, + 0); + if (iCurSel == CB_ERR) + break; + + NewLcid = SendDlgItemMessage(hwndDlg, + IDC_SORTLIST_COMBO, + CB_GETITEMDATA, + iCurSel, + 0); + if (NewLcid == (LCID)CB_ERR) + break; + + /* Save the new LCID */ + pGlobalData->UserLCID = NewLcid; + pGlobalData->fUserLocaleChanged = TRUE; } break; } diff --git a/reactos/dll/cpl/intl/time.c b/reactos/dll/cpl/intl/time.c index a5b603a8925..1e1e720b02b 100644 --- a/reactos/dll/cpl/intl/time.c +++ b/reactos/dll/cpl/intl/time.c @@ -39,11 +39,11 @@ TimeFormatEnumProc(PWSTR lpTimeFormatString) } static VOID -UpdateTimeSample(HWND hWnd, LCID lcid) +UpdateTimeSample(HWND hWnd, PGLOBALDATA pGlobalData) { WCHAR szBuffer[80]; - GetTimeFormatW(lcid, 0, NULL, NULL, szBuffer, 80); + GetTimeFormatW(pGlobalData->UserLCID, 0, NULL, pGlobalData->szTimeFormat, szBuffer, 80); SendDlgItemMessageW(hWnd, IDC_TIMESAMPLE, WM_SETTEXT, 0, (LPARAM)szBuffer); } @@ -78,6 +78,111 @@ GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize) } } + +static +VOID +InitTimeFormatCB( + HWND hwndDlg, + PGLOBALDATA pGlobalData) +{ + /* Get the time format */ + SendDlgItemMessageW(hwndDlg, IDC_TIMEFORMAT, + CB_LIMITTEXT, MAX_TIMEFORMAT, 0); + + /* Add available time formats to the list */ + hwndEnum = GetDlgItem(hwndDlg, IDC_TIMEFORMAT); + EnumTimeFormatsW(TimeFormatEnumProc, pGlobalData->UserLCID, 0); + + SendDlgItemMessageW(hwndDlg, IDC_TIMEFORMAT, + CB_SELECTSTRING, + -1, + (LPARAM)pGlobalData->szTimeFormat); +} + +static +VOID +InitTimeSeparatorCB( + HWND hwndDlg, + PGLOBALDATA pGlobalData) +{ + SendDlgItemMessageW(hwndDlg, IDC_TIMESEPARATOR, + CB_LIMITTEXT, MAX_TIMESEPARATOR, 0); + + SendDlgItemMessageW(hwndDlg, IDC_TIMESEPARATOR, + CB_ADDSTRING, + 0, + (LPARAM)pGlobalData->szTimeSep); + + SendDlgItemMessageW(hwndDlg, IDC_TIMESEPARATOR, + CB_SETCURSEL, + 0, /* Index */ + 0); +} + + +static +VOID +InitAmSymbol( + HWND hwndDlg, + PGLOBALDATA pGlobalData) +{ + int nLen; + + SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, + CB_LIMITTEXT, MAX_TIMEAMSYMBOL, 0); + + nLen = wcslen(pGlobalData->szTimeAM); + + SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, + CB_ADDSTRING, + 0, + (LPARAM)pGlobalData->szTimeAM); + if (nLen != 0) + { + SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, + CB_ADDSTRING, + 0, + (LPARAM)L""); + } + + SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, + CB_SETCURSEL, + 0, /* Index */ + 0); +} + + +static +VOID +InitPmSymbol( + HWND hwndDlg, + PGLOBALDATA pGlobalData) +{ + int nLen; + + SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, + CB_LIMITTEXT, MAX_TIMEPMSYMBOL, 0); + + nLen = wcslen(pGlobalData->szTimeAM); + + SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, + CB_ADDSTRING, + 0, + (LPARAM)pGlobalData->szTimePM); + if (nLen != 0) + { + SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, + CB_ADDSTRING, + 0, + (LPARAM)L""); + } + SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, + CB_SETCURSEL, + 0, /* Index */ + 0); +} + + /* Property page dialog callback */ INT_PTR CALLBACK TimePageProc(HWND hwndDlg, @@ -92,84 +197,24 @@ TimePageProc(HWND hwndDlg, switch (uMsg) { case WM_INITDIALOG: - { - WCHAR Buffer[80]; - int nLen; - pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam; SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData); - /* Update the time format sample */ - UpdateTimeSample(hwndDlg, pGlobalData->lcid); - /* Get the time format */ - SendDlgItemMessageW(hwndDlg, IDC_TIMEFORMAT, - CB_LIMITTEXT, MAX_TIMEFORMAT, 0); - - /* Add available time formats to the list */ - hwndEnum = GetDlgItem(hwndDlg, IDC_TIMEFORMAT); - EnumTimeFormatsW(TimeFormatEnumProc, pGlobalData->lcid, 0); - - GetLocaleInfoW(pGlobalData->lcid, LOCALE_STIMEFORMAT, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - SendDlgItemMessageW(hwndDlg, IDC_TIMEFORMAT, - CB_SELECTSTRING, - -1, - (LPARAM)Buffer); + InitTimeFormatCB(hwndDlg, pGlobalData); /* Get the time separator */ - SendDlgItemMessageW(hwndDlg, IDC_TIMESEPARATOR, - CB_LIMITTEXT, MAX_TIMESEPARATOR, 0); - GetLocaleInfoW(pGlobalData->lcid, LOCALE_STIME, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - SendDlgItemMessageW(hwndDlg, IDC_TIMESEPARATOR, - CB_ADDSTRING, - 0, - (LPARAM)Buffer); - SendDlgItemMessageW(hwndDlg, IDC_TIMESEPARATOR, - CB_SETCURSEL, - 0, /* Index */ - 0); + InitTimeSeparatorCB(hwndDlg, pGlobalData); /* Get the AM symbol */ - SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, - CB_LIMITTEXT, MAX_TIMEAMSYMBOL, 0); - nLen = GetLocaleInfoW(pGlobalData->lcid, LOCALE_S1159, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, - CB_ADDSTRING, - 0, - (LPARAM)Buffer); - if (nLen != 0) - { - SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, - CB_ADDSTRING, - 0, - (LPARAM)L""); - } - SendDlgItemMessageW(hwndDlg, IDC_TIMEAMSYMBOL, - CB_SETCURSEL, - 0, /* Index */ - 0); + InitAmSymbol(hwndDlg, pGlobalData); /* Get the PM symbol */ - SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, - CB_LIMITTEXT, MAX_TIMEPMSYMBOL, 0); - nLen = GetLocaleInfoW(pGlobalData->lcid, LOCALE_S2359, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, - CB_ADDSTRING, - 0, - (LPARAM)Buffer); - if (nLen != 0) - { - SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, - CB_ADDSTRING, - 0, - (LPARAM)L""); - } - SendDlgItemMessageW(hwndDlg, IDC_TIMEPMSYMBOL, - CB_SETCURSEL, - 0, /* Index */ - 0); - } - break; + InitPmSymbol(hwndDlg, pGlobalData); + + /* Update the time format sample */ + UpdateTimeSample(hwndDlg, pGlobalData); + break; case WM_COMMAND: switch (LOWORD(wParam)) @@ -183,47 +228,39 @@ TimePageProc(HWND hwndDlg, { PropSheet_Changed(GetParent(hwndDlg), hwndDlg); } - break; + break; } break; case WM_NOTIFY: - { - LPNMHDR lpnm = (LPNMHDR)lParam; - - if (lpnm->code == (UINT)PSN_APPLY) + if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY) { - WCHAR Buffer[80]; - /* Get selected/typed time format text */ - GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - - /* Set time format */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_STIMEFORMAT, Buffer); + GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT, + pGlobalData->szTimeFormat, + MAX_TIMEFORMAT); /* Get selected/typed time separator text */ - GetSelectedComboEntry(hwndDlg, IDC_TIMESEPARATOR, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - - /* Set time separator */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_STIME, Buffer); + GetSelectedComboEntry(hwndDlg, IDC_TIMESEPARATOR, + pGlobalData->szTimeSep, + MAX_TIMESEPARATOR); /* Get selected/typed AM symbol text */ - GetSelectedComboEntry(hwndDlg, IDC_TIMEAMSYMBOL, Buffer, sizeof(Buffer)/sizeof(WCHAR)); - - /* Set the AM symbol */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_S1159, Buffer); + GetSelectedComboEntry(hwndDlg, IDC_TIMEAMSYMBOL, + pGlobalData->szTimeAM, + MAX_TIMEAMSYMBOL); /* Get selected/typed PM symbol text */ - GetSelectedComboEntry(hwndDlg, IDC_TIMEPMSYMBOL, Buffer, sizeof(Buffer)/sizeof(WCHAR)); + GetSelectedComboEntry(hwndDlg, IDC_TIMEPMSYMBOL, + pGlobalData->szTimePM, + MAX_TIMEPMSYMBOL); - /* Set the PM symbol */ - SetLocaleInfoW(pGlobalData->lcid, LOCALE_S2359, Buffer); + pGlobalData->fUserLocaleChanged = TRUE; /* Update the time format sample */ - UpdateTimeSample(hwndDlg, pGlobalData->lcid); + UpdateTimeSample(hwndDlg, pGlobalData); } - } - break; + break; } return FALSE;