5 InsSpacePos(PCWSTR szInsStr
, const int nPos
)
12 pszDestStr
= (PWSTR
)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE
* sizeof(WCHAR
));
13 if (pszDestStr
== NULL
)
16 wcscpy(pszDestStr
, szInsStr
);
18 nStrSize
= wcslen(szInsStr
);
20 for (nStrCnt
= 0; nStrCnt
< nStrSize
; nStrCnt
++)
22 if (nStrCnt
== nStrSize
- nPos
)
24 pszDestStr
[nDestStrCnt
] = L
' ';
28 pszDestStr
[nDestStrCnt
] = szInsStr
[nStrCnt
];
32 pszDestStr
[nDestStrCnt
] = L
'\0';
37 /* Insert the spaces by format string separated by ';' */
39 InsSpacesFmt(PCWSTR szSourceStr
, PCWSTR szFmtStr
)
50 pszDestStr
= (PWSTR
)HeapAlloc(GetProcessHeap(), 0, 255 * sizeof(WCHAR
));
51 if (pszDestStr
== NULL
)
54 wcscpy(pszDestStr
, szSourceStr
);
56 /* If format is clean return source string */
60 /* Search for all format values */
61 for (nFmtCount
= 0; nFmtCount
<= wcslen(szFmtStr
); nFmtCount
++)
63 if (szFmtStr
[nFmtCount
] == L
';' || szFmtStr
[nFmtCount
] == L
'\0')
65 if (_wtoi(szFmtVal
) == 0 && !wasNul
)
71 /* If was 0, repeat spaces */
74 nSpaceOffset
+= nLastVal
;
78 nSpaceOffset
+= _wtoi(szFmtVal
);
81 szFmtVal
[nValCount
] = L
'\0';
84 /* Insert space to finded position plus all pos before */
85 pszTempStr
= InsSpacePos(pszDestStr
, nSpaceOffset
);
86 wcscpy(pszDestStr
,pszTempStr
);
87 HeapFree(GetProcessHeap(), 0, pszTempStr
);
89 /* Num of spaces total increment */
93 nLastVal
= _wtoi(szFmtVal
);
98 szFmtVal
[nValCount
++] = szFmtStr
[nFmtCount
];
102 /* Create spaces for rest part of string */
103 if (wasNul
&& nLastVal
!= 0)
105 for (nFmtCount
= nSpaceOffset
+ nLastVal
; nFmtCount
< wcslen(pszDestStr
); nFmtCount
+= nLastVal
+ 1)
107 pszTempStr
= InsSpacePos(pszDestStr
, nFmtCount
);
108 wcscpy(pszDestStr
, pszTempStr
);
109 HeapFree(GetProcessHeap(), 0, pszTempStr
);
116 /* Replace given template in source string with string to replace and return received string */
118 ReplaceSubStr(PCWSTR szSourceStr
,
119 PCWSTR szStrToReplace
,
128 szDestStr
= (PWSTR
)HeapAlloc(GetProcessHeap(), 0, MAX_SAMPLES_STR_SIZE
* sizeof(WCHAR
));
129 if (szDestStr
== NULL
)
135 wcscpy(szDestStr
, L
"");
137 while (nFirstCharCnt
< wcslen(szSourceStr
))
139 if (szSourceStr
[nFirstCharCnt
] == szTempl
[0])
142 for (nCharCnt
= nFirstCharCnt
; nCharCnt
< nFirstCharCnt
+ wcslen(szTempl
); nCharCnt
++)
144 if (szSourceStr
[nCharCnt
] == szTempl
[nSubStrCnt
])
153 if (wcslen(szTempl
) == nSubStrCnt
)
155 wcscat(szDestStr
, szStrToReplace
);
156 nDestStrCnt
= wcslen(szDestStr
);
157 nFirstCharCnt
+= wcslen(szTempl
) - 1;
164 szDestStr
[nDestStrCnt
++] = szSourceStr
[nFirstCharCnt
];
165 szDestStr
[nDestStrCnt
] = L
'\0';
176 GetSelectedComboBoxText(
187 /* Get handle to time format control */
188 hChildWnd
= GetDlgItem(hwndDlg
, nIdDlgItem
);
189 if (hChildWnd
== NULL
)
192 /* Get index to selected time format */
193 nIndex
= SendMessageW(hChildWnd
, CB_GETCURSEL
, 0, 0);
194 if (nIndex
== CB_ERR
)
196 /* No selection? Get content of the edit control */
197 SendMessageW(hChildWnd
, WM_GETTEXT
, uSize
, (LPARAM
)Buffer
);
201 /* Get requested size, including the null terminator;
202 * it shouldn't be required because the previous CB_LIMITTEXT,
203 * but it would be better to check it anyways */
204 uReqSize
= SendMessageW(hChildWnd
, CB_GETLBTEXTLEN
, (WPARAM
)nIndex
, 0) + 1;
206 /* Allocate enough space to be more safe */
207 tmp
= (PWSTR
)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, uReqSize
* sizeof(WCHAR
));
210 /* Get selected time format text */
211 SendMessageW(hChildWnd
, CB_GETLBTEXT
, (WPARAM
)nIndex
, (LPARAM
)tmp
);
213 /* Finally, copy the result into the output */
214 wcsncpy(Buffer
, tmp
, uSize
);
216 HeapFree(GetProcessHeap(), 0, tmp
);
223 GetSelectedComboBoxIndex(
228 *pValue
= SendDlgItemMessageW(hwndDlg
, nIdDlgItem
, CB_GETCURSEL
, 0, 0);