[INTL]
authorEric Kohl <eric.kohl@reactos.org>
Sat, 6 May 2017 14:41:50 +0000 (14:41 +0000)
committerEric Kohl <eric.kohl@reactos.org>
Sat, 6 May 2017 14:41:50 +0000 (14:41 +0000)
- Get rid of the individual getter funtions. Use GetSelectedComboBoxIndex for all CBS_DROPDOWNLIST comboboxes and GetSelectedComboBoxText for all CBS_DROPDOWN comboboxes.
- Check the relevant settings only!
- Rename SetXxxSettings to GetXxxSettings because it is a getter function.
- Handle the bogus WM_COMMAND/EN_CHANGE message that is sent when the IDC_SECONDYEAR_EDIT edit control is initialized. Controls should NEVER send notifications when they are modified programmatically! :-/

svn path=/trunk/; revision=74488

reactos/dll/cpl/intl/currency.c
reactos/dll/cpl/intl/date.c
reactos/dll/cpl/intl/intl.h
reactos/dll/cpl/intl/misc.c
reactos/dll/cpl/intl/numbers.c
reactos/dll/cpl/intl/time.c

index 03c962b..98a5a87 100644 (file)
@@ -261,145 +261,80 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
 }
 
 
-/* Set number of digits in field  */
-static BOOL
-SetCurrencyDigNum(HWND hwndDlg, PINT pnCurrGrouping)
+static
+BOOL
+GetCurrencySetting(
+     HWND hwndDlg,
+     PGLOBALDATA pGlobalData)
 {
-    INT nCurrSel;
-
-    /* Get setted number of digits in field */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
-        return FALSE;
-
-    *pnCurrGrouping = nCurrSel;
-
-    return TRUE;
-}
+    WCHAR szCurrSymbol[MAX_CURRSYMBOL];
+    WCHAR szCurrDecimalSep[MAX_CURRDECIMALSEP];
+    WCHAR szCurrThousandSep[MAX_CURRTHOUSANDSEP];
+    INT nCurrPosFormat;
+    INT nCurrNegFormat;
+    INT nCurrDigits;
+    INT nCurrGrouping;
 
-/* Set currency field separator */
-static BOOL
-SetCurrencyFieldSep(HWND hwndDlg, PWSTR pszCurrThousandSep)
-{
-    /* Get setted currency field separator */
-    SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPSEP,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_CURRTHOUSANDSEP,
-                        (LPARAM)pszCurrThousandSep);
+    /* Currency symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_CURRENCYSYMBOL,
+                            szCurrSymbol,
+                            MAX_SAMPLES_STR_SIZE);
 
-    return TRUE;
-}
+    if (szCurrSymbol[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-/* Set number of fractional symbols */
-static BOOL
-SetCurrencyFracSymNum(HWND hwndDlg, PINT pnCurrDigits)
-{
-    INT nCurrSel;
-
-    /* Get setted number of fractional symbols */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECNUM,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
         return FALSE;
+    }
 
-    *pnCurrDigits = nCurrSel;
-
-    return TRUE;
-}
-
-/* Set currency separator */
-static BOOL
-SetCurrencySep(HWND hwndDlg, PWSTR pszCurrDecimalSep)
-{
-    /* Get setted currency decimal separator */
-    SendDlgItemMessageW(hwndDlg, IDC_CURRENCYDECSEP,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_CURRDECIMALSEP,
-                        (LPARAM)pszCurrDecimalSep);
+    /* Positive Amount */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_CURRENCYPOSVALUE,
+                             &nCurrPosFormat);
 
-    return TRUE;
-}
+    /* Negative Amount */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_CURRENCYNEGVALUE,
+                             &nCurrNegFormat);
 
-/* Set negative currency sum format */
-static BOOL
-SetNegCurrencySumFmt(HWND hwndDlg, PINT pnCurrNegFormat)
-{
-    INT nCurrSel;
-
-    /* Get setted currency unit */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_CURRENCYNEGVALUE,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
-        return FALSE;
-
-    *pnCurrNegFormat = nCurrSel;
+    /* Decimal separator */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_CURRENCYDECSEP,
+                            szCurrDecimalSep,
+                            MAX_SAMPLES_STR_SIZE);
 
