Release 980628
[wine/gsoc-2012-control.git] / controls / comctl32undoc.c
blob88b57d5b4e9f3da59abd34cc95385db44263977b
1 /*
2 * Undocumented functions from COMCTL32.DLL
4 * Copyright 1998 Eric Kohl <ekohl@abo.rhein-zeitung.de>
6 * NOTES
7 * All of these functions are UNDOCUMENTED!! And I mean UNDOCUMENTED!!!!
8 * Do NOT rely on names of undocumented structures and types!!!
9 * These functions are used by EXPLORER.EXE, IEXPLORE.EXE and
10 * COMCTL32.DLL (internally).
12 * TODO
13 * - Fix DSA_InsertItem.
14 * - Fix DSA_GetItem.
15 * - Write documentation.
18 #include <string.h>
19 #include "windows.h"
20 #include "heap.h"
21 #include "debug.h"
24 typedef struct _DSA_DATA
26 DWORD dwEntryCount;
27 DWORD dwMaxCount;
28 DWORD dwInitial;
29 DWORD dwGrow;
30 LPSTR *ptrs;
31 } DSA_DATA, *LPDSA_DATA;
34 typedef struct _DPA_DATA
36 DWORD dwEntryCount;
37 DWORD dwMaxCount;
38 DWORD dwGrow;
39 LPDWORD ptrs;
40 } DPA_DATA, *LPDPA_DATA;
43 DWORD WINAPI DSA_Create (DWORD, DWORD);
46 DWORD WINAPI DPA_Create (DWORD);
47 DWORD WINAPI DPA_GetPtr (DWORD, DWORD);
48 DWORD WINAPI DPA_InsertPtr (DWORD, DWORD, DWORD);
54 DWORD WINAPI
55 COMCTL32_Alloc (DWORD dwParam)
57 DWORD dwPtr;
59 dwPtr = (DWORD)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY, dwParam);
61 TRACE (commctrl, "(0x%08lx) ret=0x%08lx\n", dwParam, dwPtr);
63 return dwPtr;
67 DWORD WINAPI
68 COMCTL32_ReAlloc (DWORD dwParam1, DWORD dwParam2)
70 DWORD dwPtr;
72 if (dwParam1 == 0)
73 dwPtr = (DWORD)HeapAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
74 dwParam2);
75 else
76 dwPtr = (DWORD)HeapReAlloc (GetProcessHeap (), HEAP_ZERO_MEMORY,
77 (LPVOID)dwParam1, dwParam2);
79 TRACE (commctrl, "(0x%08lx 0x%08lx) ret=0x%08lx\n",
80 dwParam1, dwParam2, dwPtr);
82 return dwPtr;
86 DWORD WINAPI
87 COMCTL32_Free (DWORD dwParam)
89 TRACE (commctrl, "(0x%08lx)\n", dwParam);
90 HeapFree (GetProcessHeap (), 0, (LPVOID)dwParam);
92 return 0;
96 DWORD WINAPI
97 COMCTL32_GetSize (DWORD dwParam)
99 TRACE (commctrl, "(0x%08lx)\n", dwParam);
100 return (HeapSize (GetProcessHeap (), 0, (LPVOID)dwParam));
105 DWORD WINAPI
106 DSA_Create (DWORD dwParam1, DWORD dwParam2)
108 LPDSA_DATA dsaPtr;
110 dsaPtr = (LPDSA_DATA)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(DSA_DATA));
111 dsaPtr->dwInitial = dwParam1;
112 dsaPtr->dwGrow = dwParam2;
114 TRACE (commctrl, "(0x%08lx 0x%08lx) ret=0x%08lx\n",
115 dwParam1, dwParam2, (DWORD)dsaPtr);
117 return (DWORD)dsaPtr;
121 DWORD WINAPI
122 DSA_Destroy (DWORD dwParam1)
124 LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
125 DWORD i;
127 TRACE (commctrl, "(0x%08lx):semi-stub!\n", dwParam1);
129 if (dsaPtr->ptrs) {
130 for (i = 0; i < dsaPtr->dwEntryCount; i++) {
131 if (dsaPtr->ptrs[i])
132 HeapFree (SystemHeap, 0, (LPSTR)dsaPtr->ptrs[i]);
136 HeapFree (SystemHeap, 0, dsaPtr);
138 return 0;
142 DWORD WINAPI
143 DSA_GetItem (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
145 FIXME (commctrl, "(0x%08lx 0x%08lx 0x%08lx): stub!\n",
146 dwParam1, dwParam2, dwParam3);
148 return 0;
152 DWORD WINAPI
153 DSA_GetItemPtr (DWORD dwParam1, DWORD dwParam2)
155 LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
157 TRACE (commctrl, "(0x%08lx 0x%08lx)\n", dwParam1, dwParam2);
159 if (dsaPtr == NULL)
160 return 0;
161 if (dsaPtr->ptrs == NULL)
162 return 0;
163 if ((dwParam2 < 0) || (dwParam2 >= dsaPtr->dwEntryCount))
164 return 0;
166 TRACE (commctrl, "ret=0x%08lx\n", (DWORD)dsaPtr->ptrs[dwParam2]);
168 return (DWORD)dsaPtr->ptrs[dwParam2];
172 DWORD WINAPI
173 DSA_InsertItem (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
175 LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
176 DWORD dwIndex;
177 INT32 len;
179 TRACE (commctrl, "(0x%08lx 0x%08lx \"%s\"):semi-stub!\n",
180 dwParam1, dwParam2, (LPSTR)dwParam3);
182 if (dsaPtr->ptrs == NULL) {
183 dsaPtr->ptrs = (LPSTR*)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
184 dsaPtr->dwInitial * sizeof(LPVOID));
185 dsaPtr->dwMaxCount = dsaPtr->dwInitial;
186 dwIndex = 0;
187 len = lstrlen32A ((LPSTR)dwParam3);
188 dsaPtr->ptrs[dwIndex] =
189 (LPSTR)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, len+1);
190 lstrcpy32A (dsaPtr->ptrs[dwIndex], (LPSTR)dwParam3);
192 else {
193 TRACE (commctrl, "(0x%08lx 0x%08lx)\n",
194 dsaPtr->dwEntryCount, dsaPtr->dwMaxCount);
195 if (dwParam2 >= dsaPtr->dwEntryCount) {
196 if (dsaPtr->dwEntryCount < dsaPtr->dwMaxCount) {
197 dwIndex = dsaPtr->dwEntryCount;
198 len = lstrlen32A ((LPSTR)dwParam3);
199 dsaPtr->ptrs[dwIndex] =
200 (LPSTR)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, len+1);
201 lstrcpy32A (dsaPtr->ptrs[dwIndex], (LPSTR)dwParam3);
203 else {
204 FIXME (commctrl, "resizing array! stub!\n");
206 dwIndex = dwParam2;
210 else {
211 FIXME (commctrl, "inserting! stub!\n");
213 dwIndex = dwParam2;
217 dsaPtr->dwEntryCount++;
219 TRACE (commctrl, "ret=0x%08lx\n", dwIndex);
221 return (dwIndex);
227 DWORD WINAPI
228 DSA_DeleteItem (DWORD dwParam1, DWORD dwParam2)
230 LPDSA_DATA dsaPtr = (LPDSA_DATA)dwParam1;
232 TRACE (commctrl, "(0x%08lx 0x%08lx):semi-stub!\n",
233 dwParam1, dwParam2);
235 if (dsaPtr->ptrs) {
236 if (dsaPtr->dwEntryCount == 1) {
237 if (dsaPtr->ptrs[dwParam2])
238 HeapFree (SystemHeap, 0, dsaPtr->ptrs[dwParam2]);
239 dsaPtr->dwEntryCount--;
241 else {
242 LPSTR *oldPtrs = dsaPtr->ptrs;
243 TRACE (commctrl, "complex delete!\n");
245 if (dsaPtr->ptrs[dwParam2])
246 HeapFree (SystemHeap, 0, dsaPtr->ptrs[dwParam2]);
248 dsaPtr->dwEntryCount--;
249 dsaPtr->ptrs =
250 (LPSTR*)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
251 dsaPtr->dwEntryCount * sizeof(LPVOID));
252 if (dwParam2 > 0) {
253 memcpy (&dsaPtr->ptrs[0], &oldPtrs[0],
254 dwParam2 * sizeof(LPSTR));
257 if (dwParam2 < dsaPtr->dwEntryCount) {
258 memcpy (&dsaPtr->ptrs[dwParam2], &oldPtrs[dwParam2+1],
259 (dsaPtr->dwEntryCount - dwParam2) * sizeof(LPSTR));
261 HeapFree (SystemHeap, 0, oldPtrs);
264 if (dsaPtr->dwEntryCount == 0) {
265 HeapFree (SystemHeap, 0, dsaPtr->ptrs);
266 dsaPtr->ptrs = NULL;
270 return 0;
277 DWORD WINAPI
278 DPA_Create (DWORD dwParam1)
280 LPDPA_DATA dpaPtr;
282 TRACE (commctrl, "(0x%08lx)\n", dwParam1);
284 dpaPtr = (LPDPA_DATA)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY, sizeof(DPA_DATA));
285 dpaPtr->dwGrow = dwParam1;
287 TRACE (commctrl, "ret=0x%08lx\n", (DWORD)dpaPtr);
289 return (DWORD)dpaPtr;
294 DWORD WINAPI
295 DPA_GetPtr (DWORD dwParam1, DWORD dwParam2)
297 LPDPA_DATA dpaPtr = (LPDPA_DATA)dwParam1;
299 TRACE (commctrl, "(0x%08lx 0x%08lx)\n", dwParam1, dwParam2);
301 if (dpaPtr == NULL)
302 return 0;
303 if (dpaPtr->ptrs == NULL)
304 return 0;
305 if ((dwParam2 < 0) || (dwParam2 >= dpaPtr->dwEntryCount))
306 return 0;
308 TRACE (commctrl, "ret=0x%08lx\n", (DWORD)dpaPtr->ptrs[dwParam2]);
310 return (DWORD)dpaPtr->ptrs[dwParam2];
315 DWORD WINAPI
316 DPA_InsertPtr (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
318 LPDPA_DATA dpaPtr = (LPDPA_DATA)dwParam1;
319 DWORD dwIndex;
321 TRACE (commctrl, "(0x%08lx 0x%08lx 0x%lx)\n",
322 dwParam1, dwParam2, dwParam3);
324 if (dpaPtr->ptrs == NULL) {
325 dpaPtr->ptrs = (LPDWORD)HeapAlloc (SystemHeap, HEAP_ZERO_MEMORY,
326 dpaPtr->dwGrow * sizeof(LPVOID));
327 dpaPtr->dwMaxCount = dpaPtr->dwGrow;
328 dwIndex = 0;
329 dpaPtr->ptrs[dwIndex] = dwParam3;
331 else {
332 FIXME (commctrl, "adding to existing array! stub!\n");
335 dwIndex = dwParam2;
338 dpaPtr->dwEntryCount++;
340 return (dwIndex);
344 LPSTR WINAPI
345 COMCTL32_StrChrA (LPSTR lpString, CHAR cChar)
347 return strchr (lpString, cChar);