2007-09-02 20:42:08 +00:00
|
|
|
#include "intl.h"
|
|
|
|
|
|
|
|
#define NUM_SHEETS 4
|
|
|
|
|
|
|
|
/* Insert the space */
|
2007-09-05 14:24:45 +00:00
|
|
|
LPTSTR
|
|
|
|
InsSpacePos(LPCTSTR szInsStr, const int nPos)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
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++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
if (nStrCnt == nStrSize - nPos)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
pszDestStr[nDestStrCnt] = _T(' ');
|
2007-09-02 20:42:08 +00:00
|
|
|
nDestStrCnt++;
|
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
|
|
|
|
pszDestStr[nDestStrCnt] = szInsStr[nStrCnt];
|
2007-09-02 20:42:08 +00:00
|
|
|
nDestStrCnt++;
|
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
|
|
|
|
pszDestStr[nDestStrCnt] = _T('\0');
|
|
|
|
|
|
|
|
return pszDestStr;
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Insert the spaces by format string separated by ';' */
|
2007-09-05 14:24:45 +00:00
|
|
|
LPTSTR
|
|
|
|
InsSpacesFmt(LPCTSTR szSourceStr, LPCTSTR szFmtStr)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
LPTSTR pszDestStr;
|
|
|
|
LPTSTR pszTempStr;
|
|
|
|
TCHAR szFmtVal[255];
|
2008-05-06 20:51:07 +00:00
|
|
|
UINT nFmtCount = 0;
|
2007-09-05 14:24:45 +00:00
|
|
|
INT nValCount = 0;
|
|
|
|
INT nLastVal = 0;
|
|
|
|
INT nSpaceOffset = 0;
|
2007-09-02 20:42:08 +00:00
|
|
|
BOOL wasNul=FALSE;
|
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
pszDestStr = (LPTSTR)malloc(255 * sizeof(TCHAR));
|
|
|
|
|
|
|
|
_tcscpy(pszDestStr, szSourceStr);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* If format is clean return source string */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (!*szFmtStr)
|
|
|
|
return pszDestStr;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
/* Search for all format values */
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nFmtCount = 0; nFmtCount <= _tcslen(szFmtStr); nFmtCount++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
if (szFmtStr[nFmtCount] == _T(';') || szFmtStr[nFmtCount] == _T('\0'))
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
if (_ttoi(szFmtVal) == 0 && !wasNul)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
|
|
|
wasNul=TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* If was 0, repeat spaces */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (wasNul)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
nSpaceOffset += nLastVal;
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
nSpaceOffset += _ttoi(szFmtVal);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
|
|
|
|
szFmtVal[nValCount] = _T('\0');
|
2007-09-02 20:42:08 +00:00
|
|
|
nValCount=0;
|
2007-09-05 14:24:45 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Insert space to finded position plus all pos before */
|
2007-09-05 14:24:45 +00:00
|
|
|
pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset);
|
|
|
|
_tcscpy(pszDestStr,pszTempStr);
|
|
|
|
free(pszTempStr);
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Num of spaces total increment */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (!wasNul)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
|
|
|
nSpaceOffset++;
|
2007-09-05 14:24:45 +00:00
|
|
|
nLastVal = _ttoi(szFmtVal);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
szFmtVal[nValCount++] = szFmtStr[nFmtCount];
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Create spaces for rest part of string */
|
2007-09-05 14:24:45 +00:00
|
|
|
if (wasNul && nLastVal != 0)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
for (nFmtCount = nSpaceOffset + nLastVal; nFmtCount < _tcslen(pszDestStr); nFmtCount += nLastVal + 1)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
pszTempStr = InsSpacePos(pszDestStr, nFmtCount);
|
|
|
|
_tcscpy(pszDestStr, pszTempStr);
|
|
|
|
free(pszTempStr);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
return pszDestStr;
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Replace given template in source string with string to replace and return recieved string */
|
2007-09-05 14:24:45 +00:00
|
|
|
LPTSTR
|
|
|
|
ReplaceSubStr(LPCTSTR szSourceStr,
|
|
|
|
LPCTSTR szStrToReplace,
|
|
|
|
LPCTSTR szTempl)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
LPTSTR szDestStr;
|
2008-05-06 20:51:07 +00:00
|
|
|
UINT nCharCnt;
|
|
|
|
UINT nSubStrCnt;
|
|
|
|
UINT nDestStrCnt;
|
|
|
|
UINT nFirstCharCnt;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
szDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR));
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
nDestStrCnt = 0;
|
|
|
|
nFirstCharCnt = 0;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
_tcscpy(szDestStr, _T(""));
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
while (nFirstCharCnt < _tcslen(szSourceStr))
|
|
|
|
{
|
|
|
|
if (szSourceStr[nFirstCharCnt] == szTempl[0])
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
nSubStrCnt = 0;
|
|
|
|
for (nCharCnt = nFirstCharCnt; nCharCnt < nFirstCharCnt + _tcslen(szTempl); nCharCnt++)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
if (szSourceStr[nCharCnt] == szTempl[nSubStrCnt])
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
|
|
|
nSubStrCnt++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
|
|
|
|
if (_tcslen(szTempl) == nSubStrCnt)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
_tcscat(szDestStr, szStrToReplace);
|
|
|
|
nDestStrCnt = _tcslen(szDestStr);
|
|
|
|
nFirstCharCnt += _tcslen(szTempl) - 1;
|
2007-09-02 20:42:08 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
else
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-05 14:24:45 +00:00
|
|
|
szDestStr[nDestStrCnt++] = szSourceStr[nFirstCharCnt];
|
|
|
|
szDestStr[nDestStrCnt] = _T('\0');
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
2007-09-05 14:24:45 +00:00
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
nFirstCharCnt++;
|
2007-09-05 14:24:45 +00:00
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-05 14:24:45 +00:00
|
|
|
return szDestStr;
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
static VOID
|
2007-09-10 20:46:27 +00:00
|
|
|
InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBALDATA pGlobalData)
|
2007-09-08 22:27:41 +00:00
|
|
|
{
|
|
|
|
ZeroMemory(psp, sizeof(PROPSHEETPAGE));
|
|
|
|
psp->dwSize = sizeof(PROPSHEETPAGE);
|
|
|
|
psp->dwFlags = PSP_DEFAULT;
|
|
|
|
psp->hInstance = hApplet;
|
|
|
|
psp->pszTemplate = MAKEINTRESOURCE(idDlg);
|
|
|
|
psp->pfnDlgProc = DlgProc;
|
2007-09-10 20:46:27 +00:00
|
|
|
psp->lParam = (LPARAM)pGlobalData;
|
2007-09-08 22:27:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
/* Create applets */
|
|
|
|
LONG
|
|
|
|
APIENTRY
|
2008-11-14 19:08:29 +00:00
|
|
|
SetupApplet(HWND hwndDlg, LCID lcid)
|
2007-09-02 20:42:08 +00:00
|
|
|
{
|
2007-09-08 22:27:41 +00:00
|
|
|
PROPSHEETPAGE PsPage[NUM_SHEETS + 1];
|
2007-09-02 20:42:08 +00:00
|
|
|
PROPSHEETHEADER psh;
|
2007-09-10 20:46:27 +00:00
|
|
|
PGLOBALDATA pGlobalData;
|
2007-09-02 20:42:08 +00:00
|
|
|
TCHAR Caption[MAX_STR_SIZE];
|
2007-09-10 20:46:27 +00:00
|
|
|
INT ret;
|
2007-09-02 20:42:08 +00:00
|
|
|
|
|
|
|
LoadString(hApplet, IDS_CUSTOMIZE_TITLE, Caption, sizeof(Caption) / sizeof(TCHAR));
|
|
|
|
|
2007-09-10 20:46:27 +00:00
|
|
|
pGlobalData = (PGLOBALDATA)malloc(sizeof(GLOBALDATA));
|
|
|
|
|
|
|
|
pGlobalData->lcid = lcid;
|
|
|
|
|
2007-09-02 20:42:08 +00:00
|
|
|
ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
|
|
|
|
psh.dwSize = sizeof(PROPSHEETHEADER);
|
|
|
|
psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE;
|
2008-11-14 19:08:29 +00:00
|
|
|
psh.hwndParent = hwndDlg;
|
2007-09-02 20:42:08 +00:00
|
|
|
psh.hInstance = hApplet;
|
|
|
|
psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON));
|
|
|
|
psh.pszCaption = Caption;
|
2007-09-08 22:27:41 +00:00
|
|
|
psh.nPages = (sizeof(PsPage) / sizeof(PROPSHEETPAGE)) - 1;
|
2007-09-02 20:42:08 +00:00
|
|
|
psh.nStartPage = 0;
|
|
|
|
psh.ppsp = PsPage;
|
|
|
|
|
2007-09-10 20:46:27 +00:00
|
|
|
InitPropSheetPage(&PsPage[0], IDD_NUMBERSPAGE, NumbersPageProc, pGlobalData);
|
|
|
|
InitPropSheetPage(&PsPage[1], IDD_CURRENCYPAGE, CurrencyPageProc, pGlobalData);
|
|
|
|
InitPropSheetPage(&PsPage[2], IDD_TIMEPAGE, TimePageProc, pGlobalData);
|
|
|
|
InitPropSheetPage(&PsPage[3], IDD_DATEPAGE, DatePageProc, pGlobalData);
|
2007-09-08 22:27:41 +00:00
|
|
|
|
|
|
|
if (IsSortPageNeeded(lcid))
|
|
|
|
{
|
|
|
|
psh.nPages++;
|
2007-09-10 20:46:27 +00:00
|
|
|
InitPropSheetPage(&PsPage[4], IDD_SORTPAGE, SortPageProc, pGlobalData);
|
2007-09-08 22:27:41 +00:00
|
|
|
}
|
2007-09-02 20:42:08 +00:00
|
|
|
|
2007-09-10 20:46:27 +00:00
|
|
|
ret = PropertySheet(&psh);
|
|
|
|
|
|
|
|
free(pGlobalData);
|
|
|
|
|
|
|
|
return (LONG)(ret != -1);
|
2007-09-02 20:42:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|