-    return TRUE;
-}
+    if (szCurrDecimalSep[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-/* Set positive currency sum format */
-static BOOL
-SetPosCurrencySumFmt(HWND hwndDlg, PINT pnCurrPosFormat)
-{
-    INT nCurrSel;
-
-    /* Get setted currency unit */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_CURRENCYPOSVALUE,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
         return FALSE;
+    }
 
-    *pnCurrPosFormat = nCurrSel;
-
-    return TRUE;
-}
-
-/* Set currency symbol */
-static BOOL
-SetCurrencySymbol(HWND hwndDlg, PWSTR pszCurrSymbol)
-{
-    /* Get setted currency unit */
-    SendDlgItemMessageW(hwndDlg, IDC_CURRENCYSYMBOL,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_CURRSYMBOL,
-                        (LPARAM)pszCurrSymbol);
-
-    return TRUE;
-}
-
+    /* Number of fractional digits */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_CURRENCYDECNUM,
+                             &nCurrDigits);
 
-static BOOL
-SetCurrencySetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
-{
-    WCHAR szCurrSymbol[MAX_CURRSYMBOL];
-    WCHAR szCurrDecimalSep[MAX_CURRDECIMALSEP];
-    WCHAR szCurrThousandSep[MAX_CURRTHOUSANDSEP];
-    INT nCurrGrouping;
-    INT nCurrPosFormat;
-    INT nCurrNegFormat;
-    INT nCurrDigits;
+    /* Grouping symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_CURRENCYGRPSEP,
+                            szCurrThousandSep,
+                            MAX_SAMPLES_STR_SIZE);
 
-    if (!SetCurrencySymbol(hwndDlg, szCurrSymbol) ||
-        !SetCurrencyDigNum(hwndDlg, &nCurrGrouping) ||
-        !SetPosCurrencySumFmt(hwndDlg, &nCurrPosFormat) ||
-        !SetNegCurrencySumFmt(hwndDlg, &nCurrNegFormat) ||
-        !SetCurrencySep(hwndDlg, szCurrDecimalSep) ||
-        !SetCurrencyFracSymNum(hwndDlg, &nCurrDigits) ||
-        !SetCurrencyFieldSep(hwndDlg, szCurrThousandSep))
+    if (szCurrThousandSep[0] == L'\0')
     {
+        /* TODO: Show error message */
+
         return FALSE;
     }
 
-    /* store to global data */
+    /* Digit grouping */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_CURRENCYGRPNUM,
+                             &nCurrGrouping);
+
+    /* Store settings in global data */
     wcscpy(pGlobalData->szCurrSymbol, szCurrSymbol);
     pGlobalData->nCurrGrouping = nCurrGrouping;
     wcscpy(pGlobalData->szCurrDecimalSep, szCurrDecimalSep);
@@ -448,7 +383,8 @@ CurrencyPageProc(HWND hwndDlg,
                 case IDC_CURRENCYDECNUM:
                 case IDC_CURRENCYGRPSEP:
                 case IDC_CURRENCYGRPNUM:
-                    if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
+                    if (HIWORD(wParam) == CBN_SELCHANGE ||
+                        HIWORD(wParam) == CBN_EDITCHANGE)
                     {
                         /* Enable the Apply button */
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
@@ -459,7 +395,7 @@ CurrencyPageProc(HWND hwndDlg,
         case WM_NOTIFY:
             if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
             {
-                if (SetCurrencySetting(hwndDlg, pGlobalData))
+                if (GetCurrencySetting(hwndDlg, pGlobalData))
                 {
                     pGlobalData->bUserLocaleChanged = TRUE;
                     UpdateExamples(hwndDlg, pGlobalData);
index 90d4ea5..91fd09e 100644 (file)
@@ -162,7 +162,6 @@ SetShortDateFormat(HWND hwndDlg, PWSTR pszShortDateFmt)
             PrintErrorMsgBox(IDS_ERROR_SYMBOL_FORMAT_SHORT);
             return FALSE;
         }
-
     }
 
     if (OpenApostFlg || nFmtStrSize == 0)
@@ -221,7 +220,6 @@ SetLongDateFormat(HWND hwndDlg, PWSTR pszLongDateFmt)
             PrintErrorMsgBox(IDS_ERROR_SYMBOL_FORMAT_LONG);
             return FALSE;
         }
-
     }
 
     if (OpenApostFlg || nFmtStrSize == 0)
@@ -515,24 +513,28 @@ UpdateDateLocaleSamples(HWND hwndDlg,
                         WM_SETTEXT, 0, (LPARAM)OutBuffer);
 }
 
