mirror of
https://github.com/reactos/reactos.git
synced 2025-02-23 08:55:19 +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)
|
||||
{
|
||||
index = SendMessageW(hLangList,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)lang);
|
||||
index = SendMessageW(hLangList,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)lang);
|
||||
|
||||
SendMessageW(hLangList,
|
||||
CB_SETITEMDATA,
|
||||
index,
|
||||
(LPARAM)lcid);
|
||||
SendMessageW(hLangList,
|
||||
CB_SETITEMDATA,
|
||||
index,
|
||||
(LPARAM)lcid);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -245,7 +245,10 @@ GetCurrentDPI(LPTSTR szDPI)
|
|||
return;
|
||||
}
|
||||
}
|
||||
else wsprintf(szDPI, L"%d", dwDPI);
|
||||
else
|
||||
{
|
||||
wsprintf(szDPI, L"%d", dwDPI);
|
||||
}
|
||||
|
||||
RegCloseKey(hKey);
|
||||
}
|
||||
|
@ -266,7 +269,6 @@ SaveFontSubstitutionSettings(
|
|||
wsprintf(szSection, L"Font.CP%s.%s", szDefCP, szDPI);
|
||||
|
||||
hFontInf = SetupOpenInfFileW(L"font.inf", NULL, INF_STYLE_WIN4, NULL);
|
||||
|
||||
if (hFontInf == INVALID_HANDLE_VALUE)
|
||||
return;
|
||||
|
||||
|
@ -277,12 +279,15 @@ SaveFontSubstitutionSettings(
|
|||
}
|
||||
|
||||
Count = (UINT) SetupGetLineCount(hFontInf, szSection);
|
||||
if (Count <= 0) return;
|
||||
if (Count <= 0)
|
||||
return;
|
||||
|
||||
if (!SetupInstallFromInfSectionW(hwnd, hFontInf, szSection, SPINST_REGISTRY & ~SPINST_FILES,
|
||||
NULL, NULL, 0, NULL, NULL, NULL, NULL))
|
||||
{
|
||||
MessageBoxW(hwnd, L"Unable to install a new language for programs don't support unicode!",
|
||||
NULL, MB_ICONERROR | MB_OK);
|
||||
}
|
||||
|
||||
SetupCloseInfFile(hFontInf);
|
||||
}
|
||||
|
@ -421,10 +426,7 @@ AdvancedPageProc(HWND hwndDlg,
|
|||
break;
|
||||
|
||||
case WM_NOTIFY:
|
||||
{
|
||||
LPNMHDR lpnm = (LPNMHDR)lParam;
|
||||
|
||||
if (lpnm->code == (UINT)PSN_APPLY)
|
||||
if (((LPNMHDR)lParam)->code == (UINT)PSN_APPLY)
|
||||
{
|
||||
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
|
||||
|
||||
|
@ -432,8 +434,7 @@ AdvancedPageProc(HWND hwndDlg,
|
|||
SaveFontSubstitutionSettings(hwndDlg, pGlobalData);
|
||||
SaveFontLinkingSettings(hwndDlg, pGlobalData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
|
|
|
@ -439,7 +439,7 @@ CurrencyPageProc(HWND hwndDlg,
|
|||
if (!SetCurrencyFieldSep(hwndDlg, pGlobalData))
|
||||
break;
|
||||
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
|
||||
UpdateExamples(hwndDlg, pGlobalData);
|
||||
}
|
||||
|
|
|
@ -55,9 +55,8 @@ FindDateSep(const WCHAR *szSourceStr)
|
|||
UINT nDateCompCount=0;
|
||||
UINT nDateSepCount=0;
|
||||
|
||||
pszFoundSep = (LPWSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
||||
|
||||
if(!pszFoundSep)
|
||||
pszFoundSep = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE * sizeof(WCHAR));
|
||||
if (pszFoundSep == NULL)
|
||||
return NULL;
|
||||
|
||||
wcscpy(pszFoundSep,STD_DATE_SEP);
|
||||
|
@ -171,15 +170,19 @@ SetShortDateFormat(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
|||
}
|
||||
|
||||
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 */
|
||||
wcscpy(szFoundDateSep, pszFoundSep);
|
||||
pszResultStr = ReplaceSubStr(szShortDateFmt, szShortDateSep, szFoundDateSep);
|
||||
wcscpy(szShortDateFmt, pszResultStr);
|
||||
free(pszResultStr);
|
||||
|
||||
if (pszFoundSep)
|
||||
free(pszFoundSep);
|
||||
HeapFree(GetProcessHeap(), 0, pszFoundSep);
|
||||
}
|
||||
|
||||
/* Save short date format */
|
||||
wcscpy(pGlobalData->szShortDateFormat, szShortDateFmt);
|
||||
|
@ -393,19 +396,19 @@ SetMaxDate(HWND hwndDlg, LCID lcid)
|
|||
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
|
||||
|
||||
/* Get spin value */
|
||||
nSpinVal=LOWORD(SendMessageW(hWndYearSpin,
|
||||
UDM_GETPOS,
|
||||
0,
|
||||
0));
|
||||
nSpinVal = LOWORD(SendMessageW(hWndYearSpin,
|
||||
UDM_GETPOS,
|
||||
0,
|
||||
0));
|
||||
|
||||
/* convert to wide char */
|
||||
_itow(nSpinVal, szMaxDateVal, DECIMAL_RADIX);
|
||||
|
||||
/* Save max date value */
|
||||
SetCalendarInfoW(lcid,
|
||||
CAL_GREGORIAN,
|
||||
48 , /* CAL_ITWODIGITYEARMAX */
|
||||
(PCWSTR)szMaxDateVal);
|
||||
CAL_GREGORIAN,
|
||||
48 , /* CAL_ITWODIGITYEARMAX */
|
||||
(PCWSTR)szMaxDateVal);
|
||||
}
|
||||
|
||||
/* Get max date value from registry set */
|
||||
|
@ -457,13 +460,13 @@ InitMinMaxDateSpin(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
|||
|
||||
/* Limit text lengths */
|
||||
SendDlgItemMessageW(hwndDlg, IDC_FIRSTYEAR_EDIT,
|
||||
EM_LIMITTEXT,
|
||||
MAX_YEAR_EDIT,
|
||||
0);
|
||||
EM_LIMITTEXT,
|
||||
MAX_YEAR_EDIT,
|
||||
0);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_SECONDYEAR_EDIT,
|
||||
EM_LIMITTEXT,
|
||||
MAX_YEAR_EDIT,
|
||||
0);
|
||||
EM_LIMITTEXT,
|
||||
MAX_YEAR_EDIT,
|
||||
0);
|
||||
|
||||
hWndYearSpin = GetDlgItem(hwndDlg, IDC_SCR_MAX_YEAR);
|
||||
|
||||
|
@ -584,7 +587,7 @@ DatePageProc(HWND hwndDlg,
|
|||
if (!SetShortDateSep(hwndDlg, pGlobalData))
|
||||
break;
|
||||
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
|
||||
SetMaxDate(hwndDlg, pGlobalData->UserLCID);
|
||||
InitShortDateCB(hwndDlg, pGlobalData);
|
||||
|
|
|
@ -1429,7 +1429,7 @@ GeneralPageProc(HWND hwndDlg,
|
|||
|
||||
SetNewLocale(pGlobalData, NewLcid);
|
||||
UpdateLocaleSample(hwndDlg, pGlobalData);
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
|
||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||
}
|
||||
|
@ -1456,7 +1456,7 @@ GeneralPageProc(HWND hwndDlg,
|
|||
break;
|
||||
|
||||
pGlobalData->geoid = NewGeoID;
|
||||
pGlobalData->fGeoIdChanged = TRUE;
|
||||
pGlobalData->bGeoIdChanged = TRUE;
|
||||
|
||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||
}
|
||||
|
@ -1466,7 +1466,7 @@ GeneralPageProc(HWND hwndDlg,
|
|||
if (CustomizeLocalePropertySheet(GetParent(hwndDlg), pGlobalData) > 0)
|
||||
{
|
||||
UpdateLocaleSample(hwndDlg, pGlobalData);
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
||||
}
|
||||
break;
|
||||
|
@ -1474,30 +1474,26 @@ GeneralPageProc(HWND hwndDlg,
|
|||
break;
|
||||
|
||||
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 */
|
||||
PropSheet_UnChanged(GetParent(hwndDlg), hwndDlg);
|
||||
|
||||
/* 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);
|
||||
SaveCurrentLocale(pGlobalData);
|
||||
pGlobalData->bUserLocaleChanged = FALSE;
|
||||
}
|
||||
|
||||
/* Set new GEO ID */
|
||||
if (pGlobalData->bGeoIdChanged == TRUE)
|
||||
{
|
||||
SaveGeoID(pGlobalData);
|
||||
pGlobalData->bGeoIdChanged = FALSE;
|
||||
}
|
||||
|
||||
AddNewKbLayoutsByLcid(pGlobalData->UserLCID);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,16 +51,16 @@ APPLET Applets[NUM_APPLETS] =
|
|||
VOID
|
||||
PrintErrorMsgBox(UINT msg)
|
||||
{
|
||||
TCHAR szErrorText[BUFFERSIZE];
|
||||
TCHAR szErrorCaption[BUFFERSIZE];
|
||||
WCHAR szErrorText[BUFFERSIZE];
|
||||
WCHAR szErrorCaption[BUFFERSIZE];
|
||||
|
||||
LoadString(hApplet, msg, szErrorText, sizeof(szErrorText)/sizeof(TCHAR));
|
||||
LoadString(hApplet, IDS_ERROR, szErrorCaption, sizeof(szErrorCaption)/sizeof(TCHAR));
|
||||
LoadStringW(hApplet, msg, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
||||
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(
|
||||
HWND hwnd,
|
||||
UINT uType,
|
||||
|
@ -73,7 +73,7 @@ ResourceMessageBox(
|
|||
LoadStringW(hApplet, uMessageId, szErrorText, sizeof(szErrorText) / sizeof(WCHAR));
|
||||
LoadStringW(hApplet, uCaptionId, szErrorCaption, sizeof(szErrorCaption) / sizeof(WCHAR));
|
||||
|
||||
MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
|
||||
return MessageBoxW(hwnd, szErrorText, szErrorCaption, uType);
|
||||
}
|
||||
|
||||
static VOID
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
#include <winuser.h>
|
||||
#include <cpl.h>
|
||||
#include <setupapi.h>
|
||||
#include <malloc.h>
|
||||
#include <ndk/exfuncs.h>
|
||||
|
||||
#include "resource.h"
|
||||
|
@ -110,11 +109,11 @@ typedef struct _GLOBALDATA
|
|||
|
||||
LCID UserLCID;
|
||||
LCID SystemLCID;
|
||||
BOOL fUserLocaleChanged;
|
||||
BOOL bUserLocaleChanged;
|
||||
BOOL bApplyToDefaultUser;
|
||||
|
||||
GEOID geoid;
|
||||
BOOL fGeoIdChanged;
|
||||
BOOL bGeoIdChanged;
|
||||
|
||||
/* Misc */
|
||||
BOOL bIsUserAdmin;
|
||||
|
@ -134,7 +133,7 @@ extern GROUPINGDATA GroupingFormats[MAX_GROUPINGFORMATS];
|
|||
/* intl.c */
|
||||
VOID PrintErrorMsgBox(UINT msg);
|
||||
|
||||
VOID
|
||||
INT
|
||||
ResourceMessageBox(
|
||||
HWND hwnd,
|
||||
UINT uType,
|
||||
|
|
|
@ -9,7 +9,9 @@ InsSpacePos(PCWSTR szInsStr, const int nPos)
|
|||
INT nStrCnt;
|
||||
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);
|
||||
|
||||
|
@ -45,7 +47,9 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
|
|||
INT nSpaceOffset = 0;
|
||||
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);
|
||||
|
||||
|
@ -80,7 +84,7 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
|
|||
/* Insert space to finded position plus all pos before */
|
||||
pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
|
||||
wcscpy(pszDestStr,pszTempStr);
|
||||
free(pszTempStr);
|
||||
HeapFree(GetProcessHeap(), 0, pszTempStr);
|
||||
|
||||
/* Num of spaces total increment */
|
||||
if (!wasNul)
|
||||
|
@ -102,7 +106,7 @@ InsSpacesFmt(PCWSTR szSourceStr, PCWSTR szFmtStr)
|
|||
{
|
||||
pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
|
||||
wcscpy(pszDestStr, pszTempStr);
|
||||
free(pszTempStr);
|
||||
HeapFree(GetProcessHeap(), 0, pszTempStr);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -121,7 +125,9 @@ ReplaceSubStr(PCWSTR szSourceStr,
|
|||
UINT nDestStrCnt;
|
||||
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;
|
||||
nFirstCharCnt = 0;
|
||||
|
|
|
@ -198,11 +198,14 @@ InitFieldDigNumCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
|||
for (nCBIndex = 0; nCBIndex < MAX_FIELD_DIG_SAMPLES; nCBIndex++)
|
||||
{
|
||||
pszFieldDigNumSmpl = InsSpacesFmt(SAMPLE_NUMBER, lpFieldDigNumSamples[nCBIndex]);
|
||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszFieldDigNumSmpl);
|
||||
free(pszFieldDigNumSmpl);
|
||||
if (pszFieldDigNumSmpl != NULL)
|
||||
{
|
||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszFieldDigNumSmpl);
|
||||
HeapFree(GetProcessHeap(), 0, pszFieldDigNumSmpl);
|
||||
}
|
||||
}
|
||||
|
||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSDGROUPING,
|
||||
|
@ -280,18 +283,24 @@ InitNegNumFmtCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
|||
pszResultStr = ReplaceSubStr(lpNegNumFmtSamples[nCBIndex],
|
||||
pGlobalData->szNumDecimalSep,
|
||||
L",");
|
||||
wcscpy(szNewSample, pszResultStr);
|
||||
free(pszResultStr);
|
||||
if (pszResultStr != NULL)
|
||||
{
|
||||
wcscpy(szNewSample, pszResultStr);
|
||||
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||
}
|
||||
|
||||
/* Replace standard negative sign to setted */
|
||||
pszResultStr = ReplaceSubStr(szNewSample,
|
||||
pGlobalData->szNumNegativeSign,
|
||||
L"-");
|
||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszResultStr);
|
||||
free(pszResultStr);
|
||||
if (pszResultStr != NULL)
|
||||
{
|
||||
SendDlgItemMessageW(hwndDlg, IDC_NUMBERSNNUMFORMAT,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszResultStr);
|
||||
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set current item to value from registry */
|
||||
|
@ -320,11 +329,14 @@ InitLeadingZeroesCB(HWND hwndDlg, PGLOBALDATA pGlobalData)
|
|||
pszResultStr = ReplaceSubStr(lpLeadNumFmtSamples[nCBIndex],
|
||||
pGlobalData->szNumDecimalSep,
|
||||
L",");
|
||||
SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszResultStr);
|
||||
free(pszResultStr);
|
||||
if (pszResultStr != NULL)
|
||||
{
|
||||
SendDlgItemMessage(hwndDlg, IDC_NUMBERSDISPLEADZER,
|
||||
CB_ADDSTRING,
|
||||
0,
|
||||
(LPARAM)pszResultStr);
|
||||
HeapFree(GetProcessHeap(), 0, pszResultStr);
|
||||
}
|
||||
}
|
||||
|
||||
/* Set current item to value from registry */
|
||||
|
@ -692,7 +704,7 @@ NumbersPageProc(HWND hwndDlg,
|
|||
if (!SetNumUnitsSys(hwndDlg, pGlobalData))
|
||||
break;
|
||||
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
|
||||
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 */
|
||||
pGlobalData->UserLCID = NewLcid;
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -53,30 +53,40 @@ UpdateTimeSample(HWND hWnd, PGLOBALDATA pGlobalData)
|
|||
static VOID
|
||||
GetSelectedComboEntry(HWND hwndDlg, DWORD dwIdc, WCHAR *Buffer, UINT uSize)
|
||||
{
|
||||
int nIndex;
|
||||
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 {
|
||||
PWSTR tmp;
|
||||
UINT uReqSize;
|
||||
|
||||
}
|
||||
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)_alloca(uReqSize*sizeof(WCHAR));
|
||||
/* Get selected time format text */
|
||||
SendMessageW(hChildWnd, CB_GETLBTEXT, (WPARAM)nIndex, (LPARAM)tmp);
|
||||
/* Finally, copy the result into the output */
|
||||
wcsncpy(Buffer, tmp, uSize);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -239,7 +249,7 @@ TimePageProc(HWND hwndDlg,
|
|||
{
|
||||
/* Get selected/typed time format text */
|
||||
GetSelectedComboEntry(hwndDlg, IDC_TIMEFORMAT,
|
||||
pGlobalData->szTimeFormat,
|
||||
pGlobalData->szTimeFormat,
|
||||
MAX_TIMEFORMAT);
|
||||
|
||||
/* Get selected/typed time separator text */
|
||||
|
@ -257,7 +267,7 @@ TimePageProc(HWND hwndDlg,
|
|||
pGlobalData->szTimePM,
|
||||
MAX_TIMEPMSYMBOL);
|
||||
|
||||
pGlobalData->fUserLocaleChanged = TRUE;
|
||||
pGlobalData->bUserLocaleChanged = TRUE;
|
||||
|
||||
/* Update the time format sample */
|
||||
UpdateTimeSample(hwndDlg, pGlobalData);
|
||||
|
|
Loading…
Reference in a new issue