Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygenmisc.c
Go to the documentation of this file.
00001 #include "intl.h" 00002 00003 #define NUM_SHEETS 4 00004 00005 /* Insert the space */ 00006 LPTSTR 00007 InsSpacePos(LPCTSTR szInsStr, const int nPos) 00008 { 00009 LPTSTR pszDestStr; 00010 INT nDestStrCnt = 0; 00011 INT nStrCnt; 00012 INT nStrSize; 00013 00014 pszDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR)); 00015 00016 _tcscpy(pszDestStr, szInsStr); 00017 00018 nStrSize = _tcslen(szInsStr); 00019 00020 for (nStrCnt = 0; nStrCnt < nStrSize; nStrCnt++) 00021 { 00022 if (nStrCnt == nStrSize - nPos) 00023 { 00024 pszDestStr[nDestStrCnt] = _T(' '); 00025 nDestStrCnt++; 00026 } 00027 00028 pszDestStr[nDestStrCnt] = szInsStr[nStrCnt]; 00029 nDestStrCnt++; 00030 } 00031 00032 pszDestStr[nDestStrCnt] = _T('\0'); 00033 00034 return pszDestStr; 00035 } 00036 00037 /* Insert the spaces by format string separated by ';' */ 00038 LPTSTR 00039 InsSpacesFmt(LPCTSTR szSourceStr, LPCTSTR szFmtStr) 00040 { 00041 LPTSTR pszDestStr; 00042 LPTSTR pszTempStr; 00043 TCHAR szFmtVal[255]; 00044 UINT nFmtCount = 0; 00045 INT nValCount = 0; 00046 INT nLastVal = 0; 00047 INT nSpaceOffset = 0; 00048 BOOL wasNul=FALSE; 00049 00050 pszDestStr = (LPTSTR)malloc(255 * sizeof(TCHAR)); 00051 00052 _tcscpy(pszDestStr, szSourceStr); 00053 00054 /* If format is clean return source string */ 00055 if (!*szFmtStr) 00056 return pszDestStr; 00057 00058 /* Search for all format values */ 00059 for (nFmtCount = 0; nFmtCount <= _tcslen(szFmtStr); nFmtCount++) 00060 { 00061 if (szFmtStr[nFmtCount] == _T(';') || szFmtStr[nFmtCount] == _T('\0')) 00062 { 00063 if (_ttoi(szFmtVal) == 0 && !wasNul) 00064 { 00065 wasNul=TRUE; 00066 break; 00067 } 00068 00069 /* If was 0, repeat spaces */ 00070 if (wasNul) 00071 { 00072 nSpaceOffset += nLastVal; 00073 } 00074 else 00075 { 00076 nSpaceOffset += _ttoi(szFmtVal); 00077 } 00078 00079 szFmtVal[nValCount] = _T('\0'); 00080 nValCount=0; 00081 00082 /* Insert space to finded position plus all pos before */ 00083 pszTempStr = InsSpacePos(pszDestStr, nSpaceOffset); 00084 _tcscpy(pszDestStr,pszTempStr); 00085 free(pszTempStr); 00086 00087 /* Num of spaces total increment */ 00088 if (!wasNul) 00089 { 00090 nSpaceOffset++; 00091 nLastVal = _ttoi(szFmtVal); 00092 } 00093 } 00094 else 00095 { 00096 szFmtVal[nValCount++] = szFmtStr[nFmtCount]; 00097 } 00098 } 00099 00100 /* Create spaces for rest part of string */ 00101 if (wasNul && nLastVal != 0) 00102 { 00103 for (nFmtCount = nSpaceOffset + nLastVal; nFmtCount < _tcslen(pszDestStr); nFmtCount += nLastVal + 1) 00104 { 00105 pszTempStr = InsSpacePos(pszDestStr, nFmtCount); 00106 _tcscpy(pszDestStr, pszTempStr); 00107 free(pszTempStr); 00108 } 00109 } 00110 00111 return pszDestStr; 00112 } 00113 00114 /* Replace given template in source string with string to replace and return recieved string */ 00115 LPTSTR 00116 ReplaceSubStr(LPCTSTR szSourceStr, 00117 LPCTSTR szStrToReplace, 00118 LPCTSTR szTempl) 00119 { 00120 LPTSTR szDestStr; 00121 UINT nCharCnt; 00122 UINT nSubStrCnt; 00123 UINT nDestStrCnt; 00124 UINT nFirstCharCnt; 00125 00126 szDestStr = (LPTSTR)malloc(MAX_SAMPLES_STR_SIZE * sizeof(TCHAR)); 00127 00128 nDestStrCnt = 0; 00129 nFirstCharCnt = 0; 00130 00131 _tcscpy(szDestStr, _T("")); 00132 00133 while (nFirstCharCnt < _tcslen(szSourceStr)) 00134 { 00135 if (szSourceStr[nFirstCharCnt] == szTempl[0]) 00136 { 00137 nSubStrCnt = 0; 00138 for (nCharCnt = nFirstCharCnt; nCharCnt < nFirstCharCnt + _tcslen(szTempl); nCharCnt++) 00139 { 00140 if (szSourceStr[nCharCnt] == szTempl[nSubStrCnt]) 00141 { 00142 nSubStrCnt++; 00143 } 00144 else 00145 { 00146 break; 00147 } 00148 00149 if (_tcslen(szTempl) == nSubStrCnt) 00150 { 00151 _tcscat(szDestStr, szStrToReplace); 00152 nDestStrCnt = _tcslen(szDestStr); 00153 nFirstCharCnt += _tcslen(szTempl) - 1; 00154 break; 00155 } 00156 } 00157 } 00158 else 00159 { 00160 szDestStr[nDestStrCnt++] = szSourceStr[nFirstCharCnt]; 00161 szDestStr[nDestStrCnt] = _T('\0'); 00162 } 00163 00164 nFirstCharCnt++; 00165 } 00166 00167 return szDestStr; 00168 } 00169 00170 00171 static VOID 00172 InitPropSheetPage(PROPSHEETPAGE *psp, WORD idDlg, DLGPROC DlgProc, PGLOBALDATA pGlobalData) 00173 { 00174 ZeroMemory(psp, sizeof(PROPSHEETPAGE)); 00175 psp->dwSize = sizeof(PROPSHEETPAGE); 00176 psp->dwFlags = PSP_DEFAULT; 00177 psp->hInstance = hApplet; 00178 psp->pszTemplate = MAKEINTRESOURCE(idDlg); 00179 psp->pfnDlgProc = DlgProc; 00180 psp->lParam = (LPARAM)pGlobalData; 00181 } 00182 00183 00184 /* Create applets */ 00185 LONG 00186 APIENTRY 00187 SetupApplet(HWND hwndDlg, LCID lcid) 00188 { 00189 PROPSHEETPAGE PsPage[NUM_SHEETS + 1]; 00190 PROPSHEETHEADER psh; 00191 PGLOBALDATA pGlobalData; 00192 TCHAR Caption[MAX_STR_SIZE]; 00193 INT ret; 00194 00195 LoadString(hApplet, IDS_CUSTOMIZE_TITLE, Caption, sizeof(Caption) / sizeof(TCHAR)); 00196 00197 pGlobalData = (PGLOBALDATA)malloc(sizeof(GLOBALDATA)); 00198 00199 pGlobalData->lcid = lcid; 00200 00201 ZeroMemory(&psh, sizeof(PROPSHEETHEADER)); 00202 psh.dwSize = sizeof(PROPSHEETHEADER); 00203 psh.dwFlags = PSH_PROPSHEETPAGE | PSH_USECALLBACK | PSH_PROPTITLE; 00204 psh.hwndParent = hwndDlg; 00205 psh.hInstance = hApplet; 00206 psh.hIcon = LoadIcon(hApplet, MAKEINTRESOURCE(IDC_CPLICON)); 00207 psh.pszCaption = Caption; 00208 psh.nPages = (sizeof(PsPage) / sizeof(PROPSHEETPAGE)) - 1; 00209 psh.nStartPage = 0; 00210 psh.ppsp = PsPage; 00211 00212 InitPropSheetPage(&PsPage[0], IDD_NUMBERSPAGE, NumbersPageProc, pGlobalData); 00213 InitPropSheetPage(&PsPage[1], IDD_CURRENCYPAGE, CurrencyPageProc, pGlobalData); 00214 InitPropSheetPage(&PsPage[2], IDD_TIMEPAGE, TimePageProc, pGlobalData); 00215 InitPropSheetPage(&PsPage[3], IDD_DATEPAGE, DatePageProc, pGlobalData); 00216 00217 if (IsSortPageNeeded(lcid)) 00218 { 00219 psh.nPages++; 00220 InitPropSheetPage(&PsPage[4], IDD_SORTPAGE, SortPageProc, pGlobalData); 00221 } 00222 00223 ret = PropertySheet(&psh); 00224 00225 free(pGlobalData); 00226 00227 return (LONG)(ret != -1); 00228 } 00229 00230 /* EOF */ Generated on Fri May 25 2012 04:15:07 for ReactOS by
1.7.6.1
|