ae85e94c9485d352cf417fa3a8c21b61b3c0c89a
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 *****************************************************************/
19 /* GLOBALS ******************************************************************/
23 /* FUNCTIONS ****************************************************************/
25 /* Insert the space */
27 InsSpacePos(const TCHAR
*szInsStr
, const int nPos
)
34 pszDestStr
= (LPTSTR
)malloc(MAX_SAMPLES_STR_SIZE
* sizeof(TCHAR
));
36 _tcscpy(pszDestStr
, szInsStr
);
38 nStrSize
= _tcslen(szInsStr
);
40 for (nStrCnt
= 0; nStrCnt
< nStrSize
; nStrCnt
++)
42 if (nStrCnt
== nStrSize
- nPos
)
44 pszDestStr
[nDestStrCnt
] = _T(' ');
48 pszDestStr
[nDestStrCnt
] = szInsStr
[nStrCnt
];
52 pszDestStr
[nDestStrCnt
] = _T('\0');
57 /* Insert the spaces by format string separated by ';' */
59 InsSpacesFmt(const TCHAR
*szSourceStr
, const TCHAR
*szFmtStr
)
70 pszDestStr
= (LPTSTR
) malloc(255 * sizeof(TCHAR
));
72 _tcscpy(pszDestStr
, szSourceStr
);
74 /* if format is clean return source string */
78 /* Search for all format values */
79 for (nFmtCount
= 0; nFmtCount
<= (int)_tcslen(szFmtStr
); nFmtCount
++)
81 if (szFmtStr
[nFmtCount
] == _T(';') || szFmtStr
[nFmtCount
] == _T('\0'))
83 if (_ttoi(szFmtVal
) == 0 && !wasNul
)
89 /* If was 0, repeat spaces */
92 nSpaceOffset
+= nLastVal
;
96 nSpaceOffset
+= _ttoi(szFmtVal
);
99 szFmtVal
[nValCount
] = _T('\0');
102 /* insert space to finded position plus all pos before */
103 pszTempStr
= InsSpacePos(pszDestStr
, nSpaceOffset
);
104 _tcscpy(pszDestStr
, pszTempStr
);
107 /* num of spaces total increment */
111 nLastVal
= _ttoi(szFmtVal
);
116 szFmtVal
[nValCount
++] = szFmtStr
[nFmtCount
];
120 /* Create spaces for rest part of string */
121 if (wasNul
&& nLastVal
!=0)
123 for (nFmtCount
= nSpaceOffset
+ nLastVal
; nFmtCount
< _tcslen(pszDestStr
); nFmtCount
+= nLastVal
+ 1)
125 pszTempStr
= InsSpacePos(pszDestStr
, nFmtCount
);
126 _tcscpy(pszDestStr
,pszTempStr
);
134 /* Replace given template in source string with string to replace and return recieved string */
136 ReplaceSubStr(const TCHAR
*szSourceStr
,
137 const TCHAR
*szStrToReplace
,
138 const TCHAR
*szTempl
)
146 szDestStr
= (LPTSTR
)malloc(MAX_SAMPLES_STR_SIZE
* sizeof(TCHAR
));
150 _tcscpy(szDestStr
, _T(L
""));
152 while (nFirstCharCnt
< (int)_tcslen(szSourceStr
))
154 if (szSourceStr
[nFirstCharCnt
] == szTempl
[0])
157 for (nCharCnt
= nFirstCharCnt
; nCharCnt
< nFirstCharCnt
+ (int)_tcslen(szTempl
); nCharCnt
++)
159 if (szSourceStr
[nCharCnt
] == szTempl
[nSubStrCnt
])
168 if ((int)_tcslen(szTempl
) == nSubStrCnt
)
170 _tcscat(szDestStr
, szStrToReplace
);
171 nDestStrCnt
= (int)_tcslen(szDestStr
);
172 nFirstCharCnt
+= (int)_tcslen(szTempl
) - 1;
179 szDestStr
[nDestStrCnt
++] = wszSourceStr
[nFirstCharCnt
];
180 szDestStr
[nDestStrCnt
] = _T('\0');
191 InitPropSheetPage(PROPSHEETPAGE
*PsPage
, WORD IdDlg
, DLGPROC DlgProc
)
193 ZeroMemory(PsPage
, sizeof(PROPSHEETPAGE
));
194 PsPage
->dwSize
= sizeof(PROPSHEETPAGE
);
195 PsPage
->dwFlags
= PSP_DEFAULT
;
196 PsPage
->hInstance
= hApplet
;
197 PsPage
->pszTemplate
= MAKEINTRESOURCE(IdDlg
);
198 PsPage
->pfnDlgProc
= DlgProc
;
204 SetupApplet(HWND hwnd
, UINT uMsg
, LONG wParam
, LONG lParam
)
207 PROPSHEETPAGE PsPage
[NUM_SHEETS
];
209 TCHAR Caption
[MAX_STR_SIZE
];
211 UNREFERENCED_PARAMETER(lParam
);
212 UNREFERENCED_PARAMETER(wParam
);
213 UNREFERENCED_PARAMETER(uMsg
);
214 UNREFERENCED_PARAMETER(hwnd
);
216 LoadString(hApplet
, IDS_CPLNAME
, Caption
, sizeof(Caption
) / sizeof(TCHAR
));
218 ZeroMemory(&psh
, sizeof(PROPSHEETHEADER
));
219 psh
.dwSize
= sizeof(PROPSHEETHEADER
);
220 psh
.dwFlags
= PSH_PROPSHEETPAGE
| PSH_USECALLBACK
| PSH_PROPTITLE
;
221 psh
.hwndParent
= NULL
;
222 psh
.hInstance
= hApplet
;
223 psh
.hIcon
= LoadIcon(hApplet
, MAKEINTRESOURCE(IDC_CPLICON
));
224 psh
.pszCaption
= Caption
;
225 psh
.nPages
= sizeof(PsPage
) / sizeof(PROPSHEETPAGE
);
229 InitPropSheetPage(&PsPage
[0], IDD_NUMSOPTSSETUP
, NumsOptsSetProc
);
230 InitPropSheetPage(&PsPage
[1], IDD_CURRENCYOPTSSETUP
, CurrencyOptsSetProc
);
231 InitPropSheetPage(&PsPage
[2], IDD_TIMEOPTSSETUP
, TimeOptsSetProc
);
232 InitPropSheetPage(&PsPage
[3], IDD_DATEOPTSSETUP
, DateOptsSetProc
);
234 return (LONG
)(PropertySheet(&psh
) != -1);