mirror of
https://github.com/reactos/reactos.git
synced 2025-04-21 20:50:29 +00:00
[INTL]
- Get rid of alloca, malloc and free. - Always check the return values of HeapAlloc. - Rename fUserLocaleChanged to bUserLocaleChanged and fGeoIdChanged to bGeoIdChanged. - Use WCHAR instead of TCHAR. - Fix indentation and coding style. - Remove setupreg.c because it is an unused copy of misc.c. svn path=/trunk/; revision=74434
This commit is contained in:
parent
30d5e8f413
commit
a526c712b5
11 changed files with 140 additions and 344 deletions
|
@ -188,15 +188,15 @@ LocalesEnumProc(PWSTR lpLocale)
|
||||||
|
|
||||||
if (bNoShow == FALSE)
|
if (bNoShow == FALSE)
|
||||||
{
|
{
|
||||||
index = SendMessageW(hLangList,
|
index = SendMessageW(hLangList,
|
||||||
CB_ADDSTRING,
|
CB_ADDSTRING,
|
||||||
0,
|
0,
|
||||||
(LPARAM)lang);
|
(LPARAM)lang);
|
||||||
|
|
||||||
SendMessageW(hLangList,
|
SendMessageW(hLangList,
|
||||||
CB_SETITEMDATA,
|
CB_SETITEMDATA,
|
||||||
index,
|
index,
|
||||||
(LPARAM)lcid);
|
(LPARAM)lcid);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -245,7 +245,10 @@ GetCurrentDPI(LPTSTR szDPI)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else wsprintf(szDPI, L"%d", dwDPI);
|
else
|
||||||
|
{
|
||||||
|
wsprintf(szDPI, L"%d", dwDPI);
|
||||||
|
}
|
||||||
|
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
@ -266,7 +269,6 @@ SaveFontSubstitutionSettings(
|
||||||
wsprintf(szSection, L"Font.CP%s.%s", szDefCP, szDPI);
|
wsprintf(szSection, L"Font.CP%s.%s", szDefCP, szDPI);
|
||||||
|
|
||||||
hFontInf = SetupOpenInfFileW(L"font.inf", NULL, INF_STYLE_WIN4, NULL);
|
hFontInf = SetupOpenInfFileW(L"font.inf", NULL, INF_STYLE_WIN4, NULL);
|
||||||
|
|
||||||
if (hFontInf == INVALID_HANDLE_VALUE)
|
if (hFontInf == INVALID_HANDLE_VALUE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -277,12 +279,15 @@ SaveFontSubstitutionSettings(
|
||||||
}
|
}
|
||||||
|
|
||||||
Count = (UINT) SetupGetLineCount(hFontInf, szSection);
|
Count = (UINT) SetupGetLineCount(hFontInf, szSection);
|
||||||
if (Count <= 0) return;
|
if (Count <= 0)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!SetupInstallFromInfSectionW(hwnd, hFontInf, szSection, SPINST_REGISTRY & ~SPINST_FILES,
|
if (!SetupInstallFromInfSectionW(hwnd, hFontInf, szSection, SPINST_REGISTRY & ~SPINST_FILES,
|
||||||
NULL, NULL, 0, NULL, NULL, NULL, NULL))
|
NULL, NULL, 0, NULL, NULL, NULL, NULL))
|
||||||
|
{
|
||||||
MessageBoxW(hwnd, L"Unable to install a new language for programs don't support unicode!",
|
MessageBoxW(hwnd, L"Unable to install a new language for programs don't support unicode!",
|
||||||
NULL, MB_ICONERROR | MB_OK);
|
NULL, MB_ICONERROR | MB_OK);
|
||||||
|
}
|
||||||
|
|
||||||
SetupCloseInfFile(hFontInf);
|
SetupCloseInfFile(hFontInf);
|
||||||
}
|
}
|
||||||
|
@ -421,10 +426,7 @@ AdvancedPageProc(HWND hwndDlg,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
{
|
if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
|
||||||
LPNMHDR lpnm = (LPNMHDR)lParam;
|
|
||||||
|
|
||||||
if (lpnm->code == (UINT)PSN_APPLY)
|
|
||||||
{
|
{
|
||||||
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
|
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
|
||||||
|
|
||||||
|
@ -432,8 +434,7 @@ AdvancedPageProc(HWND hwndDlg,
|
||||||
SaveFontSubstitutionSettings(hwndDlg, pGlobalData);
|
SaveFontSubstitutionSettings(hwndDlg, pGlobalData);
|
||||||
SaveFontLinkingSettings(hwndDlg, pGlobalData);
|
SaveFontLinkingSettings(hwndDlg, pGlobalData);
|
||||||
}
|
}
|
||||||
}
|
break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -439,7 +439,7 @@ CurrencyPageProc(HWND hwndDlg,
|
||||||
if (!SetCurrencyFieldSep(hwndDlg, pGlobalData))
|
if (!SetCurrencyFieldSep(hwndDlg, pGlobalData))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
|
|
||||||
UpdateExamples(hwndDlg, pGlobalData);
|
UpdateExamples(hwndDlg, pGlobalData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,9 +55,8 @@ FindDateSep(const WCHAR *szSourceStr)
|
||||||
UINT nDateCompCount=0;
|
UINT nDateCompCount=0;
|
||||||
UINT nDateSepCount=0;
|
UINT nDateSepCount=0;
|
||||||
|
|
||||||
pszFoundSep = (LPWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
pszFoundSep = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
||||||
|
if (pszFoundSep == NULL)
|
||||||
if(!pszFoundSep)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
wcscpy(pszFoundSep,STD_DATE_SEP);
|
wcscpy(pszFoundSep,STD_DATE_SEP);
|
||||||
|
@ -171,15 +170,19 @@ SetShortDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
||||||
}
|
}
|
||||||
|
|
||||||
pszFoundSep = FindDateSep(szShortDateFmt);
|
pszFoundSep = FindDateSep(szShortDateFmt);
|
||||||
|
if (pszFoundSep != NULL)
|
||||||
|
{
|
||||||
|
/* Substring replacement of separator */
|
||||||
|
wcscpy(szFoundDateSep, pszFoundSep);
|
||||||
|
pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
|
||||||
|
if (pszResultStr != NULL)
|
||||||
|
{
|
||||||
|
wcscpy(szShortDateFmt, pszResultStr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Substring replacement of separator */
|
HeapFree(GetProcessHeap(), 0, pszFoundSep);
|
||||||
wcscpy(szFoundDateSep, pszFoundSep);
|
}
|
||||||
pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
|
|
||||||
wcscpy(szShortDateFmt, pszResultStr);
|
|
||||||
free(pszResultStr);
|
|
||||||
|
|
||||||
if (pszFoundSep)
|
|
||||||
free(pszFoundSep);
|
|
||||||
|
|
||||||
/* Save short date format */
|
/* Save short date format */
|
||||||
wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
|
wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
|
||||||
|
@ -393,19 +396,19 @@ SetMaxDate(HWND hwndDlg, LCID lcid)
|
||||||
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
|
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
|
||||||
|
|
||||||
/* Get spin value */
|
/* Get spin value */
|
||||||
nSpinVal=LOWORD(SendMessageW(hWndYearSpin,
|
nSpinVal = LOWORD(SendMessageW(hWndYearSpin,
|
||||||
UDM_GETPOS,
|
UDM_GETPOS,
|
||||||
0,
|
0,
|
||||||
0));
|
0));
|
||||||
|
|
||||||
/* convert to wide char */
|
/* convert to wide char */
|
||||||
_itow(nSpinVal, szMaxDateVal, DECIMAL_RADIX);
|
_itow(nSpinVal, szMaxDateVal, DECIMAL_RADIX);
|
||||||
|
|
||||||
/* Save max date value */
|
/* Save max date value */
|
||||||
SetCalendarInfoW(lcid,
|
SetCalendarInfoW(lcid,
|
||||||
CAL_GREGORIAN,
|
CAL_GREGORIAN,
|
||||||
48 , /* CAL_ITWODIGITYEARMAX */
|
48 , /* CAL_ITWODIGITYEARMAX */
|
||||||
(PCWSTR)szMaxDateVal);
|
(PCWSTR)szMaxDateVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get max date value from registry set */
|
/* Get max date value from registry set */
|
||||||
|
@ -457,13 +460,13 @@ InitMinMaxDateSpin(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
||||||
|
|
||||||
/* Limit text lengths */
|
/* Limit text lengths */
|
||||||
SendDlgItemMessageW(hwndDlg, IDC_FIRSTYEAR_EDIT,
|
SendDlgItemMessageW(hwndDlg, IDC_FIRSTYEAR_EDIT,
|
||||||
EM_LIMITTEXT,
|
EM_LIMITTEXT,
|
||||||
MAX_YEAR_EDIT,
|
MAX_YEAR_EDIT,
|
||||||
0);
|
0);
|
||||||
SendDlgItemMessageW(hwndDlg, IDC_SECONDYEAR_EDIT,
|
SendDlgItemMessageW(hwndDlg, IDC_SECONDYEAR_EDIT,
|
||||||
EM_LIMITTEXT,
|
EM_LIMITTEXT,
|
||||||
MAX_YEAR_EDIT,
|
MAX_YEAR_EDIT,
|
||||||
0);
|
0);
|
||||||
|
|
||||||
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
|
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
|
||||||
|
|
||||||
|
@ -584,7 +587,7 @@ DatePageProc(HWND hwndDlg,
|
||||||
if (!SetShortDateSep(hwndDlg, pGlobalData))
|
if (!SetShortDateSep(hwndDlg, pGlobalData))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
|
|
||||||
SetMaxDate(hwndDlg, pGlobalData->UserLCID);
|
SetMaxDate(hwndDlg, pGlobalData->UserLCID);
|
||||||
InitShortDateCB(hwndDlg, pGlobalData);
|
InitShortDateCB(hwndDlg, pGlobalData);
|
||||||
|
|
|
@ -1429,7 +1429,7 @@ GeneralPageProc(HWND hwndDlg,
|
||||||
|
|
||||||
SetNewLocale(pGlobalData, NewLcid);
|
SetNewLocale(pGlobalData, NewLcid);
|
||||||
UpdateLocaleSample(hwndDlg, pGlobalData);
|
UpdateLocaleSample(hwndDlg, pGlobalData);
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
|
|
||||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||||
}
|
}
|
||||||
|
@ -1456,7 +1456,7 @@ GeneralPageProc(HWND hwndDlg,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pGlobalData->geoid = NewGeoID;
|
pGlobalData->geoid = NewGeoID;
|
||||||
pGlobalData->fGeoIdChanged = TRUE;
|
pGlobalData->bGeoIdChanged = TRUE;
|
||||||
|
|
||||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||||
}
|
}
|
||||||
|
@ -1466,7 +1466,7 @@ GeneralPageProc(HWND hwndDlg,
|
||||||
if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData) > 0)
|
if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData) > 0)
|
||||||
{
|
{
|
||||||
UpdateLocaleSample(hwndDlg, pGlobalData);
|
UpdateLocaleSample(hwndDlg, pGlobalData);
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1474,30 +1474,26 @@ GeneralPageProc(HWND hwndDlg,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_NOTIFY:
|
case WM_NOTIFY:
|
||||||
|
if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
|
||||||
{
|
{
|
||||||
LPNMHDR lpnm = (LPNMHDR)lParam;
|
/* Apply changes */
|
||||||
|
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
|
||||||
|
|
||||||
if (lpnm->code == (UINT)PSN_APPLY)
|
/* Set new locale */
|
||||||
|
if (pGlobalData->bUserLocaleChanged == TRUE)
|
||||||
{
|
{
|
||||||
/* Apply changes */
|
SaveCurrentLocale(pGlobalData);
|
||||||
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
|
pGlobalData->bUserLocaleChanged = FALSE;
|
||||||
|
|
||||||
/* Set new locale */
|
|
||||||
if (pGlobalData->fUserLocaleChanged == TRUE)
|
|
||||||
{
|
|
||||||
SaveCurrentLocale(pGlobalData);
|
|
||||||
pGlobalData->fUserLocaleChanged = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set new GEO ID */
|
|
||||||
if (pGlobalData->fGeoIdChanged == TRUE)
|
|
||||||
{
|
|
||||||
SaveGeoID(pGlobalData);
|
|
||||||
pGlobalData->fGeoIdChanged = FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Set new GEO ID */
|
||||||
|
if (pGlobalData->bGeoIdChanged == TRUE)
|
||||||
|
{
|
||||||
|
SaveGeoID(pGlobalData);
|
||||||
|
pGlobalData->bGeoIdChanged = FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,16 +51,16 @@ APPLET Applets[NUM_APPLETS] =
|
||||||
VOID
|
VOID
|
||||||
PrintErrorMsgBox(UINT msg)
|
PrintErrorMsgBox(UINT msg)
|
||||||
{
|
{
|
||||||
TCHAR szErrorText[BUFFERSIZE];
|
WCHAR szErrorText[BUFFERSIZE];
|
||||||
TCHAR szErrorCaption[BUFFERSIZE];
|
WCHAR szErrorCaption[BUFFERSIZE];
|
||||||
|
|
||||||
LoadString(hApplet, msg, szErrorText, sizeof(szErrorText)/sizeof(TCHAR));
|
LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
||||||
LoadString(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption)/sizeof(TCHAR));
|
LoadStringW(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
|
||||||
|
|
||||||
MessageBox(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
|
MessageBoxW(NULL, szErrorText, szErrorCaption, MB_OK | MB_ICONERROR);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID
|
INT
|
||||||
ResourceMessageBox(
|
ResourceMessageBox(
|
||||||
HWND hwnd,
|
HWND hwnd,
|
||||||
UINT uType,
|
UINT uType,
|
||||||
|
@ -73,7 +73,7 @@ ResourceMessageBox(
|
||||||
LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
||||||
LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
|
LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
|
||||||
|
|
||||||
MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
|
return MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VOID
|
static VOID
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
#include <cpl.h>
|
#include <cpl.h>
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <malloc.h>
|
|
||||||
#include <ndk/exfuncs.h>
|
#include <ndk/exfuncs.h>
|
||||||
|
|
||||||
#include "resource.h"
|
#include "resource.h"
|
||||||
|
@ -110,11 +109,11 @@ typedef struct _GLOBALDATA
|
||||||
|
|
||||||
LCID UserLCID;
|
LCID UserLCID;
|
||||||
LCID SystemLCID;
|
LCID SystemLCID;
|
||||||
BOOL fUserLocaleChanged;
|
BOOL bUserLocaleChanged;
|
||||||
BOOL bApplyToDefaultUser;
|
BOOL bApplyToDefaultUser;
|
||||||
|
|
||||||
GEOID geoid;
|
GEOID geoid;
|
||||||
BOOL fGeoIdChanged;
|
BOOL bGeoIdChanged;
|
||||||
|
|
||||||
/* Misc */
|
/* Misc */
|
||||||
BOOL bIsUserAdmin;
|
BOOL bIsUserAdmin;
|
||||||
|
@ -134,7 +133,7 @@ extern GROUPINGDATA GroupingFormats[MAX_GROUPINGFORMATS];
|
||||||
/* intl.c */
|
/* intl.c */
|
||||||
VOID PrintErrorMsgBox(UINT msg);
|
VOID PrintErrorMsgBox(UINT msg);
|
||||||
|
|
||||||
VOID
|
INT
|
||||||
ResourceMessageBox(
|
ResourceMessageBox(
|
||||||
HWND hwnd,
|
HWND hwnd,
|
||||||
UINT uType,
|
UINT uType,
|
||||||
|
|
|
@ -9,7 +9,9 @@ InsSpacePos(PCWSTR szInsStr, const int nPos)
|
||||||
INT nStrCnt;
|
INT nStrCnt;
|
||||||
INT nStrSize;
|
INT nStrSize;
|
||||||
|
|
||||||
pszDestStr = (PWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
pszDestStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
||||||
|
if (pszDestStr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
wcscpy(pszDestStr, szInsStr);
|
wcscpy(pszDestStr, szInsStr);
|
||||||
|
|
||||||
|
@ -45,7 +47,9 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
|
||||||
INT nSpaceOffset = 0;
|
INT nSpaceOffset = 0;
|
||||||
BOOL wasNul=FALSE;
|
BOOL wasNul=FALSE;
|
||||||
|
|
||||||
pszDestStr = (PWSTR)malloc(255 * sizeof(WCHAR));
|
pszDestStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, 255 * sizeof(WCHAR));
|
||||||
|
if (pszDestStr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
wcscpy(pszDestStr, szSourceStr);
|
wcscpy(pszDestStr, szSourceStr);
|
||||||
|
|
||||||
|
@ -80,7 +84,7 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
|
||||||
/* Insert space to finded position plus all pos before */
|
/* Insert space to finded position plus all pos before */
|
||||||
pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
|
pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
|
||||||
wcscpy(pszDestStr,pszTempStr);
|
wcscpy(pszDestStr,pszTempStr);
|
||||||
free(pszTempStr);
|
HeapFree(GetProcessHeap(), 0, pszTempStr);
|
||||||
|
|
||||||
/* Num of spaces total increment */
|
/* Num of spaces total increment */
|
||||||
if (!wasNul)
|
if (!wasNul)
|
||||||
|
@ -102,7 +106,7 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
|
||||||
{
|
{
|
||||||
pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
|
pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
|
||||||
wcscpy(pszDestStr, pszTempStr);
|
wcscpy(pszDestStr, pszTempStr);
|
||||||
free(pszTempStr);
|
HeapFree(GetProcessHeap(), 0, pszTempStr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +125,9 @@ ReplaceSubStr(PCWSTR szSourceStr,
|
||||||
UINT nDestStrCnt;
|
UINT nDestStrCnt;
|
||||||
UINT nFirstCharCnt;
|
UINT nFirstCharCnt;
|
||||||
|
|
||||||
szDestStr = (PWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
szDestStr = (PWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
||||||
|
if (szDestStr == NULL)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
nDestStrCnt = 0;
|
nDestStrCnt = 0;
|
||||||
nFirstCharCnt = 0;
|
nFirstCharCnt = 0;
|
||||||
|
|
|
@ -198,11 +198,14 @@ InitFieldDigNumCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
||||||
for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
|
for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
|
||||||
{
|
{
|
||||||
pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
|
pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
|
||||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
if (pszFieldDigNumSmpl != NULL)
|
||||||
CB_ADDSTRING,
|
{
|
||||||
0,
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
||||||
(LPARAM)pszFieldDigNumSmpl);
|
CB_ADDSTRING,
|
||||||
free(pszFieldDigNumSmpl);
|
0,
|
||||||
|
(LPARAM)pszFieldDigNumSmpl);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszFieldDigNumSmpl);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
||||||
|
@ -280,18 +283,24 @@ InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
||||||
pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
|
pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
|
||||||
pGlobalData->szNumDecimalSep,
|
pGlobalData->szNumDecimalSep,
|
||||||
L",");
|
L",");
|
||||||
wcscpy(szNewSample, pszResultStr);
|
if (pszResultStr != NULL)
|
||||||
free(pszResultStr);
|
{
|
||||||
|
wcscpy(szNewSample, pszResultStr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||||
|
}
|
||||||
|
|
||||||
/* Replace standard negative sign to setted */
|
/* Replace standard negative sign to setted */
|
||||||
pszResultStr = ReplaceSubStr(szNewSample,
|
pszResultStr = ReplaceSubStr(szNewSample,
|
||||||
pGlobalData->szNumNegativeSign,
|
pGlobalData->szNumNegativeSign,
|
||||||
L"-");
|
L"-");
|
||||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
if (pszResultStr != NULL)
|
||||||
CB_ADDSTRING,
|
{
|
||||||
0,
|
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
||||||
(LPARAM)pszResultStr);
|
CB_ADDSTRING,
|
||||||
free(pszResultStr);
|
0,
|
||||||
|
(LPARAM)pszResultStr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set current item to value from registry */
|
/* Set current item to value from registry */
|
||||||
|
@ -320,11 +329,14 @@ InitLeadingZeroesCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
||||||
pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
|
pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
|
||||||
pGlobalData->szNumDecimalSep,
|
pGlobalData->szNumDecimalSep,
|
||||||
L",");
|
L",");
|
||||||
SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
if (pszResultStr != NULL)
|
||||||
CB_ADDSTRING,
|
{
|
||||||
0,
|
SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
||||||
(LPARAM)pszResultStr);
|
CB_ADDSTRING,
|
||||||
free(pszResultStr);
|
0,
|
||||||
|
(LPARAM)pszResultStr);
|
||||||
|
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set current item to value from registry */
|
/* Set current item to value from registry */
|
||||||
|
@ -692,7 +704,7 @@ NumbersPageProc(HWND hwndDlg,
|
||||||
if (!SetNumUnitsSys(hwndDlg, pGlobalData))
|
if (!SetNumUnitsSys(hwndDlg, pGlobalData))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
|
|
||||||
UpdateNumSamples(hwndDlg, pGlobalData);
|
UpdateNumSamples(hwndDlg, pGlobalData);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,231 +0,0 @@
|
||||||
/*
|
|
||||||
* PROJECT: ReactOS International Control Panel
|
|
||||||
* LICENSE: GPL - See COPYING in the top level directory
|
|
||||||
* FILE: dll/cpl/intl/setupreg.c
|
|
||||||
* PURPOSE: ReactOS International Control Panel
|
|
||||||
* PROGRAMMERS: Alexey Zavyalov (gen_x@mail.ru)
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* INCLUDES *****************************************************************/
|
|
||||||
|
|
||||||
#include "intl.h"
|
|
||||||
|
|
||||||
/* GLOBALS ******************************************************************/
|
|
||||||
|
|
||||||
#define NUM_SHEETS 4
|
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
|
||||||
|
|
||||||
/* Insert the space */
|
|
||||||
TCHAR*
|
|
||||||
InsSpacePos(const TCHAR *szInsStr, const int nPos)
|
|
||||||
{
|
|
||||||
LPTSTR pszDestStr;
|
|
||||||
int nDestStrCnt=0;
|
|
||||||
int nStrCnt;
|
|
||||||
int nStrSize;
|
|
||||||
|
|
||||||
pszDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR));
|
|
||||||
|
|
||||||
_tcscpy(pszDestStr, szInsStr);
|
|
||||||
|
|
||||||
nStrSize = _tcslen(szInsStr);
|
|
||||||
|
|
||||||
for (nStrCnt = 0; nStrCnt < nStrSize; nStrCnt++)
|
|
||||||
{
|
|
||||||
if (nStrCnt == nStrSize - nPos)
|
|
||||||
{
|
|
||||||
pszDestStr[nDestStrCnt] = _T(' ');
|
|
||||||
nDestStrCnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
pszDestStr[nDestStrCnt] = szInsStr[nStrCnt];
|
|
||||||
nDestStrCnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
pszDestStr[nDestStrCnt] = _T('\0');
|
|
||||||
|
|
||||||
return pszDestStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Insert the spaces by format string separated by ';' */
|
|
||||||
LPTSTR
|
|
||||||
InsSpacesFmt(const TCHAR *szSourceStr, const TCHAR *szFmtStr)
|
|
||||||
{
|
|
||||||
LPTSTR pszDestStr;
|
|
||||||
LPTSTR pszTempStr;
|
|
||||||
TCHAR szFmtVal[255];
|
|
||||||
int nFmtCount=0;
|
|
||||||
int nValCount=0;
|
|
||||||
int nLastVal=0;
|
|
||||||
int nSpaceOffset=0;
|
|
||||||
BOOL wasNul=FALSE;
|
|
||||||
|
|
||||||
pszDestStr = (LPTSTR) malloc(255 * sizeof(TCHAR));
|
|
||||||
|
|
||||||
_tcscpy(pszDestStr, szSourceStr);
|
|
||||||
|
|
||||||
/* If format is clean return source string */
|
|
||||||
if (!*szFmtStr)
|
|
||||||
return pszDestStr;
|
|
||||||
|
|
||||||
/* Search for all format values */
|
|
||||||
for (nFmtCount = 0; nFmtCount <= (int)_tcslen(szFmtStr); nFmtCount++)
|
|
||||||
{
|
|
||||||
if (szFmtStr[nFmtCount] == _T(';') || szFmtStr[nFmtCount] == _T('\0'))
|
|
||||||
{
|
|
||||||
if (_ttoi(szFmtVal) == 0 && !wasNul)
|
|
||||||
{
|
|
||||||
wasNul = TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If was 0, repeat spaces */
|
|
||||||
if (wasNul)
|
|
||||||
{
|
|
||||||
nSpaceOffset += nLastVal;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nSpaceOffset += _ttoi(szFmtVal);
|
|
||||||
}
|
|
||||||
|
|
||||||
szFmtVal[nValCount] = _T('\0');
|
|
||||||
nValCount=0;
|
|
||||||
|
|
||||||
/* Insert space to finded position plus all pos before */
|
|
||||||
pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
|
|
||||||
_tcscpy(pszDestStr, pszTempStr);
|
|
||||||
free(pszTempStr);
|
|
||||||
|
|
||||||
/* Num of spaces total increment */
|
|
||||||
if (!wasNul)
|
|
||||||
{
|
|
||||||
nSpaceOffset++;
|
|
||||||
nLastVal = _ttoi(szFmtVal);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
szFmtVal[nValCount++] = szFmtStr[nFmtCount];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create spaces for rest part of string */
|
|
||||||
if (wasNul && nLastVal!=0)
|
|
||||||
{
|
|
||||||
for (nFmtCount = nSpaceOffset + nLastVal; nFmtCount < _tcslen(pszDestStr); nFmtCount += nLastVal + 1)
|
|
||||||
{
|
|
||||||
pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
|
|
||||||
_tcscpy(pszDestStr,pszTempStr);
|
|
||||||
free(pszTempStr);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return pszDestStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Replace given template in source string with string to replace and return received string */
|
|
||||||
TCHAR*
|
|
||||||
ReplaceSubStr(const TCHAR *szSourceStr,
|
|
||||||
const TCHAR *szStrToReplace,
|
|
||||||
const TCHAR *szTempl)
|
|
||||||
{
|
|
||||||
int nCharCnt;
|
|
||||||
int nSubStrCnt;
|
|
||||||
int nDestStrCnt;
|
|
||||||
int nFirstCharCnt;
|
|
||||||
LPTSTR szDestStr;
|
|
||||||
|
|
||||||
szDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR));
|
|
||||||
nDestStrCnt = 0;
|
|
||||||
nFirstCharCnt = 0;
|
|
||||||
|
|
||||||
_tcscpy(szDestStr, _T(L""));
|
|
||||||
|
|
||||||
while (nFirstCharCnt < (int)_tcslen(szSourceStr))
|
|
||||||
{
|
|
||||||
if (szSourceStr[nFirstCharCnt] == szTempl[0])
|
|
||||||
{
|
|
||||||
nSubStrCnt=0;
|
|
||||||
for (nCharCnt = nFirstCharCnt; nCharCnt < nFirstCharCnt + (int)_tcslen(szTempl); nCharCnt++)
|
|
||||||
{
|
|
||||||
if (szSourceStr[nCharCnt] == szTempl[nSubStrCnt])
|
|
||||||
{
|
|
||||||
nSubStrCnt++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((int)_tcslen(szTempl) == nSubStrCnt)
|
|
||||||
{
|
|
||||||
_tcscat(szDestStr, szStrToReplace);
|
|
||||||
nDestStrCnt = (int)_tcslen(szDestStr);
|
|
||||||
nFirstCharCnt += (int)_tcslen(szTempl) - 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
szDestStr[nDestStrCnt++] = wszSourceStr[nFirstCharCnt];
|
|
||||||
szDestStr[nDestStrCnt] = _T('\0');
|
|
||||||
}
|
|
||||||
|
|
||||||
nFirstCharCnt++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return szDestStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static
|
|
||||||
VOID
|
|
||||||
InitPropSheetPage(PROPSHEETPAGE *PsPage, WORD IdDlg, DLGPROC DlgProc)
|
|
||||||
{
|
|
||||||
ZeroMemory(PsPage, sizeof(PROPSHEETPAGE));
|
|
||||||
PsPage->dwSize = sizeof(PROPSHEETPAGE);
|
|
||||||
PsPage->dwFlags = PSP_DEFAULT;
|
|
||||||
PsPage->hInstance = hApplet;
|
|
||||||
PsPage->pszTemplate = MAKEINTRESOURCE(IdDlg);
|
|
||||||
PsPage->pfnDlgProc = DlgProc;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Create applets */
|
|
||||||
LONG
|
|
||||||
APIENTRY
|
|
||||||
SetupApplet(HWND hwnd, UINT uMsg, LONG wParam, LONG lParam)
|
|
||||||
{
|
|
||||||
|
|
||||||
PROPSHEETPAGE PsPage[NUM_SHEETS];
|
|
||||||
PROPSHEETHEADER psh;
|
|
||||||
TCHAR Caption[MAX_STR_SIZE];
|
|
||||||
|
|
||||||
UNREFERENCED_PARAMETER(lParam);
|
|
||||||
UNREFERENCED_PARAMETER(wParam);
|
|
||||||
UNREFERENCED_PARAMETER(uMsg);
|
|
||||||
UNREFERENCED_PARAMETER(hwnd);
|
|
||||||
|
|
||||||
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
|
|
||||||
|
|
||||||
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
||||||
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
||||||
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
|
|
||||||
psh.hwndParent = NULL;
|
|
||||||
psh.hInstance = hApplet;
|
|
||||||
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
|
|
||||||
psh.pszCaption = Caption;
|
|
||||||
psh.nPages = sizeof(PsPage) / sizeof(PROPSHEETPAGE);
|
|
||||||
psh.nStartPage = 0;
|
|
||||||
psh.ppsp = PsPage;
|
|
||||||
|
|
||||||
InitPropSheetPage(&PsPage[0], IDD_NUMSOPTSSETUP, NumsOptsSetProc);
|
|
||||||
InitPropSheetPage(&PsPage[1], IDD_CURRENCYOPTSSETUP, CurrencyOptsSetProc);
|
|
||||||
InitPropSheetPage(&PsPage[2], IDD_TIMEOPTSSETUP, TimeOptsSetProc);
|
|
||||||
InitPropSheetPage(&PsPage[3], IDD_DATEOPTSSETUP, DateOptsSetProc);
|
|
||||||
|
|
||||||
return (LONG)(PropertySheet(&psh) != -1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* EOF */
|
|
|
@ -198,7 +198,7 @@ SortPageProc(HWND hwndDlg,
|
||||||
|
|
||||||
/* Save the new LCID */
|
/* Save the new LCID */
|
||||||
pGlobalData->UserLCID = NewLcid;
|
pGlobalData->UserLCID = NewLcid;
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,30 +53,40 @@ UpdateTimeSample(HWND hWnd, PGLOBALDATA pGlobalData)
|
||||||
static VOID
|
static VOID
|
||||||
GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
|
GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
|
||||||
{
|
{
|
||||||
int nIndex;
|
|
||||||
HWND hChildWnd;
|
HWND hChildWnd;
|
||||||
|
PWSTR tmp;
|
||||||
|
INT nIndex;
|
||||||
|
UINT uReqSize;
|
||||||
|
|
||||||
/* Get handle to time format control */
|
/* Get handle to time format control */
|
||||||
hChildWnd = GetDlgItem(hwndDlg, dwIdc);
|
hChildWnd = GetDlgItem(hwndDlg, dwIdc);
|
||||||
|
|
||||||
/* Get index to selected time format */
|
/* Get index to selected time format */
|
||||||
nIndex = SendMessageW(hChildWnd, CB_GETCURSEL, 0, 0);
|
nIndex = SendMessageW(hChildWnd, CB_GETCURSEL, 0, 0);
|
||||||
if (nIndex == CB_ERR)
|
if (nIndex == CB_ERR)
|
||||||
|
{
|
||||||
/* No selection? Get content of the edit control */
|
/* No selection? Get content of the edit control */
|
||||||
SendMessageW(hChildWnd, WM_GETTEXT, uSize, (LPARAM)Buffer);
|
SendMessageW(hChildWnd, WM_GETTEXT, uSize, (LPARAM)Buffer);
|
||||||
else {
|
}
|
||||||
PWSTR tmp;
|
else
|
||||||
UINT uReqSize;
|
{
|
||||||
|
|
||||||
/* Get requested size, including the null terminator;
|
/* Get requested size, including the null terminator;
|
||||||
* it shouldn't be required because the previous CB_LIMITTEXT,
|
* it shouldn't be required because the previous CB_LIMITTEXT,
|
||||||
* but it would be better to check it anyways */
|
* but it would be better to check it anyways */
|
||||||
uReqSize = SendMessageW(hChildWnd, CB_GETLBTEXTLEN, (WPARAM)nIndex, 0) + 1;
|
uReqSize = SendMessageW(hChildWnd, CB_GETLBTEXTLEN, (WPARAM)nIndex, 0) + 1;
|
||||||
|
|
||||||
/* Allocate enough space to be more safe */
|
/* Allocate enough space to be more safe */
|
||||||
tmp = (PWSTR)_alloca(uReqSize*sizeof(WCHAR));
|
tmp = (PWSTR)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, uReqSize * sizeof(WCHAR));
|
||||||
/* Get selected time format text */
|
if (tmp != NULL)
|
||||||
SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
|
{
|
||||||
/* Finally, copy the result into the output */
|
/* Get selected time format text */
|
||||||
wcsncpy(Buffer, tmp, uSize);
|
SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
|
||||||
|
|
||||||
|
/* Finally, copy the result into the output */
|
||||||
|
wcsncpy(Buffer, tmp, uSize);
|
||||||
|
|
||||||
|
HeapFree(GetProcessHeap(), 0, tmp);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,7 +267,7 @@ TimePageProc(HWND hwndDlg,
|
||||||
pGlobalData->szTimePM,
|
pGlobalData->szTimePM,
|
||||||
MAX_TIMEPMSYMBOL);
|
MAX_TIMEPMSYMBOL);
|
||||||
|
|
||||||
pGlobalData->fUserLocaleChanged = TRUE;
|
pGlobalData->bUserLocaleChanged = TRUE;
|
||||||
|
|
||||||
/* Update the time format sample */
|
/* Update the time format sample */
|
||||||
UpdateTimeSample(hwndDlg, pGlobalData);
|
UpdateTimeSample(hwndDlg, pGlobalData);
|
||||||
|
|
Loading…
Reference in a new issue