-static BOOL
-SetDateSetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
+
+static
+BOOL
+GetDateSetting(
+    HWND hwndDlg,
+    PGLOBALDATA pGlobalData)
 {
-    WCHAR szLongDateFmt[MAX_SAMPLES_STR_SIZE];
-    WCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE];
-    WCHAR szShortDateSep[MAX_SAMPLES_STR_SIZE];
+    WCHAR szLongDateFormat[MAX_SAMPLES_STR_SIZE];
+    WCHAR szShortDateFormat[MAX_SAMPLES_STR_SIZE];
+    WCHAR szDateSeparator[MAX_SAMPLES_STR_SIZE];
 
-    if (!SetLongDateFormat(hwndDlg, szLongDateFmt) ||
-        !SetShortDateFormat(hwndDlg, szShortDateFmt) ||
-        !SetShortDateSep(hwndDlg, szShortDateSep))
+    if (!SetLongDateFormat(hwndDlg, szLongDateFormat) ||
+        !SetShortDateFormat(hwndDlg, szShortDateFormat) ||
+        !SetShortDateSep(hwndDlg, szDateSeparator))
     {
         return FALSE;
     }
 
-    /* store to global data */
-    wcscpy(pGlobalData->szLongDateFormat, szLongDateFmt);
-    wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
-    wcscpy(pGlobalData->szDateSep, szShortDateSep);
+    /* Store settings in global data */
+    wcscpy(pGlobalData->szLongDateFormat, szLongDateFormat);
+    wcscpy(pGlobalData->szShortDateFormat, szShortDateFormat);
+    wcscpy(pGlobalData->szDateSep, szDateSeparator);
 
     return TRUE;
 }
