Update number and currency examples according to the current settings.
CORE-10074 #resolve

svn path=/trunk/; revision=69501
This commit is contained in:
Eric Kohl 2015-10-11 18:36:22 +00:00
parent 5e05f2675b
commit bc538be477
4 changed files with 74 additions and 50 deletions

View file

@ -33,18 +33,28 @@ static VOID
UpdateExamples(HWND hwndDlg, PGLOBALDATA pGlobalData) UpdateExamples(HWND hwndDlg, PGLOBALDATA pGlobalData)
{ {
WCHAR szBuffer[MAX_FMT_SIZE]; WCHAR szBuffer[MAX_FMT_SIZE];
CURRENCYFMTW CurrencyFormat;
CurrencyFormat.NumDigits = pGlobalData->nCurrDigits;
CurrencyFormat.LeadingZero = pGlobalData->nNumLeadingZero;
CurrencyFormat.Grouping = GroupingFormats[pGlobalData->nCurrGrouping].nInteger;
CurrencyFormat.lpDecimalSep = pGlobalData->szCurrDecimalSep;
CurrencyFormat.lpThousandSep = pGlobalData->szCurrThousandSep;
CurrencyFormat.NegativeOrder = pGlobalData->nCurrNegFormat;
CurrencyFormat.PositiveOrder = pGlobalData->nCurrPosFormat;
CurrencyFormat.lpCurrencySymbol = pGlobalData->szCurrSymbol;
/* Positive example */ /* Positive example */
GetCurrencyFormatW(pGlobalData->UserLCID, 0, GetCurrencyFormatW(pGlobalData->UserLCID, 0,
POSITIVE_EXAMPLE, POSITIVE_EXAMPLE,
NULL, szBuffer, MAX_FMT_SIZE); &CurrencyFormat, szBuffer, MAX_FMT_SIZE);
SendDlgItemMessageW(hwndDlg, IDC_CURRENCYPOSSAMPLE, WM_SETTEXT, 0, (LPARAM)szBuffer); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYPOSSAMPLE, WM_SETTEXT, 0, (LPARAM)szBuffer);
/* Negative example */ /* Negative example */
GetCurrencyFormatW(pGlobalData->UserLCID, 0, GetCurrencyFormatW(pGlobalData->UserLCID, 0,
NEGATIVE_EXAMPLE, NEGATIVE_EXAMPLE,
NULL, szBuffer, MAX_FMT_SIZE); &CurrencyFormat, szBuffer, MAX_FMT_SIZE);
SendDlgItemMessageW(hwndDlg, IDC_CURRENCYNEGSAMPLE, WM_SETTEXT, 0, (LPARAM)szBuffer); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYNEGSAMPLE, WM_SETTEXT, 0, (LPARAM)szBuffer);
} }
@ -219,6 +229,7 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
{ {
WCHAR szBuffer[MAX_FMT_SIZE]; WCHAR szBuffer[MAX_FMT_SIZE];
CURRENCYFMTW cyFmt; CURRENCYFMTW cyFmt;
INT i;
/* Digit grouping */ /* Digit grouping */
cyFmt.NumDigits = 0; cyFmt.NumDigits = 0;
@ -228,37 +239,19 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
cyFmt.PositiveOrder = 0; cyFmt.PositiveOrder = 0;
cyFmt.NegativeOrder = 0; cyFmt.NegativeOrder = 0;
cyFmt.lpCurrencySymbol = L""; cyFmt.lpCurrencySymbol = L"";
cyFmt.Grouping = 0;
GetCurrencyFormatW(pGlobalData->UserLCID, 0,
L"123456789",
&cyFmt, szBuffer, MAX_FMT_SIZE);
SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM,
CB_INSERTSTRING,
-1,
(LPARAM)szBuffer);
cyFmt.Grouping = 3; for (i = 0 ; i < MAX_GROUPINGFORMATS ; i++)
GetCurrencyFormatW(pGlobalData->UserLCID, 0, {
L"123456789", cyFmt.Grouping = GroupingFormats[i].nInteger;
&cyFmt, szBuffer, MAX_FMT_SIZE);
SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM,
CB_INSERTSTRING,
-1,
(LPARAM)szBuffer);
cyFmt.Grouping = 32; GetCurrencyFormatW(pGlobalData->UserLCID, 0,
GetCurrencyFormatW(pGlobalData->UserLCID, 0, L"123456789",
L"123456789", &cyFmt, szBuffer, MAX_FMT_SIZE);
&cyFmt, szBuffer, MAX_FMT_SIZE); SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM,
SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM, CB_INSERTSTRING,
CB_INSERTSTRING, -1,
-1, (LPARAM)szBuffer);
(LPARAM)szBuffer); }
SendDlgItemMessageW(hwndDlg, IDC_CURRENCYGRPNUM,
CB_SETCURSEL,
pGlobalData->nCurrGrouping, /* Index */
0);
} }

