2 * PROJECT: ReactOS International Control Panel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: dll/cpl/intl/setupreg.c
5 * PURPOSE: ReactOS International Control Panel
6 * PROGRAMMERS: Alexey Zavyalov (gen_x@mail.ru)
9 /* INCLUDES *****************************************************************/
13 /* GLOBALS ******************************************************************/
17 /* FUNCTIONS ****************************************************************/
19 /* Insert the space */
21 InsSpacePos(const TCHAR
*szInsStr
, const int nPos
)
28 pszDestStr
= (LPTSTR
)malloc(MAX_SAMPLES_STR_SIZE
* sizeof(TCHAR
));
30 _tcscpy(pszDestStr
, szInsStr
);
32 nStrSize
= _tcslen(szInsStr
);
34 for (nStrCnt
= 0; nStrCnt
< nStrSize
; nStrCnt
++)
36 if (nStrCnt
== nStrSize
- nPos
)
38 pszDestStr
[nDestStrCnt
] = _T(' ');
42 pszDestStr
[nDestStrCnt
] = szInsStr
[nStrCnt
];
46 pszDestStr
[nDestStrCnt
] = _T('\0');
51 /* Insert the spaces by format string separated by ';' */
53 InsSpacesFmt(const TCHAR
*szSourceStr
, const TCHAR
*szFmtStr
)
64 pszDestStr
= (LPTSTR
) malloc(255 * sizeof(TCHAR
));
66 _tcscpy(pszDestStr
, szSourceStr
);
68 /* If format is clean return source string */
72 /* Search for all format values */
73 for (nFmtCount
= 0; nFmtCount
<= (int)_tcslen(szFmtStr
); nFmtCount
++)
75 if (szFmtStr
[nFmtCount
] == _T(';') || szFmtStr
[nFmtCount
] == _T('\0'))
77 if (_ttoi(szFmtVal
) == 0 && !wasNul
)
83 /* If was 0, repeat spaces */
86 nSpaceOffset
+= nLastVal
;
90 nSpaceOffset
+= _ttoi(szFmtVal
);
93 szFmtVal
[nValCount
] = _T('\0');
96 /* Insert space to finded position plus all pos before */
97 pszTempStr
= InsSpacePos(pszDestStr
, nSpaceOffset
);
98 _tcscpy(pszDestStr
, pszTempStr
);
101 /* Num of spaces total increment */
105 nLastVal
= _ttoi(szFmtVal
);
110 szFmtVal
[nValCount
++] = szFmtStr
[nFmtCount
];
114 /* Create spaces for rest part of string */
115 if (wasNul
&& nLastVal
!=0)
117 for (nFmtCount
= nSpaceOffset
+ nLastVal
; nFmtCount
< _tcslen(pszDestStr
); nFmtCount
+= nLastVal
+ 1)
119 pszTempStr
= InsSpacePos(pszDestStr
, nFmtCount
);
120 _tcscpy(pszDestStr
,pszTempStr
);
128 /* Replace given template in source string with string to replace and return received string */
130 ReplaceSubStr(const TCHAR
*szSourceStr
,
131 const TCHAR
*szStrToReplace
,
132 const TCHAR
*szTempl
)
140 szDestStr
= (LPTSTR
)malloc(MAX_SAMPLES_STR_SIZE
* sizeof(TCHAR
));
144 _tcscpy(szDestStr
, _T(L
""));
146 while (nFirstCharCnt
< (int)_tcslen(szSourceStr
))
148 if (szSourceStr
[nFirstCharCnt
] == szTempl
[0])
151 for (nCharCnt
= nFirstCharCnt
; nCharCnt
< nFirstCharCnt
+ (int)_tcslen(szTempl
); nCharCnt
++)
153 if (szSourceStr
[nCharCnt
] == szTempl
[nSubStrCnt
])
162 if ((int)_tcslen(szTempl
) == nSubStrCnt
)
164 _tcscat(szDestStr
, szStrToReplace
);
165 nDestStrCnt
= (int)_tcslen(szDestStr
);
166 nFirstCharCnt
+= (int)_tcslen(szTempl
) - 1;
173 szDestStr
[nDestStrCnt
++] = wszSourceStr
[nFirstCharCnt
];
174 szDestStr
[nDestStrCnt
] = _T('\0');
185 InitPropSheetPage(PROPSHEETPAGE
*PsPage
, WORD IdDlg
, DLGPROC DlgProc
)
187 ZeroMemory(PsPage
, sizeof(PROPSHEETPAGE
));
188 PsPage
->dwSize
= sizeof(PROPSHEETPAGE
);
189 PsPage
->dwFlags
= PSP_DEFAULT
;
190 PsPage
->hInstance
= hApplet
;
191 PsPage
->pszTemplate
= MAKEINTRESOURCE(IdDlg
);
192 PsPage
->pfnDlgProc
= DlgProc
;
198 SetupApplet(HWND hwnd
, UINT uMsg
, LONG wParam
, LONG lParam
)
201 PROPSHEETPAGE PsPage
[NUM_SHEETS
];
203 TCHAR Caption
[MAX_STR_SIZE
];
205 UNREFERENCED_PARAMETER(lParam
);
206 UNREFERENCED_PARAMETER(wParam
);
207 UNREFERENCED_PARAMETER(uMsg
);
208 UNREFERENCED_PARAMETER(hwnd
);
210 LoadString(hApplet
, IDS_CPLNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
212 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
213 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
214 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_USECALLBACK
| PSH_PROPTITLE
;
215 psh
.hwndParent
= NULL
;
216 psh
.hInstance
= hApplet
;
217 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON
));
218 psh
.pszCaption
= Caption
;
219 psh
.nPages
= sizeof(PsPage
) / sizeof(PROPSHEETPAGE
);
223 InitPropSheetPage(&PsPage
[0], IDD_NUMSOPTSSETUP
, NumsOptsSetProc
);
224 InitPropSheetPage(&PsPage
[1], IDD_CURRENCYOPTSSETUP
, CurrencyOptsSetProc
);
225 InitPropSheetPage(&PsPage
[2], IDD_TIMEOPTSSETUP
, TimeOptsSetProc
);
226 InitPropSheetPage(&PsPage
[3], IDD_DATEOPTSSETUP
, DateOptsSetProc
);
228 return (LONG
)(PropertySheet(&psh
) != -1);