@@ -560,22 +562,22 @@ DatePageProc(HWND hwndDlg,
             InitLongDateCB(hwndDlg, pGlobalData);
             InitShortDateSepSamples(hwndDlg, pGlobalData);
             /* TODO: Add other calendar types */
+            pGlobalData->bEnableYearNotification = TRUE;
             break;
 
         case WM_COMMAND:
             switch (LOWORD(wParam))
             {
                 case IDC_SECONDYEAR_EDIT:
-                    if (HIWORD(wParam) == EN_CHANGE)
+                    if (HIWORD(wParam) == EN_CHANGE &&
+                        pGlobalData != NULL &&
+                        pGlobalData->bEnableYearNotification == TRUE)
                     {
                         SetMinDate(hwndDlg);
-                    }
-                    break;
 
-                case IDC_SCR_MAX_YEAR:
-                    /* Set "Apply" button enabled */
-                    /* FIXME */
-                    //PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+                        /* Enable the Apply button */
+                        PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
+                    }
                     break;
 
                 case IDC_CALTYPE_COMBO:
@@ -583,7 +585,8 @@ DatePageProc(HWND hwndDlg,
                 case IDC_SHRTDATEFMT_COMBO:
                 case IDC_LONGDATEFMT_COMBO:
                 case IDC_SHRTDATESEP_COMBO:
-                    if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
+                    if (HIWORD(wParam) == CBN_SELCHANGE ||
+                        HIWORD(wParam) == CBN_EDITCHANGE)
                     {
                         /* Enable the Apply button */
                         PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
@@ -595,7 +598,7 @@ DatePageProc(HWND hwndDlg,
         case WM_NOTIFY:
             if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
             {
-                if (SetDateSetting(hwndDlg, pGlobalData))
+                if (GetDateSetting(hwndDlg, pGlobalData))
                 {
                     pGlobalData->bUserLocaleChanged = TRUE;
                     SetMaxDate(hwndDlg, pGlobalData->UserLCID);
index 1a039f8..46fbb65 100644 (file)
@@ -61,13 +61,15 @@ typedef struct _APPLET
 
 typedef struct _GLOBALDATA
 {
+    /* General */
+    WCHAR szNumPositiveSign[MAX_NUMPOSITIVESIGN];
+    WCHAR szNumNativeDigits[MAX_NUMNATIVEDIGITS];
+
     /* 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;
@@ -101,6 +103,7 @@ typedef struct _GLOBALDATA
     INT nFirstWeekOfYear;
     INT nDate;
     INT nCalendarType;
+    BOOL bEnableYearNotification;
 
     /* Other */
     WCHAR szMiscCountry[MAX_MISCCOUNTRY];
@@ -191,6 +194,19 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr);
 PWSTR
 ReplaceSubStr(PCWSTR szSourceStr, PCWSTR szStrToReplace, PCWSTR szTempl);
 
+VOID
+GetSelectedComboBoxText(
+    HWND hwndDlg,
+    INT nIdDlgItem,
+    PWSTR Buffer,
+    UINT uSize);
+
+VOID
+GetSelectedComboBoxIndex(
+    HWND hwndDlg,
+    INT nIdDlgItem,
+    PINT pValue);
+
 /* kblayouts.c */
 VOID AddNewKbLayoutsByLcid(LCID Lcid);
 
index e05d75c..0967fd6 100644 (file)
@@ -171,4 +171,61 @@ ReplaceSubStr(PCWSTR szSourceStr,
     return szDestStr;
 }
 
+
+VOID
+GetSelectedComboBoxText(
+    HWND hwndDlg,
+    INT nIdDlgItem,
+    PWSTR Buffer,
+    UINT uSize)
+{
+    HWND hChildWnd;
+    PWSTR tmp;
+    INT nIndex;
+    UINT uReqSize;
+
+    /* Get handle to time format control */
+    hChildWnd = GetDlgItem(hwndDlg, nIdDlgItem);
+    if (hChildWnd == NULL)
+        return;
+
+    /* Get index to selected time format */
+    nIndex = SendMessageW(hChildWnd, CB_GETCURSEL, 0, 0);
+    if (nIndex == CB_ERR)
+    {
+        /* No selection? Get content of the edit control */
+        SendMessageW(hChildWnd, WM_GETTEXT, uSize, (LPARAM)Buffer);
+    }
+    else
+    {
+        /* Get requested size, including the null terminator;
+         * it shouldn't be required because the previous CB_LIMITTEXT,
+         * but it would be better to check it anyways */
+        uReqSize = SendMessageW(hChildWnd, CB_GETLBTEXTLEN, (WPARAM)nIndex, 0) + 1;
+
+        /* Allocate enough space to be more safe */
+        tmp = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uReqSize * sizeof(WCHAR));
+        if (tmp != NULL)
+        {
+            /* Get selected time format text */
+            SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
+
+            /* Finally, copy the result into the output */
+            wcsncpy(Buffer, tmp, uSize);
+
+            HeapFree(GetProcessHeap(), 0, tmp);
+        }
+    }
+}
+
+
+VOID
+GetSelectedComboBoxIndex(
+    HWND hwndDlg,
+    INT nIdDlgItem,
+    PINT pValue)
+{
+    *pValue = SendDlgItemMessageW(hwndDlg, nIdDlgItem, CB_GETCURSEL, 0, 0);
+}
+
 /* EOF */
index 3640d63..dfc5c14 100644 (file)
@@ -469,195 +469,105 @@ UpdateNumSamples(HWND hwndDlg,
                         (LPARAM)OutBuffer);
 }
 
-/* Set num decimal separator */
-static BOOL
-SetNumDecimalSep(HWND hwndDlg,
-                 PWSTR pszNumDecimalSep)
-{
-    /* Get setted decimal separator */
-    SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_NUMDECIMALSEP,
-                        (LPARAM)pszNumDecimalSep);
-
-    return TRUE;
-}
 
-/* Set number of fractional symbols */
-static BOOL
-SetFracSymNum(HWND hwndDlg,
-              PINT pnNumDigits)
+static
+BOOL
+GetNumberSetting(
+    HWND hwndDlg,
+    PGLOBALDATA pGlobalData)
 {
-    INT nCurrSel;
-
-    /* Get setted number of fractional symbols */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNDIGDEC,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
-        return FALSE;
-
-    *pnNumDigits = nCurrSel;
-
-    return TRUE;
-}
-
-/* Set field separator */
-static BOOL
-SetNumFieldSep(HWND hwndDlg,
-               PWSTR pszNumThousandSep)
-{
-    /* Get thousand separator */
-    SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_NUMTHOUSANDSEP,
-                        (LPARAM)pszNumThousandSep);
-
-    return TRUE;
-}
+    WCHAR szNumDecimalSep[MAX_NUMDECIMALSEP];
+    WCHAR szNumThousandSep[MAX_NUMTHOUSANDSEP];
+    WCHAR szNumNegativeSign[MAX_NUMNEGATIVESIGN];
+    WCHAR szNumListSep[MAX_NUMLISTSEP];
+    INT nNumDigits;
+    INT nNumGrouping;
+    INT nNumNegFormat;
+    INT nNumLeadingZero;
+    INT nNumMeasure;
+
+    /* Decimal symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_NUMBERDSYMBOL,
+                            szNumDecimalSep,
+                            MAX_NUMDECIMALSEP);
+
+    if (szNumDecimalSep[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-/* Set number of digits in field */
-static BOOL
-SetFieldDigNum(HWND hwndDlg,
-               PINT pnNumGrouping)
-{
-    INT nCurrSel;
-
-    /* Get setted negative sum format */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
         return FALSE;
+    }
 
-    *pnNumGrouping = nCurrSel;
-
-    return TRUE;
-}
-
-/* Set negative sign */
-static BOOL
-SetNumNegSign(HWND hwndDlg,
-              PWSTR pszNumNegativeSign)
-{
-    /* Get setted negative sign */
-    SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_NUMNEGATIVESIGN,
-                        (LPARAM)pszNumNegativeSign);
-
-    return TRUE;
-}
-
-/* Set negative sum format */
-static BOOL
-SetNegSumFmt(HWND hwndDlg,
-             PINT pnNumNegFormat)
-{
-    INT nCurrSel;
-
-    /* Get setted negative sum format */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
-        return FALSE;
+    /* Number of digits after decimal */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_NUMBERSNDIGDEC,
+                             &nNumDigits);
 
