2004-10-30 12:33:51 +00:00
|
|
|
/*
|
|
|
|
* ReactOS
|
|
|
|
* Copyright (C) 2004 ReactOS Team
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
2009-10-27 10:34:16 +00:00
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2004-10-30 12:33:51 +00:00
|
|
|
*/
|
2013-03-16 20:25:38 +00:00
|
|
|
/*
|
2004-10-30 12:33:51 +00:00
|
|
|
* PROJECT: ReactOS International Control Panel
|
2011-11-29 14:55:58 +00:00
|
|
|
* FILE: dll/cpl/intl/numbers.c
|
2004-10-30 12:33:51 +00:00
|
|
|
* PURPOSE: Numbers property page
|
2017-05-06 13:43:03 +00:00
|
|
|
* PROGRAMMERS: Eric Kohl
|
|
|
|
* Katayama Hirofumi MZ (katayama.hirofumi.mz@gmail.com)
|
2004-10-30 12:33:51 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "intl.h"
|
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
#define SAMPLE_NUMBER L"123456789"
|
|
|
|
#define SAMPLE_NEG_NUMBER L"-123456789"
|
2007-09-02 20:42:08 +00:00
|
|
|
#define MAX_NUM_SEP_SAMPLES 2
|
2007-09-10 20:40:27 +00:00
|
|
|
#define MAX_FRAC_NUM_SAMPLES 10
|
2007-09-02 20:42:08 +00:00
|
|
|
#define MAX_FIELD_SEP_SAMPLES 1
|
|
|
|
#define MAX_FIELD_DIG_SAMPLES 3
|
|
|
|
#define MAX_NEG_SIGN_SAMPLES 1
|
|
|
|
#define MAX_NEG_NUMBERS_SAMPLES 5
|
|
|
|
#define MAX_LEAD_ZEROES_SAMPLES 2
|
|
|
|
#define MAX_LIST_SEP_SAMPLES 1
|
|
|
|
#define MAX_UNITS_SYS_SAMPLES 2
|
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
static PWSTR lpNumSepSamples[MAX_NUM_SEP_SAMPLES] =
|
|
|
|
{L",", L"."};
|
|
|
|
static PWSTR lpFieldSepSamples[MAX_FIELD_SEP_SAMPLES] =
|
|
|
|
{L" "};
|
|
|
|
static PWSTR lpFieldDigNumSamples[MAX_FIELD_DIG_SAMPLES] =
|
|
|
|
{L"0;0", L"3;0", L"3;2;0"};
|
|
|
|
static PWSTR lpNegSignSamples[MAX_NEG_SIGN_SAMPLES] =
|
|
|
|
{L"-"};
|
|
|
|
static PWSTR lpNegNumFmtSamples[MAX_NEG_NUMBERS_SAMPLES] =
|
|
|
|
{L"(1,1)", L"-1,1", L"- 1,1", L"1,1-", L"1,1 -"};
|
|
|
|
static PWSTR lpLeadNumFmtSamples[MAX_LEAD_ZEROES_SAMPLES] =
|
|
|
|
{L",7", L"0,7"};
|
|
|
|
static PWSTR lpListSepSamples[MAX_LIST_SEP_SAMPLES] =
|
|
|
|
{L";"};
|
2007-09-10 20:40:27 +00:00
|
|
|
|
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* Init num decimal separator control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitNumDecimalSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
|
|
|
INT nRetCode;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Limit text length */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
|
|
|
|
CB_LIMITTEXT,
|
2015-10-04 21:57:03 +00:00
|
|
|
MAX_NUMDECIMALSEP - 1,
|
2015-09-20 19:00:10 +00:00
|
|
|
0);
|
2009-10-28 23:20:28 +00:00
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
/* Create standard list of decimal separators */
|
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_NUM_SEP_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lpNumSepSamples[nCBIndex]);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumDecimalSep);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* If it is not successful, add new values to list and select them */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (nRetCode == CB_ERR)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
MAX_NUM_SEP_SAMPLES,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumDecimalSep);
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERDSYMBOL,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumDecimalSep);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init number of fractional symbols control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitNumOfFracSymbCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
WCHAR szFracCount[MAX_SAMPLES_STR_SIZE];
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNDIGDEC,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
/* Create standard list of fractional symbols */
|
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_FRAC_NUM_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Convert to wide char */
|
2015-09-20 19:00:10 +00:00
|
|
|
_itow(nCBIndex, szFracCount, DECIMAL_RADIX);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNDIGDEC,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)szFracCount);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNDIGDEC,
|
|
|
|
CB_SETCURSEL,
|
2015-10-04 21:57:03 +00:00
|
|
|
(WPARAM)pGlobalData->nNumDigits,
|
2015-09-20 19:00:10 +00:00
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init field separator control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitNumFieldSepCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
|
|
|
INT nRetCode;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Limit text length */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
|
|
|
|
CB_LIMITTEXT,
|
2015-10-04 21:57:03 +00:00
|
|
|
MAX_NUMTHOUSANDSEP - 1,
|
2015-09-20 19:00:10 +00:00
|
|
|
0);
|
2009-10-28 23:20:28 +00:00
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create standard list of field separators */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_FIELD_SEP_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lpFieldSepSamples[nCBIndex]);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumThousandSep);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* If it is not success, add new values to list and select them */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (nRetCode == CB_ERR)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumThousandSep);
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDIGITGRSYM,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumThousandSep);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Init number of digits in field control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitFieldDigNumCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
PWSTR pszFieldDigNumSmpl;
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create standard list of field digits num */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
|
2017-04-30 15:39:41 +00:00
|
|
|
if (pszFieldDigNumSmpl != NULL)
|
|
|
|
{
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)pszFieldDigNumSmpl);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszFieldDigNumSmpl);
|
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
2015-10-04 21:57:03 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
|
|
|
CB_SETCURSEL,
|
|
|
|
(WPARAM)pGlobalData->nNumGrouping,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init negative sign control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitNegSignCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
|
|
|
INT nRetCode;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Limit text length */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
|
|
|
|
CB_LIMITTEXT,
|
2015-10-04 21:57:03 +00:00
|
|
|
MAX_NUMNEGATIVESIGN - 1,
|
2015-09-20 19:00:10 +00:00
|
|
|
0);
|
2009-10-28 23:20:28 +00:00
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create standard list of signs */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_NEG_SIGN_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lpNegSignSamples[nCBIndex]);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumNegativeSign);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* If it is not successful, add new values to list and select them */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (nRetCode == CB_ERR)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumNegativeSign);
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNSIGNSYM,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumNegativeSign);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init negative numbers format control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2017-06-07 15:55:16 +00:00
|
|
|
PWSTR pszString1, pszString2;
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create standard list of negative numbers formats */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_NEG_NUMBERS_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Replace standard separator to setted */
|
2017-06-07 15:55:16 +00:00
|
|
|
pszString1 = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
|
|
|
|
pGlobalData->szNumDecimalSep,
|
|
|
|
L",");
|
|
|
|
if (pszString1 != NULL)
|
2017-04-30 15:39:41 +00:00
|
|
|
{
|
2017-06-07 15:55:16 +00:00
|
|
|
/* Replace standard negative sign to setted */
|
|
|
|
pszString2 = ReplaceSubStr(pszString1,
|
|
|
|
pGlobalData->szNumNegativeSign,
|
|
|
|
L"-");
|
|
|
|
if (pszString2 != NULL)
|
|
|
|
{
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)pszString2);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszString2);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszString1);
|
2017-04-30 15:39:41 +00:00
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
|
|
|
CB_SETCURSEL,
|
2015-10-04 21:57:03 +00:00
|
|
|
(WPARAM)pGlobalData->nNumNegFormat,
|
2015-09-20 19:00:10 +00:00
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Init leading zeroes control box */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2015-09-20 19:00:10 +00:00
|
|
|
InitLeadingZeroesCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
PWSTR pszResultStr;
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create list of standard leading zeroes formats */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_LEAD_ZEROES_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
|
2015-10-04 21:57:03 +00:00
|
|
|
pGlobalData->szNumDecimalSep,
|
2015-09-20 19:00:10 +00:00
|
|
|
L",");
|
2017-04-30 15:39:41 +00:00
|
|
|
if (pszResultStr != NULL)
|
|
|
|
{
|
|
|
|
SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)pszResultStr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
|
|
|
CB_SETCURSEL,
|
2015-10-04 21:57:03 +00:00
|
|
|
(WPARAM)pGlobalData->nNumLeadingZero,
|
2015-09-20 19:00:10 +00:00
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2007-09-10 20:40:27 +00:00
|
|
|
InitListSepCB(HWND hwndDlg,
|
2015-09-20 19:00:10 +00:00
|
|
|
PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
|
|
|
INT nRetCode;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Limit text length */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
|
|
|
|
CB_LIMITTEXT,
|
2015-10-04 21:57:03 +00:00
|
|
|
MAX_NUMLISTSEP - 1,
|
2015-09-20 19:00:10 +00:00
|
|
|
0);
|
2009-10-28 23:20:28 +00:00
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create standard list of signs */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_LIST_SEP_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)lpListSepSamples[nCBIndex]);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
nRetCode = SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumListSep);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* If it is not successful, add new values to list and select them */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (nRetCode == CB_ERR)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumListSep);
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSLSEP,
|
|
|
|
CB_SELECTSTRING,
|
|
|
|
-1,
|
2015-10-04 21:57:03 +00:00
|
|
|
(LPARAM)pGlobalData->szNumListSep);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Init system of units control box */
|
2007-09-10 20:40:27 +00:00
|
|
|
static VOID
|
|
|
|
InitUnitsSysCB(HWND hwndDlg,
|
2015-09-20 19:00:10 +00:00
|
|
|
PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
WCHAR szUnitName[128];
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nCBIndex;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Clear all box content */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSMEASSYS,
|
|
|
|
CB_RESETCONTENT,
|
|
|
|
(WPARAM)0,
|
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2009-10-28 23:20:28 +00:00
|
|
|
/* Create list of standard system of units */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nCBIndex = 0; nCBIndex < MAX_UNITS_SYS_SAMPLES; nCBIndex++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
LoadStringW(hApplet, IDS_METRIC + nCBIndex, szUnitName, 128);
|
2010-05-22 10:20:56 +00:00
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSMEASSYS,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)szUnitName);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Set current item to value from registry */
|
2015-09-20 19:00:10 +00:00
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSMEASSYS,
|
|
|
|
CB_SETCURSEL,
|
2015-10-04 21:57:03 +00:00
|
|
|
(WPARAM)pGlobalData->nNumMeasure,
|
2015-09-20 19:00:10 +00:00
|
|
|
(LPARAM)0);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Update all numbers locale samples */
|
2007-09-05 14:24:45 +00:00
|
|
|
static VOID
|
2007-09-02 20:42:08 +00:00
|
|
|
UpdateNumSamples(HWND hwndDlg,
|
2015-09-20 19:00:10 +00:00
|
|
|
PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2015-09-20 19:00:10 +00:00
|
|
|
WCHAR OutBuffer[MAX_FMT_SIZE];
|
2015-10-11 18:36:22 +00:00
|
|
|
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;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Get positive number format sample */
|
2015-10-04 21:57:03 +00:00
|
|
|
GetNumberFormatW(pGlobalData->UserLCID,
|
2015-09-20 19:00:10 +00:00
|
|
|
0,
|
|
|
|
SAMPLE_NUMBER,
|
2015-10-11 18:36:22 +00:00
|
|
|
&NumberFormat,
|
2015-09-20 19:00:10 +00:00
|
|
|
OutBuffer,
|
|
|
|
MAX_FMT_SIZE);
|
|
|
|
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSPOSSAMPLE,
|
|
|
|
WM_SETTEXT,
|
|
|
|
0,
|
|
|
|
(LPARAM)OutBuffer);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Get positive number format sample */
|
2015-10-04 21:57:03 +00:00
|
|
|
GetNumberFormatW(pGlobalData->UserLCID,
|
2015-09-20 19:00:10 +00:00
|
|
|
0,
|
|
|
|
SAMPLE_NEG_NUMBER,
|
2015-10-11 18:36:22 +00:00
|
|
|
&NumberFormat,
|
2015-09-20 19:00:10 +00:00
|
|
|
OutBuffer,
|
|
|
|
MAX_FMT_SIZE);
|
|
|
|
|
|
|
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNEGSAMPLE,
|
|
|
|
WM_SETTEXT,
|
|
|
|
0,
|
|
|
|
(LPARAM)OutBuffer);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
static
|
|
|
|
BOOL
|
|
|
|
GetNumberSetting(
|
|
|
|
HWND hwndDlg,
|
|
|
|
PGLOBALDATA pGlobalData)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2017-05-06 14:41:50 +00:00
|
|
|
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 */
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2015-10-04 21:57:03 +00:00
|
|
|
return FALSE;
|
2017-05-06 14:41:50 +00:00
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Number of digits after decimal */
|
|
|
|
GetSelectedComboBoxIndex(hwndDlg,
|
|
|
|
IDC_NUMBERSNDIGDEC,
|
|
|
|
&nNumDigits);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Digit grouping symbol */
|
|
|
|
GetSelectedComboBoxText(hwndDlg,
|
|
|
|
IDC_NUMBERSDIGITGRSYM,
|
|
|
|
szNumThousandSep,
|
|
|
|
MAX_NUMTHOUSANDSEP);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
if (szNumThousandSep[0] == L'\0')
|
|
|
|
{
|
|
|
|
/* TODO: Show error message */
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2015-10-04 21:57:03 +00:00
|
|
|
return FALSE;
|
2017-05-06 14:41:50 +00:00
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Digit grouping */
|
|
|
|
GetSelectedComboBoxIndex(hwndDlg,
|
|
|
|
IDC_NUMBERSDGROUPING,
|
|
|
|
&nNumGrouping);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Negative sign symbol */
|
|
|
|
GetSelectedComboBoxText(hwndDlg,
|
|
|
|
IDC_NUMBERSNSIGNSYM,
|
|
|
|
szNumNegativeSign,
|
|
|
|
MAX_NUMNEGATIVESIGN);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
if (szNumNegativeSign[0] == L'\0')
|
|
|
|
{
|
|
|
|
/* TODO: Show error message */
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2015-10-04 21:57:03 +00:00
|
|
|
return FALSE;
|
2017-05-06 14:41:50 +00:00
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Negative number format */
|
|
|
|
GetSelectedComboBoxIndex(hwndDlg,
|
|
|
|
IDC_NUMBERSNNUMFORMAT,
|
|
|
|
&nNumNegFormat);
|
2017-05-06 13:43:03 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Display leading zeros */
|
|
|
|
GetSelectedComboBoxIndex(hwndDlg,
|
|
|
|
IDC_NUMBERSDISPLEADZER,
|
|
|
|
&nNumLeadingZero);
|
2017-05-06 13:43:03 +00:00
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* List separator */
|
|
|
|
GetSelectedComboBoxText(hwndDlg,
|
|
|
|
IDC_NUMBERSLSEP,
|
|
|
|
szNumListSep,
|
|
|
|
MAX_NUMLISTSEP);
|
|
|
|
|
|
|
|
if (szNumListSep[0] == L'\0')
|
2017-05-06 13:43:03 +00:00
|
|
|
{
|
2017-05-06 14:41:50 +00:00
|
|
|
/* TODO: Show error message */
|
|
|
|
|
2017-05-06 13:43:03 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2017-05-06 14:41:50 +00:00
|
|
|
/* Measurement system */
|
|
|
|
GetSelectedComboBoxIndex(hwndDlg,
|
|
|
|
IDC_NUMBERSMEASSYS,
|
|
|
|
&nNumMeasure);
|
|
|
|
|
|
|
|
/* Store settings in global data */
|
2017-05-06 13:43:03 +00:00
|
|
|
wcscpy(pGlobalData->szNumDecimalSep, szNumDecimalSep);
|
|
|
|
wcscpy(pGlobalData->szNumThousandSep, szNumThousandSep);
|
|
|
|
wcscpy(pGlobalData->szNumNegativeSign, szNumNegativeSign);
|
|
|
|
wcscpy(pGlobalData->szNumListSep, szNumListSep);
|
|
|
|
pGlobalData->nNumGrouping = nNumGrouping;
|
|
|
|
pGlobalData->nNumDigits = nNumDigits;
|
|
|
|
pGlobalData->nNumNegFormat = nNumNegFormat;
|
|
|
|
pGlobalData->nNumLeadingZero = nNumLeadingZero;
|
|
|
|
pGlobalData->nNumMeasure = nNumMeasure;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2004-10-30 12:33:51 +00:00
|
|
|
|
|
|
|
/* Property page dialog callback */
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
NumbersPageProc(HWND hwndDlg,
|
2007-09-10 20:40:27 +00:00
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
2004-10-30 12:33:51 +00:00
|
|
|
{
|
2007-09-10 20:40:27 +00:00
|
|
|
PGLOBALDATA pGlobalData;
|
|
|
|
|
|
|
|
pGlobalData = (PGLOBALDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
pGlobalData = (PGLOBALDATA)((LPPROPSHEETPAGE)lParam)->lParam;
|
|
|
|
SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pGlobalData);
|
|
|
|
|
2015-09-20 19:00:10 +00:00
|
|
|
InitNumDecimalSepCB(hwndDlg, pGlobalData);
|
|
|
|
InitNumOfFracSymbCB(hwndDlg, pGlobalData);
|
|
|
|
InitNumFieldSepCB(hwndDlg, pGlobalData);
|
|
|
|
InitFieldDigNumCB(hwndDlg, pGlobalData);
|
|
|
|
InitNegSignCB(hwndDlg, pGlobalData);
|
|
|
|
InitNegNumFmtCB(hwndDlg, pGlobalData);
|
|
|
|
InitLeadingZeroesCB(hwndDlg, pGlobalData);
|
|
|
|
InitListSepCB(hwndDlg, pGlobalData);
|
|
|
|
InitUnitsSysCB(hwndDlg, pGlobalData);
|
|
|
|
UpdateNumSamples(hwndDlg, pGlobalData);
|
2007-09-10 20:40:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam))
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-10 20:40:27 +00:00
|
|
|
case IDC_NUMBERDSYMBOL:
|
|
|
|
case IDC_NUMBERSNDIGDEC:
|
|
|
|
case IDC_NUMBERSDIGITGRSYM:
|
|
|
|
case IDC_NUMBERSDGROUPING:
|
|
|
|
case IDC_NUMBERSNSIGNSYM:
|
|
|
|
case IDC_NUMBERSNNUMFORMAT:
|
|
|
|
case IDC_NUMBERSDISPLEADZER:
|
|
|
|
case IDC_NUMBERSLSEP:
|
|
|
|
case IDC_NUMBERSMEASSYS:
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE || HIWORD(wParam) == CBN_EDITCHANGE)
|
|
|
|
{
|
2017-05-06 13:43:03 +00:00
|
|
|
/* Enable the Apply button */
|
2007-09-10 20:40:27 +00:00
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
2007-09-10 20:40:27 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
|
|
|
|
{
|
2017-05-06 14:41:50 +00:00
|
|
|
if (GetNumberSetting(hwndDlg, pGlobalData))
|
2017-05-06 13:43:03 +00:00
|
|
|
{
|
|
|
|
pGlobalData->bUserLocaleChanged = TRUE;
|
|
|
|
UpdateNumSamples(hwndDlg, pGlobalData);
|
|
|
|
}
|
2007-09-10 20:40:27 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
2004-10-30 12:33:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|