- 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
This commit is contained in:
Eric Kohl 2017-05-06 14:41:50 +00:00
parent 3ac350cfe0
commit d4b437e4ee
6 changed files with 296 additions and 388 deletions

View file

@ -261,145 +261,80 @@ InitDigitGroupCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
}
/* Set number of digits in field */
static BOOL
SetCurrencyDigNum(HWND hwndDlg, PINT pnCurrGrouping)
{
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;
}
/* 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);
return TRUE;
}
/* 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);
return TRUE;
}
/* 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;
return TRUE;
}
/* 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;
}
static BOOL
SetCurrencySetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
static
BOOL
GetCurrencySetting(
HWND hwndDlg,
PGLOBALDATA pGlobalData)
{
WCHAR szCurrSymbol[MAX_CURRSYMBOL];
WCHAR szCurrDecimalSep[MAX_CURRDECIMALSEP];
WCHAR szCurrThousandSep[MAX_CURRTHOUSANDSEP];
INT nCurrGrouping;
INT nCurrPosFormat;
INT nCurrNegFormat;
INT nCurrDigits;
INT nCurrGrouping;
if (!SetCurrencySymbol(hwndDlg, szCurrSymbol) ||
!SetCurrencyDigNum(hwndDlg, &nCurrGrouping) ||
!SetPosCurrencySumFmt(hwndDlg, &nCurrPosFormat) ||
!SetNegCurrencySumFmt(hwndDlg, &nCurrNegFormat) ||
!SetCurrencySep(hwndDlg, szCurrDecimalSep) ||
!SetCurrencyFracSymNum(hwndDlg, &nCurrDigits) ||
!SetCurrencyFieldSep(hwndDlg, szCurrThousandSep))
/* Currency symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_CURRENCYSYMBOL,
szCurrSymbol,
MAX_SAMPLES_STR_SIZE);
if (szCurrSymbol[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* store to global data */
/* Positive Amount */
GetSelectedComboBoxIndex(hwndDlg,
IDC_CURRENCYPOSVALUE,
&nCurrPosFormat);
/* Negative Amount */
GetSelectedComboBoxIndex(hwndDlg,
IDC_CURRENCYNEGVALUE,
&nCurrNegFormat);
/* Decimal separator */
GetSelectedComboBoxText(hwndDlg,
IDC_CURRENCYDECSEP,
szCurrDecimalSep,
MAX_SAMPLES_STR_SIZE);
if (szCurrDecimalSep[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* Number of fractional digits */
GetSelectedComboBoxIndex(hwndDlg,
IDC_CURRENCYDECNUM,
&nCurrDigits);
/* Grouping symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_CURRENCYGRPSEP,
szCurrThousandSep,
MAX_SAMPLES_STR_SIZE);
if (szCurrThousandSep[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* 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);

View 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)
{
WCHAR szLongDateFmt[MAX_SAMPLES_STR_SIZE];
WCHAR szShortDateFmt[MAX_SAMPLES_STR_SIZE];
WCHAR szShortDateSep[MAX_SAMPLES_STR_SIZE];
if (!SetLongDateFormat(hwndDlg, szLongDateFmt) ||
!SetShortDateFormat(hwndDlg, szShortDateFmt) ||
!SetShortDateSep(hwndDlg, szShortDateSep))
static
BOOL
GetDateSetting(
HWND hwndDlg,
PGLOBALDATA pGlobalData)
{
WCHAR szLongDateFormat[MAX_SAMPLES_STR_SIZE];
WCHAR szShortDateFormat[MAX_SAMPLES_STR_SIZE];
WCHAR szDateSeparator[MAX_SAMPLES_STR_SIZE];
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);

View 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);

View 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 */

View 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)
{
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;
}
/* 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;
*pnNumNegFormat = nCurrSel;
return TRUE;
}
/* 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;
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);
return TRUE;
}
/* 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;
return TRUE;
}
static BOOL
SetNumberSetting(HWND hwndDlg, PGLOBALDATA pGlobalData)
static
BOOL
GetNumberSetting(
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;
INT nNumDigits;
INT nNumGrouping;
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))
/* Decimal symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_NUMBERDSYMBOL,
szNumDecimalSep,
MAX_NUMDECIMALSEP);
if (szNumDecimalSep[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* store to global data */
/* Number of digits after decimal */
GetSelectedComboBoxIndex(hwndDlg,
IDC_NUMBERSNDIGDEC,
&nNumDigits);
/* Digit grouping symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_NUMBERSDIGITGRSYM,
szNumThousandSep,
MAX_NUMTHOUSANDSEP);
if (szNumThousandSep[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* Digit grouping */
GetSelectedComboBoxIndex(hwndDlg,
IDC_NUMBERSDGROUPING,
&nNumGrouping);
/* Negative sign symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_NUMBERSNSIGNSYM,
szNumNegativeSign,
MAX_NUMNEGATIVESIGN);
if (szNumNegativeSign[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* Negative number format */
GetSelectedComboBoxIndex(hwndDlg,
IDC_NUMBERSNNUMFORMAT,
&nNumNegFormat);
/* Display leading zeros */
GetSelectedComboBoxIndex(hwndDlg,
IDC_NUMBERSDISPLEADZER,
&nNumLeadingZero);
/* List separator */
GetSelectedComboBoxText(hwndDlg,
IDC_NUMBERSLSEP,
szNumListSep,
MAX_NUMLISTSEP);
if (szNumListSep[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* 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);

View 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);
/* Get selected/typed PM symbol text */
GetSelectedComboEntry(hwndDlg, IDC_TIMEPMSYMBOL, szTimePM, MAX_TIMEPMSYMBOL);
/* verify values */
if (szTimeFormat[0] == L'\0' || szTimeSep[0] == L'\0')
return FALSE;
}
/* store to global data */
/* Time separator */
GetSelectedComboBoxText(hwndDlg,
IDC_TIMESEPARATOR,
szTimeSep,
MAX_TIMESEPARATOR);
/* Check the time separator */
if (szTimeSep[0] == L'\0')
{
/* TODO: Show error message */
return FALSE;
}
/* AM symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_TIMEAMSYMBOL,
szTimeAM,
MAX_TIMEAMSYMBOL);
/* PM symbol */
GetSelectedComboBoxText(hwndDlg,
IDC_TIMEPMSYMBOL,
szTimePM,
MAX_TIMEPMSYMBOL);
/* 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);