-    *pnNumNegFormat = nCurrSel;
+    /* Digit grouping symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_NUMBERSDIGITGRSYM,
+                            szNumThousandSep,
+                            MAX_NUMTHOUSANDSEP);
 
-    return TRUE;
-}
+    if (szNumThousandSep[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-/* Set leading zero */
-static BOOL
-SetNumLeadZero(HWND hwndDlg,
-               PINT pnNumLeadingZero)
-{
-    INT nCurrSel;
-
-    /* Get setted leading zero format */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDISPLEADZER,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
         return FALSE;
+    }
 
-    *pnNumLeadingZero = nCurrSel;
+    /* Digit grouping */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_NUMBERSDGROUPING,
+                             &nNumGrouping);
 
-    return TRUE;
-}
-
-/* Set elements list separator */
-static BOOL
-SetNumListSep(HWND hwndDlg,
-              PWSTR pszNumListSep)
-{
-    /* Get setted list separator */
-    SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
-                        WM_GETTEXT,
-                        (WPARAM)MAX_NUMLISTSEP,
-                        (LPARAM)pszNumListSep);
+    /* Negative sign symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_NUMBERSNSIGNSYM,
+                            szNumNegativeSign,
+                            MAX_NUMNEGATIVESIGN);
 
-    return TRUE;
-}
+    if (szNumNegativeSign[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-/* Set units system */
-static BOOL
-SetNumUnitsSys(HWND hwndDlg,
-               PINT pnNumMeasure)
-{
-    INT nCurrSel;
-
-    /* Get setted units system */
-    nCurrSel = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSMEASSYS,
-                                   CB_GETCURSEL,
-                                   (WPARAM)0,
-                                   (LPARAM)0);
-    if (nCurrSel == CB_ERR)
         return FALSE;