View file

@ -30,28 +30,22 @@
#include <debug.h> #include <debug.h>
#define SAMPLE_NUMBER L"123456789" #define SAMPLE_NUMBER L"123456789"
#define NO_FLAG 0
#define NUM_SHEETS 4 #define NUM_SHEETS 4
#define MAX_FIELD_DIG_SAMPLES 3 #define MAX_FIELD_DIG_SAMPLES 3
typedef struct
{
LCTYPE lcType;
PWSTR pKeyName;
} LOCALE_KEY_DATA, *PLOCALE_KEY_DATA;
HWND hList; HWND hList;
HWND hLocaleList, hGeoList; HWND hLocaleList, hGeoList;
BOOL bSpain = FALSE; BOOL bSpain = FALSE;
GROUPINGDATA
PWSTR szCurrencyGrouping[3] = GroupingFormats[MAX_GROUPINGFORMATS] =
{ {
L"0;0", {0, L"0;0"},
L"3;0", {3, L"3;0"},
L"3;2;0" {32, L"3;2;0"}
}; };
static BOOL CALLBACK static BOOL CALLBACK
@ -111,16 +105,36 @@ UpdateLocaleSample(
PGLOBALDATA pGlobalData) PGLOBALDATA pGlobalData)
{ {
WCHAR OutBuffer[MAX_SAMPLES_STR_SIZE]; WCHAR OutBuffer[MAX_SAMPLES_STR_SIZE];
NUMBERFMT NumberFormat;
CURRENCYFMTW CurrencyFormat;
NumberFormat.NumDigits = pGlobalData->nNumDigits;
NumberFormat.LeadingZero = pGlobalData->nNumLeadingZero;
NumberFormat.Grouping = GroupingFormats[pGlobalData->nNumGrouping].nInteger;
NumberFormat.lpDecimalSep = pGlobalData->szNumDecimalSep;
NumberFormat.lpThousandSep = pGlobalData->szNumThousandSep;
NumberFormat.NegativeOrder = pGlobalData->nNumNegFormat;
CurrencyFormat.NumDigits = pGlobalData->nCurrDigits;
CurrencyFormat.LeadingZero = pGlobalData->nNumLeadingZero;
CurrencyFormat.Grouping = GroupingFormats[pGlobalData->nCurrGrouping].nInteger;
CurrencyFormat.lpDecimalSep = pGlobalData->szCurrDecimalSep;
CurrencyFormat.lpThousandSep = pGlobalData->szCurrThousandSep;
CurrencyFormat.NegativeOrder = pGlobalData->nCurrNegFormat;
CurrencyFormat.PositiveOrder = pGlobalData->nCurrPosFormat;
CurrencyFormat.lpCurrencySymbol = pGlobalData->szCurrSymbol;
/* Get number format sample */ /* Get number format sample */
GetNumberFormatW(pGlobalData->UserLCID, NO_FLAG, SAMPLE_NUMBER, NULL, GetNumberFormatW(pGlobalData->UserLCID, 0, SAMPLE_NUMBER,
&NumberFormat,
OutBuffer, MAX_SAMPLES_STR_SIZE); OutBuffer, MAX_SAMPLES_STR_SIZE);
SendDlgItemMessageW(hwndDlg, IDC_NUMSAMPLE_EDIT, SendDlgItemMessageW(hwndDlg, IDC_NUMSAMPLE_EDIT,
WM_SETTEXT, 0, (LPARAM)OutBuffer); WM_SETTEXT, 0, (LPARAM)OutBuffer);
ZeroMemory(OutBuffer, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR)); ZeroMemory(OutBuffer, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
/* Get monetary format sample */ /* Get monetary format sample */
GetCurrencyFormatW(pGlobalData->UserLCID, NO_FLAG, SAMPLE_NUMBER, NULL, GetCurrencyFormatW(pGlobalData->UserLCID, 0, SAMPLE_NUMBER,
&CurrencyFormat,
OutBuffer, MAX_SAMPLES_STR_SIZE); OutBuffer, MAX_SAMPLES_STR_SIZE);
SendDlgItemMessageW(hwndDlg, IDC_MONEYSAMPLE_EDIT, SendDlgItemMessageW(hwndDlg, IDC_MONEYSAMPLE_EDIT,
WM_SETTEXT, 0, (LPARAM)OutBuffer); WM_SETTEXT, 0, (LPARAM)OutBuffer);
@ -833,8 +847,8 @@ SaveUserLocale(
L"sGrouping", L"sGrouping",
0, 0,
REG_SZ, REG_SZ,
(PBYTE)szCurrencyGrouping[pGlobalData->nNumGrouping], (PBYTE)GroupingFormats[pGlobalData->nNumGrouping].pszString,
(wcslen(szCurrencyGrouping[pGlobalData->nNumGrouping]) + 1) * sizeof(WCHAR)); (wcslen(GroupingFormats[pGlobalData->nNumGrouping].pszString) + 1) * sizeof(WCHAR));
RegSetValueExW(hLocaleKey, RegSetValueExW(hLocaleKey,
L"sList", L"sList",
@ -921,8 +935,8 @@ SaveUserLocale(
L"sMonGrouping", L"sMonGrouping",
0, 0,
REG_SZ, REG_SZ,
(PBYTE)szCurrencyGrouping[pGlobalData->nCurrGrouping], (PBYTE)GroupingFormats[pGlobalData->nCurrGrouping].pszString,
(wcslen(szCurrencyGrouping[pGlobalData->nCurrGrouping]) + 1) * sizeof(WCHAR)); (wcslen(GroupingFormats[pGlobalData->nCurrGrouping].pszString) + 1) * sizeof(WCHAR));
_itow(pGlobalData->nCurrPosFormat, _itow(pGlobalData->nCurrPosFormat,
szBuffer, DECIMAL_RADIX); szBuffer, DECIMAL_RADIX);

View file

@ -49,6 +49,8 @@
#define MAX_MISCCOUNTRY 80 #define MAX_MISCCOUNTRY 80
#define MAX_MISCLANGUAGE 80 #define MAX_MISCLANGUAGE 80
#define MAX_GROUPINGFORMATS 3
typedef struct _APPLET typedef struct _APPLET
{ {
@ -116,9 +118,16 @@ typedef struct _GLOBALDATA
} GLOBALDATA, *PGLOBALDATA; } GLOBALDATA, *PGLOBALDATA;
typedef struct
{
UINT nInteger;
PWSTR pszString;
} GROUPINGDATA;
extern HINSTANCE hApplet; extern HINSTANCE hApplet;
extern DWORD IsUnattendedSetupEnabled; extern DWORD IsUnattendedSetupEnabled;
extern DWORD UnattendLCID; extern DWORD UnattendLCID;
extern GROUPINGDATA GroupingFormats[MAX_GROUPINGFORMATS];
/* intl.c */ /* intl.c */
VOID PrintErrorMsgBox(UINT msg); VOID PrintErrorMsgBox(UINT msg);

View file

@ -420,12 +420,20 @@ UpdateNumSamples(HWND hwndDlg,
PGLOBALDATA pGlobalData) PGLOBALDATA pGlobalData)
{ {
WCHAR OutBuffer[MAX_FMT_SIZE]; WCHAR OutBuffer[MAX_FMT_SIZE];
NUMBERFMT NumberFormat;
NumberFormat.NumDigits = pGlobalData->nNumDigits;
NumberFormat.LeadingZero = pGlobalData->nNumLeadingZero;
NumberFormat.Grouping = GroupingFormats[pGlobalData->nNumGrouping].nInteger;
NumberFormat.lpDecimalSep = pGlobalData->szNumDecimalSep;
NumberFormat.lpThousandSep = pGlobalData->szNumThousandSep;
NumberFormat.NegativeOrder = pGlobalData->nNumNegFormat;
/* Get positive number format sample */ /* Get positive number format sample */
GetNumberFormatW(pGlobalData->UserLCID, GetNumberFormatW(pGlobalData->UserLCID,
0, 0,
SAMPLE_NUMBER, SAMPLE_NUMBER,
NULL, &NumberFormat,
OutBuffer, OutBuffer,
MAX_FMT_SIZE); MAX_FMT_SIZE);
@ -438,7 +446,7 @@ UpdateNumSamples(HWND hwndDlg,
GetNumberFormatW(pGlobalData->UserLCID, GetNumberFormatW(pGlobalData->UserLCID,
0, 0,
SAMPLE_NEG_NUMBER, SAMPLE_NEG_NUMBER,
NULL, &NumberFormat,
OutBuffer, OutBuffer,
MAX_FMT_SIZE); MAX_FMT_SIZE);