+    }
 
-    *pnNumMeasure = nCurrSel;
+    /* Negative number format */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_NUMBERSNNUMFORMAT,
+                             &nNumNegFormat);
 
-    return TRUE;
-}
+    /* Display leading zeros */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_NUMBERSDISPLEADZER,
+                             &nNumLeadingZero);
 
-static BOOL
-SetNumberSetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
-{
-    WCHAR szNumDecimalSep[MAX_NUMDECIMALSEP];
-    WCHAR szNumThousandSep[MAX_NUMTHOUSANDSEP];
-    WCHAR szNumNegativeSign[MAX_NUMNEGATIVESIGN];
-    WCHAR szNumListSep[MAX_NUMLISTSEP];
-    WCHAR szNumNativeDigits[MAX_NUMNATIVEDIGITS];
-    int nNumGrouping;
-    int nNumDigits;
-    int nNumNegFormat;
-    int nNumLeadingZero;
-    int nNumMeasure;
-
-    if (!SetNumDecimalSep(hwndDlg, szNumDecimalSep) ||
-        !SetNumFieldSep(hwndDlg, szNumThousandSep) ||
-        !SetNumNegSign(hwndDlg, szNumNegativeSign) ||
-        !SetNumListSep(hwndDlg, szNumListSep) ||
-        !SetFieldDigNum(hwndDlg, &nNumGrouping) ||
-        !SetFracSymNum(hwndDlg, &nNumDigits) ||
-        !SetNegSumFmt(hwndDlg, &nNumNegFormat) ||
-        !SetNumLeadZero(hwndDlg, &nNumLeadingZero) ||
-        !SetNumUnitsSys(hwndDlg, &nNumMeasure))
+    /* List separator */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_NUMBERSLSEP,
+                            szNumListSep,
+                            MAX_NUMLISTSEP);
+
+    if (szNumListSep[0] == L'\0')
     {
+        /* TODO: Show error message */
+
         return FALSE;
     }
 
-    /* store to global data */
+    /* Measurement system */
+    GetSelectedComboBoxIndex(hwndDlg,
+                             IDC_NUMBERSMEASSYS,
+                             &nNumMeasure);
+
+    /* Store settings in global data */
     wcscpy(pGlobalData->szNumDecimalSep, szNumDecimalSep);
     wcscpy(pGlobalData->szNumThousandSep, szNumThousandSep);
     wcscpy(pGlobalData->szNumNegativeSign, szNumNegativeSign);
     wcscpy(pGlobalData->szNumListSep, szNumListSep);
-    wcscpy(pGlobalData->szNumNativeDigits, szNumNativeDigits);
     pGlobalData->nNumGrouping = nNumGrouping;
     pGlobalData->nNumDigits = nNumDigits;
     pGlobalData->nNumNegFormat = nNumNegFormat;
@@ -717,10 +627,9 @@ NumbersPageProc(HWND hwndDlg,
             break;
 
         case WM_NOTIFY:
-            /* If push apply button */
             if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
             {
-                if (SetNumberSetting(hwndDlg, pGlobalData))
+                if (GetNumberSetting(hwndDlg, pGlobalData))
                 {
                     pGlobalData->bUserLocaleChanged = TRUE;
                     UpdateNumSamples(hwndDlg, pGlobalData);
index 8fe9ae2..b416cec 100644 (file)
@@ -51,47 +51,6 @@ UpdateTimeSample(HWND hWnd, PGLOBALDATA pGlobalData)
 }
 
 
-static VOID
-GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
-{
-    HWND hChildWnd;
-    PWSTR tmp;
-    INT nIndex;
-    UINT uReqSize;
-
-    /* Get handle to time format control */
-    hChildWnd = GetDlgItem(hwndDlg, dwIdc);
-
-    /* Get index to selected time format */
-    nIndex = SendMessageW(hChildWnd, CB_GETCURSEL, 0, 0);
-    if (nIndex == CB_ERR)
-    {
-        /* No selection? Get content of the edit control */
-        SendMessageW(hChildWnd, WM_GETTEXT, uSize, (LPARAM)Buffer);
-    }
-    else
-    {
-        /* Get requested size, including the null terminator;
-         * it shouldn't be required because the previous CB_LIMITTEXT,
-         * but it would be better to check it anyways */
-        uReqSize = SendMessageW(hChildWnd, CB_GETLBTEXTLEN, (WPARAM)nIndex, 0) + 1;
-
-        /* Allocate enough space to be more safe */
-        tmp = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uReqSize * sizeof(WCHAR));
-        if (tmp != NULL)
-        {
-            /* Get selected time format text */
-            SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
-
-            /* Finally, copy the result into the output */
-            wcsncpy(Buffer, tmp, uSize);
-
-            HeapFree(GetProcessHeap(), 0, tmp);
-        }
-    }
-}
-
-
 static
 VOID
 InitTimeFormatCB(
@@ -195,31 +154,59 @@ InitPmSymbol(
                         0);
 }
 
-static BOOL
-SetTimeSetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
+
+static
+BOOL
+GetTimeSetting(
+    HWND hwndDlg,
+    PGLOBALDATA pGlobalData)
 {
     WCHAR szTimeFormat[MAX_TIMEFORMAT];
     WCHAR szTimeSep[MAX_TIMEFORMAT];
     WCHAR szTimeAM[MAX_TIMEFORMAT];
     WCHAR szTimePM[MAX_TIMEFORMAT];
 
-    /* Get selected/typed time format text */
-    GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT, szTimeFormat, MAX_TIMEFORMAT);
+    /* Time format */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_TIMEFORMAT,
+                            szTimeFormat,
+                            MAX_TIMEFORMAT);
 
-    /* Get selected/typed time separator text */
-    GetSelectedComboEntry(hwndDlg, IDC_TIMESEPARATOR, szTimeSep, MAX_TIMESEPARATOR);
+    /* Check the time format */
+    if (szTimeFormat[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-    /* Get selected/typed AM symbol text */
-    GetSelectedComboEntry(hwndDlg, IDC_TIMEAMSYMBOL, szTimeAM, MAX_TIMEAMSYMBOL);
+        return FALSE;
+    }
 
-    /* Get selected/typed PM symbol text */
-    GetSelectedComboEntry(hwndDlg, IDC_TIMEPMSYMBOL, szTimePM, MAX_TIMEPMSYMBOL);
+    /* Time separator */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_TIMESEPARATOR,
+                            szTimeSep,
+                            MAX_TIMESEPARATOR);
+
+    /* Check the time separator */
+    if (szTimeSep[0] == L'\0')
+    {
+        /* TODO: Show error message */
 
-    /* verify values */
-    if (szTimeFormat[0] == L'\0' || szTimeSep[0] == L'\0')
         return FALSE;
+    }
+
+    /* AM symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_TIMEAMSYMBOL,
+                            szTimeAM,
+                            MAX_TIMEAMSYMBOL);
+
+    /* PM symbol */
+    GetSelectedComboBoxText(hwndDlg,
+                            IDC_TIMEPMSYMBOL,
+                            szTimePM,
+                            MAX_TIMEPMSYMBOL);
 
-    /* store to global data */
+    /* Store settings in global data */
     wcscpy(pGlobalData->szTimeFormat, szTimeFormat);
     wcscpy(pGlobalData->szTimeSep, szTimeSep);
     wcscpy(pGlobalData->szTimeAM, szTimeAM);
@@ -281,7 +268,7 @@ TimePageProc(HWND hwndDlg,
         case WM_NOTIFY:
             if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
             {
-                if (SetTimeSetting(hwndDlg, pGlobalData))
+                if (GetTimeSetting(hwndDlg, pGlobalData))
                 {
                     pGlobalData->bUserLocaleChanged = TRUE;
                     UpdateTimeSample(hwndDlg, pGlobalData);