1 | /* $Id: comctl32undoc.c,v 1.7 1999-06-23 19:45:00 achimha Exp $ */
|
---|
2 | /*
|
---|
3 | * Undocumented functions from COMCTL32.DLL
|
---|
4 | *
|
---|
5 | * Copyright (C) 1999 Achim Hasenmueller
|
---|
6 | *
|
---|
7 | * Based on the work of the WINE group (www.winehq.com)
|
---|
8 | *
|
---|
9 | *
|
---|
10 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
11 | *
|
---|
12 | */
|
---|
13 |
|
---|
14 | #include "comctl32.h"
|
---|
15 | #include <memory.h>
|
---|
16 | #include <string.h>
|
---|
17 | #include <stdlib.h>
|
---|
18 | #include <ctype.h>
|
---|
19 |
|
---|
20 | extern HANDLE COMCTL32_hHeap; /* handle to the private heap */
|
---|
21 |
|
---|
22 | /**************************************************************************
|
---|
23 | * DPA_Merge [COMCTL32.11]
|
---|
24 | *
|
---|
25 | * PARAMS
|
---|
26 | * hdpa1 [I] handle to a dynamic pointer array
|
---|
27 | * hdpa2 [I] handle to a dynamic pointer array
|
---|
28 | * dwFlags [I] flags
|
---|
29 | * pfnSort [I] pointer to sort function
|
---|
30 | * dwParam5 [I]
|
---|
31 | * lParam [I] application specific value
|
---|
32 | *
|
---|
33 | * NOTES
|
---|
34 | * No more information available yet!
|
---|
35 | */
|
---|
36 |
|
---|
37 | BOOL WINAPI
|
---|
38 | DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
|
---|
39 | PFNDPACOMPARE pfnCompare, LPVOID pfnParam5, LPARAM lParam)
|
---|
40 | {
|
---|
41 | /* LPVOID *pWork1, *pWork2; */
|
---|
42 | INT nCount1, nCount2;
|
---|
43 |
|
---|
44 | // TRACE (commctrl, "(%p %p %08lx %p %p %08lx): stub!\n",
|
---|
45 | // hdpa1, hdpa2, dwFlags, pfnCompare, pfnParam5, lParam);
|
---|
46 |
|
---|
47 | if (IsBadWritePtr (hdpa1, sizeof(DPA)))
|
---|
48 | return FALSE;
|
---|
49 |
|
---|
50 | if (IsBadWritePtr (hdpa2, sizeof(DPA)))
|
---|
51 | return FALSE;
|
---|
52 |
|
---|
53 | if (IsBadCodePtr ((FARPROC)pfnCompare))
|
---|
54 | return FALSE;
|
---|
55 |
|
---|
56 | if (IsBadCodePtr ((FARPROC)pfnParam5))
|
---|
57 | return FALSE;
|
---|
58 |
|
---|
59 | if (dwFlags & DPAM_SORT) {
|
---|
60 | // TRACE (commctrl, "sorting dpa's!\n");
|
---|
61 | DPA_Sort (hdpa1, pfnCompare, lParam);
|
---|
62 | DPA_Sort (hdpa2, pfnCompare, lParam);
|
---|
63 | }
|
---|
64 |
|
---|
65 | if (hdpa2->nItemCount <= 0)
|
---|
66 | return TRUE;
|
---|
67 |
|
---|
68 | nCount1 = hdpa1->nItemCount - 1;
|
---|
69 |
|
---|
70 | nCount2 = hdpa2->nItemCount - 1;
|
---|
71 |
|
---|
72 | // FIXME (commctrl, "nCount1=%d nCount2=%d\n", nCount1, nCount2);
|
---|
73 | // FIXME (commctrl, "semi stub!\n");
|
---|
74 | #if 0
|
---|
75 |
|
---|
76 | do {
|
---|
77 |
|
---|
78 |
|
---|
79 | if (nResult == 0) {
|
---|
80 |
|
---|
81 | }
|
---|
82 | else if (nResult > 0) {
|
---|
83 |
|
---|
84 | }
|
---|
85 | else {
|
---|
86 |
|
---|
87 | }
|
---|
88 |
|
---|
89 | }
|
---|
90 | while (nCount2 >= 0);
|
---|
91 |
|
---|
92 | #endif
|
---|
93 |
|
---|
94 |
|
---|
95 | return TRUE;
|
---|
96 | }
|
---|
97 |
|
---|
98 |
|
---|
99 | /**************************************************************************
|
---|
100 | * Alloc [COMCTL32.71]
|
---|
101 | *
|
---|
102 | * Allocates memory block from the dll's private heap
|
---|
103 | *
|
---|
104 | * PARAMS
|
---|
105 | * dwSize [I] size of the allocated memory block
|
---|
106 | *
|
---|
107 | * RETURNS
|
---|
108 | * Success: pointer to allocated memory block
|
---|
109 | * Failure: NULL
|
---|
110 | */
|
---|
111 |
|
---|
112 |
|
---|
113 | LPVOID WINAPI COMCTL32_Alloc (DWORD dwSize)
|
---|
114 | {
|
---|
115 | LPVOID lpPtr;
|
---|
116 |
|
---|
117 | lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
|
---|
118 |
|
---|
119 | return lpPtr;
|
---|
120 | }
|
---|
121 |
|
---|
122 |
|
---|
123 | /**************************************************************************
|
---|
124 | * ReAlloc [COMCTL32.72]
|
---|
125 | *
|
---|
126 | * Changes the size of an allocated memory block or allocates a memory
|
---|
127 | * block using the dll's private heap.
|
---|
128 | *
|
---|
129 | * PARAMS
|
---|
130 | * lpSrc [I] pointer to memory block which will be resized
|
---|
131 | * dwSize [I] new size of the memory block.
|
---|
132 | *
|
---|
133 | * RETURNS
|
---|
134 | * Success: pointer to the resized memory block
|
---|
135 | * Failure: NULL
|
---|
136 | *
|
---|
137 | * NOTES
|
---|
138 | * If lpSrc is a NULL-pointer, then COMCTL32_ReAlloc allocates a memory
|
---|
139 | * block like COMCTL32_Alloc.
|
---|
140 | */
|
---|
141 |
|
---|
142 | LPVOID WINAPI COMCTL32_ReAlloc (LPVOID lpSrc, DWORD dwSize)
|
---|
143 | {
|
---|
144 | LPVOID lpDest;
|
---|
145 |
|
---|
146 | if (lpSrc)
|
---|
147 | lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
|
---|
148 | else
|
---|
149 | lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
|
---|
150 |
|
---|
151 | return lpDest;
|
---|
152 | }
|
---|
153 |
|
---|
154 |
|
---|
155 | /**************************************************************************
|
---|
156 | * Free [COMCTL32.73]
|
---|
157 | *
|
---|
158 | * Frees an allocated memory block from the dll's private heap.
|
---|
159 | *
|
---|
160 | * PARAMS
|
---|
161 | * lpMem [I] pointer to memory block which will be freed
|
---|
162 | *
|
---|
163 | * RETURNS
|
---|
164 | * Success: TRUE
|
---|
165 | * Failure: FALSE
|
---|
166 | */
|
---|
167 |
|
---|
168 | BOOL WINAPI COMCTL32_Free (LPVOID lpMem)
|
---|
169 | {
|
---|
170 | return HeapFree (COMCTL32_hHeap, 0, lpMem);
|
---|
171 | }
|
---|
172 |
|
---|
173 |
|
---|
174 | /**************************************************************************
|
---|
175 | * GetSize [COMCTL32.74]
|
---|
176 | *
|
---|
177 | * Retrieves the size of the specified memory block from the dll's
|
---|
178 | * private heap.
|
---|
179 | *
|
---|
180 | * PARAMS
|
---|
181 | * lpMem [I] pointer to an allocated memory block
|
---|
182 | *
|
---|
183 | * RETURNS
|
---|
184 | * Success: size of the specified memory block
|
---|
185 | * Failure: 0
|
---|
186 | */
|
---|
187 |
|
---|
188 | DWORD WINAPI COMCTL32_GetSize (LPVOID lpMem)
|
---|
189 | {
|
---|
190 |
|
---|
191 | return HeapSize (COMCTL32_hHeap, 0, lpMem);
|
---|
192 | }
|
---|
193 |
|
---|
194 |
|
---|
195 | /**************************************************************************
|
---|
196 | * The MRU-API is a set of functions to manipulate MRU(Most Recently Used)
|
---|
197 | * lists.
|
---|
198 | *
|
---|
199 | *
|
---|
200 | */
|
---|
201 |
|
---|
202 | typedef struct tagMRUINFO
|
---|
203 | {
|
---|
204 | DWORD dwParam1;
|
---|
205 | DWORD dwParam2;
|
---|
206 | DWORD dwParam3;
|
---|
207 | HKEY hkeyMain;
|
---|
208 | LPCSTR lpszSubKey;
|
---|
209 | DWORD dwParam6;
|
---|
210 | } MRUINFO, *LPMRUINFO;
|
---|
211 |
|
---|
212 |
|
---|
213 | typedef struct tagMRU
|
---|
214 | {
|
---|
215 | DWORD dwParam1; /* some kind of flag */
|
---|
216 | DWORD dwParam2;
|
---|
217 | DWORD dwParam3;
|
---|
218 | HKEY hkeyMRU;
|
---|
219 | LPCSTR lpszSubKey;
|
---|
220 | DWORD dwParam6;
|
---|
221 | } MRU, *HMRU;
|
---|
222 |
|
---|
223 | LPVOID WINAPI
|
---|
224 | CreateMRUListLazyA (LPMRUINFO lpmi, DWORD dwParam2,
|
---|
225 | DWORD dwParam3, DWORD dwParam4);
|
---|
226 |
|
---|
227 |
|
---|
228 | /**************************************************************************
|
---|
229 | * CreateMRUListA [COMCTL32.151]
|
---|
230 | *
|
---|
231 | * PARAMS
|
---|
232 | * dwParam
|
---|
233 | *
|
---|
234 | * RETURNS
|
---|
235 | */
|
---|
236 |
|
---|
237 | LPVOID WINAPI
|
---|
238 | CreateMRUListA (LPMRUINFO lpmi)
|
---|
239 | {
|
---|
240 | return CreateMRUListLazyA (lpmi, 0, 0, 0);
|
---|
241 | }
|
---|
242 |
|
---|
243 |
|
---|
244 | DWORD WINAPI
|
---|
245 | FreeMRUListA (HMRU hmru)
|
---|
246 | {
|
---|
247 | // FIXME (commctrl, "(%p) empty stub!\n", hmru);
|
---|
248 |
|
---|
249 | #if 0
|
---|
250 | if (!(hmru->dwParam1 & 1001)) {
|
---|
251 | RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
|
---|
252 | hmru->lpszMRUString,
|
---|
253 | lstrlenA (hmru->lpszMRUString));
|
---|
254 | }
|
---|
255 |
|
---|
256 |
|
---|
257 | RegClosKey (hmru->hkeyMRU
|
---|
258 | COMCTL32_Free32 (hmru->lpszMRUString);
|
---|
259 | #endif
|
---|
260 |
|
---|
261 | return COMCTL32_Free (hmru);
|
---|
262 | }
|
---|
263 |
|
---|
264 |
|
---|
265 |
|
---|
266 | DWORD WINAPI
|
---|
267 | AddMRUData (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
|
---|
268 | {
|
---|
269 |
|
---|
270 | // FIXME (commctrl, "(%lx %lx %lx) empty stub!\n",
|
---|
271 | // dwParam1, dwParam2, dwParam3);
|
---|
272 |
|
---|
273 | return 0;
|
---|
274 | }
|
---|
275 |
|
---|
276 |
|
---|
277 | DWORD WINAPI
|
---|
278 | FindMRUData (DWORD dwParam1, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
|
---|
279 | {
|
---|
280 |
|
---|
281 | // FIXME (commctrl, "(%lx %lx %lx %lx) empty stub!\n",
|
---|
282 | // dwParam1, dwParam2, dwParam3, dwParam4);
|
---|
283 |
|
---|
284 | return TRUE;
|
---|
285 | }
|
---|
286 |
|
---|
287 |
|
---|
288 | LPVOID WINAPI
|
---|
289 | CreateMRUListLazyA (LPMRUINFO lpmi, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
|
---|
290 | {
|
---|
291 | /* DWORD dwLocal1; *
|
---|
292 | * HKEY hkeyResult; *
|
---|
293 | * DWORD dwLocal3; *
|
---|
294 | * LPVOID lMRU; *
|
---|
295 | * DWORD dwLocal5; *
|
---|
296 | * DWORD dwLocal6; *
|
---|
297 | * DWORD dwLocal7; *
|
---|
298 | * DWORD dwDisposition; */
|
---|
299 |
|
---|
300 | /* internal variables */
|
---|
301 | LPVOID ptr;
|
---|
302 |
|
---|
303 | // FIXME (commctrl, "(%p) empty stub!\n", lpmi);
|
---|
304 |
|
---|
305 | if (lpmi) {
|
---|
306 | // FIXME (commctrl, "(%lx %lx %lx %lx \"%s\" %lx)\n",
|
---|
307 | // lpmi->dwParam1, lpmi->dwParam2, lpmi->dwParam3,
|
---|
308 | // (DWORD)lpmi->hkeyMain, lpmi->lpszSubKey, lpmi->dwParam6);
|
---|
309 | }
|
---|
310 |
|
---|
311 | /* dummy pointer creation */
|
---|
312 | ptr = COMCTL32_Alloc (32);
|
---|
313 |
|
---|
314 | // FIXME (commctrl, "-- ret = %p\n", ptr);
|
---|
315 |
|
---|
316 | return ptr;
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 |
|
---|
321 | /**************************************************************************
|
---|
322 | * Str_GetPtrA [COMCTL32.233]
|
---|
323 | *
|
---|
324 | * PARAMS
|
---|
325 | * lpSrc [I]
|
---|
326 | * lpDest [O]
|
---|
327 | * nMaxLen [I]
|
---|
328 | *
|
---|
329 | * RETURNS
|
---|
330 | */
|
---|
331 |
|
---|
332 | INT WINAPI
|
---|
333 | Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen)
|
---|
334 | {
|
---|
335 | INT len;
|
---|
336 |
|
---|
337 | // TRACE (commctrl, "(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
|
---|
338 |
|
---|
339 | if (!lpDest && lpSrc)
|
---|
340 | return lstrlenA (lpSrc);
|
---|
341 |
|
---|
342 | if (nMaxLen == 0)
|
---|
343 | return 0;
|
---|
344 |
|
---|
345 | if (lpSrc == NULL) {
|
---|
346 | lpDest[0] = '\0';
|
---|
347 | return 0;
|
---|
348 | }
|
---|
349 |
|
---|
350 | len = lstrlenA (lpSrc);
|
---|
351 | if (len >= nMaxLen)
|
---|
352 | len = nMaxLen - 1;
|
---|
353 |
|
---|
354 | RtlMoveMemory (lpDest, lpSrc, len);
|
---|
355 | lpDest[len] = '\0';
|
---|
356 |
|
---|
357 | return len;
|
---|
358 | }
|
---|
359 |
|
---|
360 |
|
---|
361 | /**************************************************************************
|
---|
362 | * Str_SetPtrA [COMCTL32.234]
|
---|
363 | *
|
---|
364 | * PARAMS
|
---|
365 | * lppDest [O]
|
---|
366 | * lpSrc [I]
|
---|
367 | *
|
---|
368 | * RETURNS
|
---|
369 | */
|
---|
370 |
|
---|
371 | BOOL WINAPI
|
---|
372 | Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc)
|
---|
373 | {
|
---|
374 | // TRACE (commctrl, "(%p %p)\n", lppDest, lpSrc);
|
---|
375 |
|
---|
376 | if (lpSrc) {
|
---|
377 | LPSTR ptr = COMCTL32_ReAlloc (*lppDest, lstrlenA (lpSrc) + 1);
|
---|
378 | if (!ptr)
|
---|
379 | return FALSE;
|
---|
380 | lstrcpyA (ptr, lpSrc);
|
---|
381 | *lppDest = ptr;
|
---|
382 | }
|
---|
383 | else {
|
---|
384 | if (*lppDest) {
|
---|
385 | COMCTL32_Free (*lppDest);
|
---|
386 | *lppDest = NULL;
|
---|
387 | }
|
---|
388 | }
|
---|
389 |
|
---|
390 | return TRUE;
|
---|
391 | }
|
---|
392 |
|
---|
393 |
|
---|
394 | /**************************************************************************
|
---|
395 | * Str_GetPtrW [COMCTL32.235]
|
---|
396 | *
|
---|
397 | * PARAMS
|
---|
398 | * lpSrc [I]
|
---|
399 | * lpDest [O]
|
---|
400 | * nMaxLen [I]
|
---|
401 | *
|
---|
402 | * RETURNS
|
---|
403 | */
|
---|
404 |
|
---|
405 | INT WINAPI
|
---|
406 | Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
|
---|
407 | {
|
---|
408 | INT len;
|
---|
409 |
|
---|
410 | // TRACE (commctrl, "(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
|
---|
411 |
|
---|
412 | if (!lpDest && lpSrc)
|
---|
413 | return lstrlenW (lpSrc);
|
---|
414 |
|
---|
415 | if (nMaxLen == 0)
|
---|
416 | return 0;
|
---|
417 |
|
---|
418 | if (lpSrc == NULL) {
|
---|
419 | lpDest[0] = L'\0';
|
---|
420 | return 0;
|
---|
421 | }
|
---|
422 |
|
---|
423 | len = lstrlenW (lpSrc);
|
---|
424 | if (len >= nMaxLen)
|
---|
425 | len = nMaxLen - 1;
|
---|
426 |
|
---|
427 | RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
|
---|
428 | lpDest[len] = L'\0';
|
---|
429 |
|
---|
430 | return len;
|
---|
431 | }
|
---|
432 |
|
---|
433 |
|
---|
434 | /**************************************************************************
|
---|
435 | * Str_SetPtrW [COMCTL32.236]
|
---|
436 | *
|
---|
437 | * PARAMS
|
---|
438 | * lpDest [O]
|
---|
439 | * lpSrc [I]
|
---|
440 | *
|
---|
441 | * RETURNS
|
---|
442 | */
|
---|
443 |
|
---|
444 | BOOL WINAPI
|
---|
445 | Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc)
|
---|
446 | {
|
---|
447 | // TRACE (commctrl, "(%p %p)\n", lppDest, lpSrc);
|
---|
448 |
|
---|
449 | if (lpSrc) {
|
---|
450 | INT len = lstrlenW (lpSrc) + 1;
|
---|
451 | LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
|
---|
452 | if (!ptr)
|
---|
453 | return FALSE;
|
---|
454 | lstrcpyW (ptr, lpSrc);
|
---|
455 | *lppDest = ptr;
|
---|
456 | }
|
---|
457 | else {
|
---|
458 | if (*lppDest) {
|
---|
459 | COMCTL32_Free (*lppDest);
|
---|
460 | *lppDest = NULL;
|
---|
461 | }
|
---|
462 | }
|
---|
463 |
|
---|
464 | return TRUE;
|
---|
465 | }
|
---|
466 |
|
---|
467 |
|
---|
468 | /**************************************************************************
|
---|
469 | * The DSA-API is a set of functions to create and manipulate arrays of
|
---|
470 | * fix sized memory blocks. These arrays can store any kind of data
|
---|
471 | * (strings, icons...).
|
---|
472 | */
|
---|
473 |
|
---|
474 | /**************************************************************************
|
---|
475 | * DSA_Create [COMCTL32.320] Creates a dynamic storage array
|
---|
476 | *
|
---|
477 | * PARAMS
|
---|
478 | * nSize [I] size of the array elements
|
---|
479 | * nGrow [I] number of elements by which the array grows when it is filled
|
---|
480 | *
|
---|
481 | * RETURNS
|
---|
482 | * Success: pointer to a array control structure. use this like a handle.
|
---|
483 | * Failure: NULL
|
---|
484 | */
|
---|
485 |
|
---|
486 | HDSA WINAPI
|
---|
487 | DSA_Create (INT nSize, INT nGrow)
|
---|
488 | {
|
---|
489 | HDSA hdsa;
|
---|
490 |
|
---|
491 | // TRACE (commctrl, "(size=%d grow=%d)\n", nSize, nGrow);
|
---|
492 |
|
---|
493 | hdsa = (HDSA)COMCTL32_Alloc (sizeof(DSA));
|
---|
494 | if (hdsa)
|
---|
495 | {
|
---|
496 | hdsa->nItemCount = 0;
|
---|
497 | hdsa->pData = NULL;
|
---|
498 | hdsa->nMaxCount = 0;
|
---|
499 | hdsa->nItemSize = nSize;
|
---|
500 | hdsa->nGrow = MAX(1, nGrow);
|
---|
501 | }
|
---|
502 |
|
---|
503 | return hdsa;
|
---|
504 | }
|
---|
505 |
|
---|
506 |
|
---|
507 | /**************************************************************************
|
---|
508 | * DSA_Destroy [COMCTL32.321] Destroys a dynamic storage array
|
---|
509 | *
|
---|
510 | * PARAMS
|
---|
511 | * hdsa [I] pointer to the array control structure
|
---|
512 | *
|
---|
513 | * RETURNS
|
---|
514 | * Success: TRUE
|
---|
515 | * Failure: FALSE
|
---|
516 | */
|
---|
517 |
|
---|
518 | BOOL WINAPI
|
---|
519 | DSA_Destroy (const HDSA hdsa)
|
---|
520 | {
|
---|
521 | // TRACE (commctrl, "(%p)\n", hdsa);
|
---|
522 |
|
---|
523 | if (!hdsa)
|
---|
524 | return FALSE;
|
---|
525 |
|
---|
526 | if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
|
---|
527 | return FALSE;
|
---|
528 |
|
---|
529 | return COMCTL32_Free (hdsa);
|
---|
530 | }
|
---|
531 |
|
---|
532 |
|
---|
533 | /**************************************************************************
|
---|
534 | * DSA_GetItem [COMCTL32.322]
|
---|
535 | *
|
---|
536 | * PARAMS
|
---|
537 | * hdsa [I] pointer to the array control structure
|
---|
538 | * nIndex [I] number of the Item to get
|
---|
539 | * pDest [O] destination buffer. Has to be >= dwElementSize.
|
---|
540 | *
|
---|
541 | * RETURNS
|
---|
542 | * Success: TRUE
|
---|
543 | * Failure: FALSE
|
---|
544 | */
|
---|
545 |
|
---|
546 | BOOL WINAPI
|
---|
547 | DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest)
|
---|
548 | {
|
---|
549 | LPVOID pSrc;
|
---|
550 |
|
---|
551 | // TRACE (commctrl, "(%p %d %p)\n", hdsa, nIndex, pDest);
|
---|
552 |
|
---|
553 | if (!hdsa)
|
---|
554 | return FALSE;
|
---|
555 | if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
|
---|
556 | return FALSE;
|
---|
557 |
|
---|
558 | pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
|
---|
559 | memmove (pDest, pSrc, hdsa->nItemSize);
|
---|
560 |
|
---|
561 | return TRUE;
|
---|
562 | }
|
---|
563 |
|
---|
564 |
|
---|
565 | /**************************************************************************
|
---|
566 | * DSA_GetItemPtr [COMCTL32.323]
|
---|
567 | *
|
---|
568 | * Retrieves a pointer to the specified item.
|
---|
569 | *
|
---|
570 | * PARAMS
|
---|
571 | * hdsa [I] pointer to the array control structure
|
---|
572 | * nIndex [I] index of the desired item
|
---|
573 | *
|
---|
574 | * RETURNS
|
---|
575 | * Success: pointer to an item
|
---|
576 | * Failure: NULL
|
---|
577 | */
|
---|
578 |
|
---|
579 | LPVOID WINAPI
|
---|
580 | DSA_GetItemPtr (const HDSA hdsa, INT nIndex)
|
---|
581 | {
|
---|
582 | LPVOID pSrc;
|
---|
583 |
|
---|
584 | // TRACE (commctrl, "(%p %d)\n", hdsa, nIndex);
|
---|
585 |
|
---|
586 | if (!hdsa)
|
---|
587 | return NULL;
|
---|
588 | if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
|
---|
589 | return NULL;
|
---|
590 |
|
---|
591 | pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
|
---|
592 |
|
---|
593 | // TRACE (commctrl, "-- ret=%p\n", pSrc);
|
---|
594 |
|
---|
595 | return pSrc;
|
---|
596 | }
|
---|
597 |
|
---|
598 |
|
---|
599 | /**************************************************************************
|
---|
600 | * DSA_SetItem [COMCTL32.325]
|
---|
601 | *
|
---|
602 | * Sets the contents of an item in the array.
|
---|
603 | *
|
---|
604 | * PARAMS
|
---|
605 | * hdsa [I] pointer to the array control structure
|
---|
606 | * nIndex [I] index for the item
|
---|
607 | * pSrc [I] pointer to the new item data
|
---|
608 | *
|
---|
609 | * RETURNS
|
---|
610 | * Success: TRUE
|
---|
611 | * Failure: FALSE
|
---|
612 | */
|
---|
613 |
|
---|
614 | BOOL WINAPI
|
---|
615 | DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
|
---|
616 | {
|
---|
617 | INT nSize, nNewItems;
|
---|
618 | LPVOID pDest, lpTemp;
|
---|
619 |
|
---|
620 | // TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
|
---|
621 |
|
---|
622 | if ((!hdsa) || nIndex < 0)
|
---|
623 | return FALSE;
|
---|
624 |
|
---|
625 | if (hdsa->nItemCount <= nIndex) {
|
---|
626 | /* within the old array */
|
---|
627 | if (hdsa->nMaxCount > nIndex) {
|
---|
628 | /* within the allocated space, set a new boundary */
|
---|
629 | hdsa->nItemCount = nIndex + 1;
|
---|
630 | }
|
---|
631 | else {
|
---|
632 | /* resize the block of memory */
|
---|
633 | nNewItems =
|
---|
634 | hdsa->nGrow * ((INT)((nIndex - 1) / hdsa->nGrow) + 1);
|
---|
635 | nSize = hdsa->nItemSize * nNewItems;
|
---|
636 |
|
---|
637 | lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
|
---|
638 | if (!lpTemp)
|
---|
639 | return FALSE;
|
---|
640 |
|
---|
641 | hdsa->nMaxCount = nNewItems;
|
---|
642 | hdsa->nItemCount = nIndex + 1;
|
---|
643 | hdsa->pData = lpTemp;
|
---|
644 | }
|
---|
645 | }
|
---|
646 |
|
---|
647 | /* put the new entry in */
|
---|
648 | pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
|
---|
649 | // TRACE("-- move dest=%p src=%p size=%d\n",
|
---|
650 | // pDest, pSrc, hdsa->nItemSize);
|
---|
651 | memmove (pDest, pSrc, hdsa->nItemSize);
|
---|
652 |
|
---|
653 | return TRUE;
|
---|
654 | }
|
---|
655 |
|
---|
656 |
|
---|
657 | /**************************************************************************
|
---|
658 | * DSA_InsertItem [COMCTL32.325]
|
---|
659 | *
|
---|
660 | * PARAMS
|
---|
661 | * hdsa [I] pointer to the array control structure
|
---|
662 | * nIndex [I] index for the new item
|
---|
663 | * pSrc [I] pointer to the element
|
---|
664 | *
|
---|
665 | * RETURNS
|
---|
666 | * Success: position of the new item
|
---|
667 | * Failure: -1
|
---|
668 | */
|
---|
669 |
|
---|
670 | INT WINAPI
|
---|
671 | DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
|
---|
672 | {
|
---|
673 | INT nNewItems, nSize, i;
|
---|
674 | LPVOID lpTemp, lpDest;
|
---|
675 | LPDWORD p;
|
---|
676 |
|
---|
677 | // TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
|
---|
678 |
|
---|
679 | if ((!hdsa) || nIndex < 0)
|
---|
680 | return -1;
|
---|
681 |
|
---|
682 | for (i = 0; i < hdsa->nItemSize; i += 4) {
|
---|
683 | p = *(DWORD**)((char *) pSrc + i);
|
---|
684 | // if (IsBadStringPtrA ((char*)p, 256))
|
---|
685 | // TRACE("-- %d=%p\n", i, (DWORD*)p);
|
---|
686 | // else
|
---|
687 | // TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
|
---|
688 | }
|
---|
689 |
|
---|
690 | /* when nIndex > nItemCount then append */
|
---|
691 | if (nIndex >= hdsa->nItemCount)
|
---|
692 | nIndex = hdsa->nItemCount;
|
---|
693 |
|
---|
694 | /* do we need to resize ? */
|
---|
695 | if (hdsa->nItemCount >= hdsa->nMaxCount) {
|
---|
696 | nNewItems = hdsa->nMaxCount + hdsa->nGrow;
|
---|
697 | nSize = hdsa->nItemSize * nNewItems;
|
---|
698 |
|
---|
699 | lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
|
---|
700 | if (!lpTemp)
|
---|
701 | return -1;
|
---|
702 |
|
---|
703 | hdsa->nMaxCount = nNewItems;
|
---|
704 | hdsa->pData = lpTemp;
|
---|
705 | }
|
---|
706 |
|
---|
707 | /* do we need to move elements ? */
|
---|
708 | if (nIndex < hdsa->nItemCount) {
|
---|
709 | lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
|
---|
710 | lpDest = (char *) lpTemp + hdsa->nItemSize;
|
---|
711 | nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
|
---|
712 | // TRACE("-- move dest=%p src=%p size=%d\n",
|
---|
713 | // lpDest, lpTemp, nSize);
|
---|
714 | memmove (lpDest, lpTemp, nSize);
|
---|
715 | }
|
---|
716 |
|
---|
717 | /* ok, we can put the new Item in */
|
---|
718 | hdsa->nItemCount++;
|
---|
719 | lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
|
---|
720 | // TRACE("-- move dest=%p src=%p size=%d\n",
|
---|
721 | // lpDest, pSrc, hdsa->nItemSize);
|
---|
722 | memmove (lpDest, pSrc, hdsa->nItemSize);
|
---|
723 |
|
---|
724 | return hdsa->nItemCount;
|
---|
725 | }
|
---|
726 |
|
---|
727 |
|
---|
728 | /**************************************************************************
|
---|
729 | * DSA_DeleteItem [COMCTL32.326]
|
---|
730 | *
|
---|
731 | * PARAMS
|
---|
732 | * hdsa [I] pointer to the array control structure
|
---|
733 | * nIndex [I] index for the element to delete
|
---|
734 | *
|
---|
735 | * RETURNS
|
---|
736 | * Success: number of the deleted element
|
---|
737 | * Failure: -1
|
---|
738 | */
|
---|
739 |
|
---|
740 | INT WINAPI
|
---|
741 | DSA_DeleteItem (const HDSA hdsa, INT nIndex)
|
---|
742 | {
|
---|
743 | LPVOID lpDest,lpSrc;
|
---|
744 | INT nSize;
|
---|
745 |
|
---|
746 | // TRACE (commctrl, "(%p %d)\n", hdsa, nIndex);
|
---|
747 |
|
---|
748 | if (!hdsa)
|
---|
749 | return -1;
|
---|
750 | if (nIndex < 0 || nIndex >= hdsa->nItemCount)
|
---|
751 | return -1;
|
---|
752 |
|
---|
753 | /* do we need to move ? */
|
---|
754 | if (nIndex < hdsa->nItemCount - 1) {
|
---|
755 | lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
|
---|
756 | lpSrc = (char *) lpDest + hdsa->nItemSize;
|
---|
757 | nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
|
---|
758 | // TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
|
---|
759 | // lpDest, lpSrc, nSize);
|
---|
760 | memmove (lpDest, lpSrc, nSize);
|
---|
761 | }
|
---|
762 |
|
---|
763 | hdsa->nItemCount--;
|
---|
764 |
|
---|
765 | /* free memory ? */
|
---|
766 | if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
|
---|
767 | nSize = hdsa->nItemSize * hdsa->nItemCount;
|
---|
768 |
|
---|
769 | lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
|
---|
770 | if (!lpDest)
|
---|
771 | return -1;
|
---|
772 |
|
---|
773 | hdsa->nMaxCount = hdsa->nItemCount;
|
---|
774 | hdsa->pData = lpDest;
|
---|
775 | }
|
---|
776 |
|
---|
777 | return nIndex;
|
---|
778 | }
|
---|
779 |
|
---|
780 |
|
---|
781 | /**************************************************************************
|
---|
782 | * DSA_DeleteAllItems [COMCTL32.326]
|
---|
783 | *
|
---|
784 | * Removes all items and reinitializes the array.
|
---|
785 | *
|
---|
786 | * PARAMS
|
---|
787 | * hdsa [I] pointer to the array control structure
|
---|
788 | *
|
---|
789 | * RETURNS
|
---|
790 | * Success: TRUE
|
---|
791 | * Failure: FALSE
|
---|
792 | */
|
---|
793 |
|
---|
794 | BOOL WINAPI
|
---|
795 | DSA_DeleteAllItems (const HDSA hdsa)
|
---|
796 | {
|
---|
797 | // TRACE (commctrl, "(%p)\n", hdsa);
|
---|
798 |
|
---|
799 | if (!hdsa)
|
---|
800 | return FALSE;
|
---|
801 | if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
|
---|
802 | return FALSE;
|
---|
803 |
|
---|
804 | hdsa->nItemCount = 0;
|
---|
805 | hdsa->pData = NULL;
|
---|
806 | hdsa->nMaxCount = 0;
|
---|
807 |
|
---|
808 | return TRUE;
|
---|
809 | }
|
---|
810 |
|
---|
811 |
|
---|
812 | /**************************************************************************
|
---|
813 | * The DPA-API is a set of functions to create and manipulate arrays of
|
---|
814 | * pointers.
|
---|
815 | */
|
---|
816 |
|
---|
817 | /**************************************************************************
|
---|
818 | * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
|
---|
819 | *
|
---|
820 | * PARAMS
|
---|
821 | * nGrow [I] number of items by which the array grows when it is filled
|
---|
822 | *
|
---|
823 | * RETURNS
|
---|
824 | * Success: handle (pointer) to the pointer array.
|
---|
825 | * Failure: NULL
|
---|
826 | */
|
---|
827 |
|
---|
828 | HDPA WINAPI
|
---|
829 | DPA_Create (INT nGrow)
|
---|
830 | {
|
---|
831 | HDPA hdpa;
|
---|
832 |
|
---|
833 | // TRACE (commctrl, "(%d)\n", nGrow);
|
---|
834 |
|
---|
835 | hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
|
---|
836 | if (hdpa) {
|
---|
837 | hdpa->nGrow = MAX(8, nGrow);
|
---|
838 | hdpa->hHeap = COMCTL32_hHeap;
|
---|
839 | hdpa->nMaxCount = hdpa->nGrow * 2;
|
---|
840 | hdpa->ptrs =
|
---|
841 | (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
|
---|
842 | }
|
---|
843 |
|
---|
844 | // TRACE (commctrl, "-- %p\n", hdpa);
|
---|
845 |
|
---|
846 | return hdpa;
|
---|
847 | }
|
---|
848 |
|
---|
849 |
|
---|
850 | /**************************************************************************
|
---|
851 | * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
|
---|
852 | *
|
---|
853 | * PARAMS
|
---|
854 | * hdpa [I] handle (pointer) to the pointer array
|
---|
855 | *
|
---|
856 | * RETURNS
|
---|
857 | * Success: TRUE
|
---|
858 | * Failure: FALSE
|
---|
859 | */
|
---|
860 |
|
---|
861 | BOOL WINAPI
|
---|
862 | DPA_Destroy (const HDPA hdpa)
|
---|
863 | {
|
---|
864 | // TRACE (commctrl, "(%p)\n", hdpa);
|
---|
865 |
|
---|
866 | if (!hdpa)
|
---|
867 | return FALSE;
|
---|
868 |
|
---|
869 | if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
|
---|
870 | return FALSE;
|
---|
871 |
|
---|
872 | return HeapFree (hdpa->hHeap, 0, hdpa);
|
---|
873 | }
|
---|
874 |
|
---|
875 |
|
---|
876 | /**************************************************************************
|
---|
877 | * DPA_Grow [COMCTL32.330]
|
---|
878 | *
|
---|
879 | * Sets the growth amount.
|
---|
880 | *
|
---|
881 | * PARAMS
|
---|
882 | * hdpa [I] handle (pointer) to the existing (source) pointer array
|
---|
883 | * nGrow [I] number of items, the array grows, when it's too small
|
---|
884 | *
|
---|
885 | * RETURNS
|
---|
886 | * Success: TRUE
|
---|
887 | * Failure: FALSE
|
---|
888 | */
|
---|
889 |
|
---|
890 | BOOL WINAPI
|
---|
891 | DPA_Grow (const HDPA hdpa, INT nGrow)
|
---|
892 | {
|
---|
893 | // TRACE (commctrl, "(%p %d)\n", hdpa, nGrow);
|
---|
894 |
|
---|
895 | if (!hdpa)
|
---|
896 | return FALSE;
|
---|
897 |
|
---|
898 | hdpa->nGrow = MAX(8, nGrow);
|
---|
899 |
|
---|
900 | return TRUE;
|
---|
901 | }
|
---|
902 |
|
---|
903 |
|
---|
904 | /**************************************************************************
|
---|
905 | * DPA_Clone [COMCTL32.331]
|
---|
906 | *
|
---|
907 | * Copies a pointer array to an other one or creates a copy
|
---|
908 | *
|
---|
909 | * PARAMS
|
---|
910 | * hdpa [I] handle (pointer) to the existing (source) pointer array
|
---|
911 | * hdpaNew [O] handle (pointer) to the destination pointer array
|
---|
912 | *
|
---|
913 | * RETURNS
|
---|
914 | * Success: pointer to the destination pointer array.
|
---|
915 | * Failure: NULL
|
---|
916 | *
|
---|
917 | * NOTES
|
---|
918 | * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer
|
---|
919 | * array will be created and it's handle (pointer) is returned.
|
---|
920 | * - If 'hdpa' is a NULL-Pointer, the original implementation crashes,
|
---|
921 | * this implementation just returns NULL.
|
---|
922 | */
|
---|
923 |
|
---|
924 | HDPA WINAPI
|
---|
925 | DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
|
---|
926 | {
|
---|
927 | INT nNewItems, nSize;
|
---|
928 | HDPA hdpaTemp;
|
---|
929 |
|
---|
930 | if (!hdpa)
|
---|
931 | return NULL;
|
---|
932 |
|
---|
933 | // TRACE (commctrl, "(%p %p)\n", hdpa, hdpaNew);
|
---|
934 |
|
---|
935 | if (!hdpaNew) {
|
---|
936 | /* create a new DPA */
|
---|
937 | hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
|
---|
938 | sizeof(DPA));
|
---|
939 | hdpaTemp->hHeap = hdpa->hHeap;
|
---|
940 | hdpaTemp->nGrow = hdpa->nGrow;
|
---|
941 | }
|
---|
942 | else
|
---|
943 | hdpaTemp = hdpaNew;
|
---|
944 |
|
---|
945 | if (hdpaTemp->ptrs) {
|
---|
946 | /* remove old pointer array */
|
---|
947 | HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
|
---|
948 | hdpaTemp->ptrs = NULL;
|
---|
949 | hdpaTemp->nItemCount = 0;
|
---|
950 | hdpaTemp->nMaxCount = 0;
|
---|
951 | }
|
---|
952 |
|
---|
953 | /* create a new pointer array */
|
---|
954 | nNewItems = hdpaTemp->nGrow *
|
---|
955 | ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
|
---|
956 | nSize = nNewItems * sizeof(LPVOID);
|
---|
957 | hdpaTemp->ptrs =
|
---|
958 | (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
|
---|
959 | hdpaTemp->nMaxCount = nNewItems;
|
---|
960 |
|
---|
961 | /* clone the pointer array */
|
---|
962 | hdpaTemp->nItemCount = hdpa->nItemCount;
|
---|
963 | memmove (hdpaTemp->ptrs, hdpa->ptrs,
|
---|
964 | hdpaTemp->nItemCount * sizeof(LPVOID));
|
---|
965 |
|
---|
966 | return hdpaTemp;
|
---|
967 | }
|
---|
968 |
|
---|
969 |
|
---|
970 | /**************************************************************************
|
---|
971 | * DPA_GetPtr [COMCTL32.332]
|
---|
972 | *
|
---|
973 | * Retrieves a pointer from a dynamic pointer array
|
---|
974 | *
|
---|
975 | * PARAMS
|
---|
976 | * hdpa [I] handle (pointer) to the pointer array
|
---|
977 | * nIndex [I] array index of the desired pointer
|
---|
978 | *
|
---|
979 | * RETURNS
|
---|
980 | * Success: pointer
|
---|
981 | * Failure: NULL
|
---|
982 | */
|
---|
983 |
|
---|
984 | LPVOID WINAPI
|
---|
985 | DPA_GetPtr (const HDPA hdpa, INT i)
|
---|
986 | {
|
---|
987 | // TRACE (commctrl, "(%p %d)\n", hdpa, i);
|
---|
988 |
|
---|
989 | if (!hdpa)
|
---|
990 | return NULL;
|
---|
991 | if (!hdpa->ptrs)
|
---|
992 | return NULL;
|
---|
993 | if ((i < 0) || (i >= hdpa->nItemCount))
|
---|
994 | return NULL;
|
---|
995 |
|
---|
996 | // TRACE (commctrl, "-- %p\n", hdpa->ptrs[i]);
|
---|
997 |
|
---|
998 | return hdpa->ptrs[i];
|
---|
999 | }
|
---|
1000 |
|
---|
1001 |
|
---|
1002 | /**************************************************************************
|
---|
1003 | * DPA_GetPtrIndex [COMCTL32.333]
|
---|
1004 | *
|
---|
1005 | * Retrieves the index of the specified pointer
|
---|
1006 | *
|
---|
1007 | * PARAMS
|
---|
1008 | * hdpa [I] handle (pointer) to the pointer array
|
---|
1009 | * p [I] pointer
|
---|
1010 | *
|
---|
1011 | * RETURNS
|
---|
1012 | * Success: index of the specified pointer
|
---|
1013 | * Failure: -1
|
---|
1014 | */
|
---|
1015 |
|
---|
1016 | INT WINAPI
|
---|
1017 | DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
|
---|
1018 | {
|
---|
1019 | INT i;
|
---|
1020 |
|
---|
1021 | if (!hdpa->ptrs)
|
---|
1022 | return -1;
|
---|
1023 |
|
---|
1024 | for (i = 0; i < hdpa->nItemCount; i++) {
|
---|
1025 | if (hdpa->ptrs[i] == p)
|
---|
1026 | return i;
|
---|
1027 | }
|
---|
1028 |
|
---|
1029 | return -1;
|
---|
1030 | }
|
---|
1031 |
|
---|
1032 |
|
---|
1033 | /**************************************************************************
|
---|
1034 | * DPA_InsertPtr [COMCTL32.334]
|
---|
1035 | *
|
---|
1036 | * Inserts a pointer into a dynamic pointer array
|
---|
1037 | *
|
---|
1038 | * PARAMS
|
---|
1039 | * hdpa [I] handle (pointer) to the array
|
---|
1040 | * i [I] array index
|
---|
1041 | * p [I] pointer to insert
|
---|
1042 | *
|
---|
1043 | * RETURNS
|
---|
1044 | * Success: index of the inserted pointer
|
---|
1045 | * Failure: -1
|
---|
1046 | */
|
---|
1047 |
|
---|
1048 | INT WINAPI
|
---|
1049 | DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
|
---|
1050 | {
|
---|
1051 | INT nNewItems, nSize, nIndex = 0;
|
---|
1052 | LPVOID *lpTemp, *lpDest;
|
---|
1053 |
|
---|
1054 | // TRACE (commctrl, "(%p %d %p)\n", hdpa, i, p);
|
---|
1055 |
|
---|
1056 | if ((!hdpa) || (i < 0))
|
---|
1057 | return -1;
|
---|
1058 |
|
---|
1059 | if (!hdpa->ptrs) {
|
---|
1060 | hdpa->ptrs =
|
---|
1061 | (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
|
---|
1062 | 2 * hdpa->nGrow * sizeof(LPVOID));
|
---|
1063 | if (!hdpa->ptrs)
|
---|
1064 | return -1;
|
---|
1065 | hdpa->nMaxCount = hdpa->nGrow * 2;
|
---|
1066 | nIndex = 0;
|
---|
1067 | }
|
---|
1068 | else {
|
---|
1069 | if (hdpa->nItemCount >= hdpa->nMaxCount) {
|
---|
1070 | // TRACE (commctrl, "-- resizing\n");
|
---|
1071 | nNewItems = hdpa->nMaxCount + hdpa->nGrow;
|
---|
1072 | nSize = nNewItems * sizeof(LPVOID);
|
---|
1073 |
|
---|
1074 | lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
|
---|
1075 | hdpa->ptrs, nSize);
|
---|
1076 | if (!lpTemp)
|
---|
1077 | return -1;
|
---|
1078 | hdpa->nMaxCount = nNewItems;
|
---|
1079 | hdpa->ptrs = lpTemp;
|
---|
1080 | }
|
---|
1081 |
|
---|
1082 | if (i >= hdpa->nItemCount) {
|
---|
1083 | nIndex = hdpa->nItemCount;
|
---|
1084 | // TRACE (commctrl, "-- appending at %d\n", nIndex);
|
---|
1085 | }
|
---|
1086 | else {
|
---|
1087 | // TRACE (commctrl, "-- inserting at %d\n", i);
|
---|
1088 | lpTemp = hdpa->ptrs + i;
|
---|
1089 | lpDest = lpTemp + 1;
|
---|
1090 | nSize = (hdpa->nItemCount - i) * sizeof(LPVOID);
|
---|
1091 | // TRACE (commctrl, "-- move dest=%p src=%p size=%x\n",
|
---|
1092 | // lpDest, lpTemp, nSize);
|
---|
1093 | memmove (lpDest, lpTemp, nSize);
|
---|
1094 | nIndex = i;
|
---|
1095 | }
|
---|
1096 | }
|
---|
1097 |
|
---|
1098 | /* insert item */
|
---|
1099 | hdpa->nItemCount++;
|
---|
1100 | hdpa->ptrs[nIndex] = p;
|
---|
1101 |
|
---|
1102 | return nIndex;
|
---|
1103 | }
|
---|
1104 |
|
---|
1105 |
|
---|
1106 | /**************************************************************************
|
---|
1107 | * DPA_SetPtr [COMCTL32.335]
|
---|
1108 | *
|
---|
1109 | * Sets a pointer in the pointer array
|
---|
1110 | *
|
---|
1111 | * PARAMS
|
---|
1112 | * hdpa [I] handle (pointer) to the pointer array
|
---|
1113 | * i [I] index of the pointer that will be set
|
---|
1114 | * p [I] pointer to be set
|
---|
1115 | *
|
---|
1116 | * RETURNS
|
---|
1117 | * Success: TRUE
|
---|
1118 | * Failure: FALSE
|
---|
1119 | */
|
---|
1120 |
|
---|
1121 | BOOL WINAPI
|
---|
1122 | DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
|
---|
1123 | {
|
---|
1124 | LPVOID *lpTemp;
|
---|
1125 |
|
---|
1126 | // TRACE (commctrl, "(%p %d %p)\n", hdpa, i, p);
|
---|
1127 |
|
---|
1128 | if ((!hdpa) || i < 0)
|
---|
1129 | return FALSE;
|
---|
1130 |
|
---|
1131 | if (hdpa->nItemCount <= i) {
|
---|
1132 | /* within the old array */
|
---|
1133 | if (hdpa->nMaxCount > i) {
|
---|
1134 | /* within the allocated space, set a new boundary */
|
---|
1135 | hdpa->nItemCount = i;
|
---|
1136 | }
|
---|
1137 | else {
|
---|
1138 | /* resize the block of memory */
|
---|
1139 | INT nNewItems =
|
---|
1140 | hdpa->nGrow * ((INT)((i - 1) / hdpa->nGrow) + 1);
|
---|
1141 | INT nSize = nNewItems * sizeof(LPVOID);
|
---|
1142 |
|
---|
1143 | lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
|
---|
1144 | hdpa->ptrs, nSize);
|
---|
1145 | if (!lpTemp)
|
---|
1146 | return FALSE;
|
---|
1147 |
|
---|
1148 | hdpa->nItemCount = nNewItems;
|
---|
1149 | hdpa->ptrs = lpTemp;
|
---|
1150 | }
|
---|
1151 | }
|
---|
1152 |
|
---|
1153 | /* put the new entry in */
|
---|
1154 | hdpa->ptrs[i] = p;
|
---|
1155 |
|
---|
1156 | return TRUE;
|
---|
1157 | }
|
---|
1158 |
|
---|
1159 |
|
---|
1160 | /**************************************************************************
|
---|
1161 | * DPA_DeletePtr [COMCTL32.336]
|
---|
1162 | *
|
---|
1163 | * Removes a pointer from the pointer array.
|
---|
1164 | *
|
---|
1165 | * PARAMS
|
---|
1166 | * hdpa [I] handle (pointer) to the pointer array
|
---|
1167 | * i [I] index of the pointer that will be deleted
|
---|
1168 | *
|
---|
1169 | * RETURNS
|
---|
1170 | * Success: deleted pointer
|
---|
1171 | * Failure: NULL
|
---|
1172 | */
|
---|
1173 |
|
---|
1174 | LPVOID WINAPI
|
---|
1175 | DPA_DeletePtr (const HDPA hdpa, INT i)
|
---|
1176 | {
|
---|
1177 | LPVOID *lpDest, *lpSrc, lpTemp = NULL;
|
---|
1178 | INT nSize;
|
---|
1179 |
|
---|
1180 | // TRACE (commctrl, "(%p %d)\n", hdpa, i);
|
---|
1181 |
|
---|
1182 | if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
|
---|
1183 | return NULL;
|
---|
1184 |
|
---|
1185 | lpTemp = hdpa->ptrs[i];
|
---|
1186 |
|
---|
1187 | /* do we need to move ?*/
|
---|
1188 | if (i < hdpa->nItemCount - 1) {
|
---|
1189 | lpDest = hdpa->ptrs + i;
|
---|
1190 | lpSrc = lpDest + 1;
|
---|
1191 | nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
|
---|
1192 | // TRACE (commctrl,"-- move dest=%p src=%p size=%x\n",
|
---|
1193 | // lpDest, lpSrc, nSize);
|
---|
1194 | memmove (lpDest, lpSrc, nSize);
|
---|
1195 | }
|
---|
1196 |
|
---|
1197 | hdpa->nItemCount --;
|
---|
1198 |
|
---|
1199 | /* free memory ?*/
|
---|
1200 | if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
|
---|
1201 | INT nNewItems = MIN(hdpa->nGrow * 2, hdpa->nItemCount);
|
---|
1202 | nSize = nNewItems * sizeof(LPVOID);
|
---|
1203 | lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
|
---|
1204 | hdpa->ptrs, nSize);
|
---|
1205 | if (!lpDest)
|
---|
1206 | return NULL;
|
---|
1207 |
|
---|
1208 | hdpa->nMaxCount = nNewItems;
|
---|
1209 | hdpa->ptrs = (LPVOID*)lpDest;
|
---|
1210 | }
|
---|
1211 |
|
---|
1212 | return lpTemp;
|
---|
1213 | }
|
---|
1214 |
|
---|
1215 |
|
---|
1216 | /**************************************************************************
|
---|
1217 | * DPA_DeleteAllPtrs [COMCTL32.337]
|
---|
1218 | *
|
---|
1219 | * Removes all pointers and reinitializes the array.
|
---|
1220 | *
|
---|
1221 | * PARAMS
|
---|
1222 | * hdpa [I] handle (pointer) to the pointer array
|
---|
1223 | *
|
---|
1224 | * RETURNS
|
---|
1225 | * Success: TRUE
|
---|
1226 | * Failure: FALSE
|
---|
1227 | */
|
---|
1228 |
|
---|
1229 | BOOL WINAPI
|
---|
1230 | DPA_DeleteAllPtrs (const HDPA hdpa)
|
---|
1231 | {
|
---|
1232 | // TRACE (commctrl, "(%p)\n", hdpa);
|
---|
1233 |
|
---|
1234 | if (!hdpa)
|
---|
1235 | return FALSE;
|
---|
1236 |
|
---|
1237 | if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
|
---|
1238 | return FALSE;
|
---|
1239 |
|
---|
1240 | hdpa->nItemCount = 0;
|
---|
1241 | hdpa->nMaxCount = hdpa->nGrow * 2;
|
---|
1242 | hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
|
---|
1243 | hdpa->nMaxCount * sizeof(LPVOID));
|
---|
1244 |
|
---|
1245 | return TRUE;
|
---|
1246 | }
|
---|
1247 |
|
---|
1248 |
|
---|
1249 | /**************************************************************************
|
---|
1250 | * DPA_QuickSort [Internal]
|
---|
1251 | *
|
---|
1252 | * Ordinary quicksort (used by DPA_Sort).
|
---|
1253 | *
|
---|
1254 | * PARAMS
|
---|
1255 | * lpPtrs [I] pointer to the pointer array
|
---|
1256 | * l [I] index of the "left border" of the partition
|
---|
1257 | * r [I] index of the "right border" of the partition
|
---|
1258 | * pfnCompare [I] pointer to the compare function
|
---|
1259 | * lParam [I] user defined value (3rd parameter in compare function)
|
---|
1260 | *
|
---|
1261 | * RETURNS
|
---|
1262 | * NONE
|
---|
1263 | */
|
---|
1264 |
|
---|
1265 | static VOID
|
---|
1266 | DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
|
---|
1267 | PFNDPACOMPARE pfnCompare, LPARAM lParam)
|
---|
1268 | {
|
---|
1269 | LPVOID t, v;
|
---|
1270 | INT i, j;
|
---|
1271 |
|
---|
1272 | // TRACE (commctrl, "l=%i r=%i\n", l, r);
|
---|
1273 |
|
---|
1274 | i = l;
|
---|
1275 | j = r;
|
---|
1276 | v = lpPtrs[(int)(l+r)/2];
|
---|
1277 | do {
|
---|
1278 | while ((pfnCompare)(lpPtrs[i], v, lParam) > 0) i++;
|
---|
1279 | while ((pfnCompare)(lpPtrs[j], v, lParam) < 0) j--;
|
---|
1280 | if (i <= j)
|
---|
1281 | {
|
---|
1282 | t = lpPtrs[i];
|
---|
1283 | lpPtrs[i++] = lpPtrs[j];
|
---|
1284 | lpPtrs[j--] = t;
|
---|
1285 | }
|
---|
1286 | } while (i <= j);
|
---|
1287 | if (l < j) DPA_QuickSort (lpPtrs, l, j, pfnCompare, lParam);
|
---|
1288 | if (i < r) DPA_QuickSort (lpPtrs, i, r, pfnCompare, lParam);
|
---|
1289 | }
|
---|
1290 |
|
---|
1291 |
|
---|
1292 | /**************************************************************************
|
---|
1293 | * DPA_Sort [COMCTL32.338]
|
---|
1294 | *
|
---|
1295 | * Sorts a pointer array using a user defined compare function
|
---|
1296 | *
|
---|
1297 | * PARAMS
|
---|
1298 | * hdpa [I] handle (pointer) to the pointer array
|
---|
1299 | * pfnCompare [I] pointer to the compare function
|
---|
1300 | * lParam [I] user defined value (3rd parameter of compare function)
|
---|
1301 | *
|
---|
1302 | * RETURNS
|
---|
1303 | * Success: TRUE
|
---|
1304 | * Failure: FALSE
|
---|
1305 | */
|
---|
1306 |
|
---|
1307 | BOOL WINAPI
|
---|
1308 | DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
|
---|
1309 | {
|
---|
1310 | if (!hdpa || !pfnCompare)
|
---|
1311 | return FALSE;
|
---|
1312 |
|
---|
1313 | // TRACE (commctrl, "(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
|
---|
1314 |
|
---|
1315 | if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
|
---|
1316 | DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
|
---|
1317 | pfnCompare, lParam);
|
---|
1318 |
|
---|
1319 | return TRUE;
|
---|
1320 | }
|
---|
1321 |
|
---|
1322 |
|
---|
1323 | /**************************************************************************
|
---|
1324 | * DPA_Search [COMCTL32.339]
|
---|
1325 | *
|
---|
1326 | * Searches a pointer array for a specified pointer
|
---|
1327 | *
|
---|
1328 | * PARAMS
|
---|
1329 | * hdpa [I] handle (pointer) to the pointer array
|
---|
1330 | * pFind [I] pointer to search for
|
---|
1331 | * nStart [I] start index
|
---|
1332 | * pfnCompare [I] pointer to the compare function
|
---|
1333 | * lParam [I] user defined value (3rd parameter of compare function)
|
---|
1334 | * uOptions [I] search options
|
---|
1335 | *
|
---|
1336 | * RETURNS
|
---|
1337 | * Success: index of the pointer in the array.
|
---|
1338 | * Failure: -1
|
---|
1339 | *
|
---|
1340 | * NOTES
|
---|
1341 | * Binary search taken from R.Sedgewick "Algorithms in C"!
|
---|
1342 | * Function is NOT tested!
|
---|
1343 | * If something goes wrong, blame HIM not ME! (Eric Kohl)
|
---|
1344 | */
|
---|
1345 |
|
---|
1346 | INT WINAPI
|
---|
1347 | DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
|
---|
1348 | PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
|
---|
1349 | {
|
---|
1350 | if (!hdpa || !pfnCompare || !pFind)
|
---|
1351 | return -1;
|
---|
1352 |
|
---|
1353 | // TRACE (commctrl, "(%p %p %d %p 0x%08lx 0x%08x)\n",
|
---|
1354 | // hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
|
---|
1355 |
|
---|
1356 | if (uOptions & DPAS_SORTED) {
|
---|
1357 | /* array is sorted --> use binary search */
|
---|
1358 | INT l, r, x, n;
|
---|
1359 | LPVOID *lpPtr;
|
---|
1360 |
|
---|
1361 | // TRACE (commctrl, "binary search\n");
|
---|
1362 |
|
---|
1363 | l = (nStart == -1) ? 0 : nStart;
|
---|
1364 | r = hdpa->nItemCount - 1;
|
---|
1365 | lpPtr = hdpa->ptrs;
|
---|
1366 | while (r >= l) {
|
---|
1367 | x = (l + r) / 2;
|
---|
1368 | n = (pfnCompare)(pFind, lpPtr[x], lParam);
|
---|
1369 | if (n < 0)
|
---|
1370 | r = x - 1;
|
---|
1371 | else
|
---|
1372 | l = x + 1;
|
---|
1373 | if (n == 0) {
|
---|
1374 | // TRACE (commctrl, "-- ret=%d\n", n);
|
---|
1375 | return n;
|
---|
1376 | }
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | if (uOptions & DPAS_INSERTBEFORE) {
|
---|
1380 | // TRACE (commctrl, "-- ret=%d\n", r);
|
---|
1381 | return r;
|
---|
1382 | }
|
---|
1383 |
|
---|
1384 | if (uOptions & DPAS_INSERTAFTER) {
|
---|
1385 | // TRACE (commctrl, "-- ret=%d\n", l);
|
---|
1386 | return l;
|
---|
1387 | }
|
---|
1388 | }
|
---|
1389 | else {
|
---|
1390 | /* array is not sorted --> use linear search */
|
---|
1391 | LPVOID *lpPtr;
|
---|
1392 | INT nIndex;
|
---|
1393 |
|
---|
1394 | // TRACE (commctrl, "linear search\n");
|
---|
1395 |
|
---|
1396 | nIndex = (nStart == -1)? 0 : nStart;
|
---|
1397 | lpPtr = hdpa->ptrs;
|
---|
1398 | for (; nIndex < hdpa->nItemCount; nIndex++) {
|
---|
1399 | if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
|
---|
1400 | // TRACE (commctrl, "-- ret=%d\n", nIndex);
|
---|
1401 | return nIndex;
|
---|
1402 | }
|
---|
1403 | }
|
---|
1404 | }
|
---|
1405 |
|
---|
1406 | // TRACE (commctrl, "-- not found: ret=-1\n");
|
---|
1407 | return -1;
|
---|
1408 | }
|
---|
1409 |
|
---|
1410 |
|
---|
1411 | /**************************************************************************
|
---|
1412 | * DPA_CreateEx [COMCTL32.340]
|
---|
1413 | *
|
---|
1414 | * Creates a dynamic pointer array using the specified size and heap.
|
---|
1415 | *
|
---|
1416 | * PARAMS
|
---|
1417 | * nGrow [I] number of items by which the array grows when it is filled
|
---|
1418 | * hHeap [I] handle to the heap where the array is stored
|
---|
1419 | *
|
---|
1420 | * RETURNS
|
---|
1421 | * Success: handle (pointer) to the pointer array.
|
---|
1422 | * Failure: NULL
|
---|
1423 | */
|
---|
1424 |
|
---|
1425 | HDPA WINAPI
|
---|
1426 | DPA_CreateEx (INT nGrow, HANDLE hHeap)
|
---|
1427 | {
|
---|
1428 | HDPA hdpa;
|
---|
1429 |
|
---|
1430 | // TRACE (commctrl, "(%d 0x%x)\n", nGrow, hHeap);
|
---|
1431 |
|
---|
1432 | if (hHeap)
|
---|
1433 | hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
|
---|
1434 | else
|
---|
1435 | hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
|
---|
1436 |
|
---|
1437 | if (hdpa) {
|
---|
1438 | hdpa->nGrow = MIN(8, nGrow);
|
---|
1439 | hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
|
---|
1440 | hdpa->nMaxCount = hdpa->nGrow * 2;
|
---|
1441 | hdpa->ptrs =
|
---|
1442 | (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
|
---|
1443 | hdpa->nMaxCount * sizeof(LPVOID));
|
---|
1444 | }
|
---|
1445 |
|
---|
1446 | // TRACE (commctrl, "-- %p\n", hdpa);
|
---|
1447 |
|
---|
1448 | return hdpa;
|
---|
1449 | }
|
---|
1450 |
|
---|
1451 | /**************************************************************************
|
---|
1452 | * Notification functions
|
---|
1453 | */
|
---|
1454 |
|
---|
1455 | typedef struct tagNOTIFYDATA
|
---|
1456 | {
|
---|
1457 | HWND hwndFrom;
|
---|
1458 | HWND hwndTo;
|
---|
1459 | DWORD dwParam3;
|
---|
1460 | DWORD dwParam4;
|
---|
1461 | DWORD dwParam5;
|
---|
1462 | DWORD dwParam6;
|
---|
1463 | } NOTIFYDATA, *LPNOTIFYDATA;
|
---|
1464 |
|
---|
1465 |
|
---|
1466 | /**************************************************************************
|
---|
1467 | * DoNotify [Internal]
|
---|
1468 | */
|
---|
1469 |
|
---|
1470 | static LRESULT
|
---|
1471 | DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr)
|
---|
1472 | {
|
---|
1473 | NMHDR nmhdr;
|
---|
1474 | LPNMHDR lpNmh = NULL;
|
---|
1475 | UINT idFrom = 0;
|
---|
1476 |
|
---|
1477 | // TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
|
---|
1478 | // lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
|
---|
1479 | // lpNotify->dwParam5);
|
---|
1480 |
|
---|
1481 | if (!lpNotify->hwndTo)
|
---|
1482 | return 0;
|
---|
1483 |
|
---|
1484 | if (lpNotify->hwndFrom == -1) {
|
---|
1485 | lpNmh = lpHdr;
|
---|
1486 | idFrom = lpHdr->idFrom;
|
---|
1487 | }
|
---|
1488 | else {
|
---|
1489 | if (lpNotify->hwndFrom) {
|
---|
1490 | HWND hwndParent = GetParent (lpNotify->hwndFrom);
|
---|
1491 | if (hwndParent) {
|
---|
1492 | hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
|
---|
1493 | if (hwndParent)
|
---|
1494 | idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
|
---|
1495 | }
|
---|
1496 | }
|
---|
1497 |
|
---|
1498 | lpNmh = (lpHdr) ? lpHdr : &nmhdr;
|
---|
1499 |
|
---|
1500 | lpNmh->hwndFrom = lpNotify->hwndFrom;
|
---|
1501 | lpNmh->idFrom = idFrom;
|
---|
1502 | lpNmh->code = uCode;
|
---|
1503 | }
|
---|
1504 |
|
---|
1505 | return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh);
|
---|
1506 | }
|
---|
1507 |
|
---|
1508 |
|
---|
1509 | /**************************************************************************
|
---|
1510 | * SendNotify [COMCTL32.341]
|
---|
1511 | *
|
---|
1512 | * PARAMS
|
---|
1513 | * hwndFrom [I]
|
---|
1514 | * hwndTo [I]
|
---|
1515 | * uCode [I]
|
---|
1516 | * lpHdr [I]
|
---|
1517 | *
|
---|
1518 | * RETURNS
|
---|
1519 | * Success: return value from notification
|
---|
1520 | * Failure: 0
|
---|
1521 | */
|
---|
1522 |
|
---|
1523 | LRESULT WINAPI
|
---|
1524 | COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
|
---|
1525 | UINT uCode, LPNMHDR lpHdr)
|
---|
1526 | {
|
---|
1527 | NOTIFYDATA notify;
|
---|
1528 |
|
---|
1529 | // TRACE (commctrl, "(0x%04x 0x%04x %d %p)\n",
|
---|
1530 | // hwndFrom, hwndTo, uCode, lpHdr);
|
---|
1531 |
|
---|
1532 | notify.hwndFrom = hwndFrom;
|
---|
1533 | notify.hwndTo = hwndTo;
|
---|
1534 | notify.dwParam5 = 0;
|
---|
1535 | notify.dwParam6 = 0;
|
---|
1536 |
|
---|
1537 | return DoNotify (¬ify, uCode, lpHdr);
|
---|
1538 | }
|
---|
1539 |
|
---|
1540 |
|
---|
1541 | /**************************************************************************
|
---|
1542 | * SendNotifyEx [COMCTL32.342]
|
---|
1543 | *
|
---|
1544 | * PARAMS
|
---|
1545 | * hwndFrom [I]
|
---|
1546 | * hwndTo [I]
|
---|
1547 | * uCode [I]
|
---|
1548 | * lpHdr [I]
|
---|
1549 | * dwParam5 [I]
|
---|
1550 | *
|
---|
1551 | * RETURNS
|
---|
1552 | * Success: return value from notification
|
---|
1553 | * Failure: 0
|
---|
1554 | */
|
---|
1555 |
|
---|
1556 | LRESULT WINAPI
|
---|
1557 | COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
|
---|
1558 | LPNMHDR lpHdr, DWORD dwParam5)
|
---|
1559 | {
|
---|
1560 | NOTIFYDATA notify;
|
---|
1561 | HWND hwndNotify;
|
---|
1562 |
|
---|
1563 | // TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
|
---|
1564 | // hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
|
---|
1565 |
|
---|
1566 | hwndNotify = hwndTo;
|
---|
1567 | if (!hwndTo) {
|
---|
1568 | if (IsWindow (hwndFrom)) {
|
---|
1569 | hwndNotify = GetParent (hwndFrom);
|
---|
1570 | if (!hwndNotify)
|
---|
1571 | return 0;
|
---|
1572 | }
|
---|
1573 | }
|
---|
1574 |
|
---|
1575 | notify.hwndFrom = hwndFrom;
|
---|
1576 | notify.hwndTo = hwndNotify;
|
---|
1577 | notify.dwParam5 = dwParam5;
|
---|
1578 | notify.dwParam6 = 0;
|
---|
1579 |
|
---|
1580 | return DoNotify (¬ify, uCode, lpHdr);
|
---|
1581 | }
|
---|
1582 |
|
---|
1583 |
|
---|
1584 | /**************************************************************************
|
---|
1585 | * StrChrA [COMCTL32.350]
|
---|
1586 | *
|
---|
1587 | */
|
---|
1588 |
|
---|
1589 | LPSTR WINAPI
|
---|
1590 | COMCTL32_StrChrA (LPCSTR lpString, CHAR cChar)
|
---|
1591 | {
|
---|
1592 | return strchr (lpString, cChar);
|
---|
1593 | }
|
---|
1594 |
|
---|
1595 |
|
---|
1596 | /**************************************************************************
|
---|
1597 | * StrStrIA [COMCTL32.355]
|
---|
1598 | */
|
---|
1599 |
|
---|
1600 | LPSTR WINAPI
|
---|
1601 | COMCTL32_StrStrIA (LPCSTR lpStr1, LPCSTR lpStr2)
|
---|
1602 | {
|
---|
1603 | INT len1, len2, i;
|
---|
1604 | CHAR first;
|
---|
1605 |
|
---|
1606 | if (*lpStr2 == 0)
|
---|
1607 | return ((LPSTR)lpStr1);
|
---|
1608 | len1 = 0;
|
---|
1609 | while (lpStr1[len1] != 0) ++len1;
|
---|
1610 | len2 = 0;
|
---|
1611 | while (lpStr2[len2] != 0) ++len2;
|
---|
1612 | if (len2 == 0)
|
---|
1613 | return ((LPSTR)(lpStr1 + len1));
|
---|
1614 | first = tolower (*lpStr2);
|
---|
1615 | while (len1 >= len2) {
|
---|
1616 | if (tolower(*lpStr1) == first) {
|
---|
1617 | for (i = 1; i < len2; ++i)
|
---|
1618 | if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
|
---|
1619 | break;
|
---|
1620 | if (i >= len2)
|
---|
1621 | return ((LPSTR)lpStr1);
|
---|
1622 | }
|
---|
1623 | ++lpStr1; --len1;
|
---|
1624 | }
|
---|
1625 | return (NULL);
|
---|
1626 | }
|
---|
1627 |
|
---|
1628 |
|
---|
1629 | /**************************************************************************
|
---|
1630 | * StrToIntA [COMCTL32.357] Converts a string to a signed integer.
|
---|
1631 | */
|
---|
1632 |
|
---|
1633 | INT WINAPI
|
---|
1634 | COMCTL32_StrToIntA (LPSTR lpString)
|
---|
1635 | {
|
---|
1636 | return atoi(lpString);
|
---|
1637 | }
|
---|
1638 |
|
---|
1639 | /**************************************************************************
|
---|
1640 | * DPA_EnumCallback [COMCTL32.385]
|
---|
1641 | *
|
---|
1642 | * Enumerates all items in a dynamic pointer array.
|
---|
1643 | *
|
---|
1644 | * PARAMS
|
---|
1645 | * hdpa [I] handle to the dynamic pointer array
|
---|
1646 | * enumProc [I]
|
---|
1647 | * lParam [I]
|
---|
1648 | *
|
---|
1649 | * RETURNS
|
---|
1650 | * none
|
---|
1651 | */
|
---|
1652 |
|
---|
1653 | VOID WINAPI
|
---|
1654 | DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
|
---|
1655 | {
|
---|
1656 | INT i;
|
---|
1657 |
|
---|
1658 | // TRACE (commctrl, "(%p %p %08lx)\n", hdpa, enumProc, lParam);
|
---|
1659 |
|
---|
1660 | if (!hdpa)
|
---|
1661 | return;
|
---|
1662 | if (hdpa->nItemCount <= 0)
|
---|
1663 | return;
|
---|
1664 |
|
---|
1665 | for (i = 0; i < hdpa->nItemCount; i++) {
|
---|
1666 | if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
|
---|
1667 | return;
|
---|
1668 | }
|
---|
1669 |
|
---|
1670 | return;
|
---|
1671 | }
|
---|
1672 |
|
---|
1673 |
|
---|
1674 | /**************************************************************************
|
---|
1675 | * DPA_DestroyCallback [COMCTL32.386]
|
---|
1676 | *
|
---|
1677 | * Enumerates all items in a dynamic pointer array and destroys it.
|
---|
1678 | *
|
---|
1679 | * PARAMS
|
---|
1680 | * hdpa [I] handle to the dynamic pointer array
|
---|
1681 | * enumProc [I]
|
---|
1682 | * lParam [I]
|
---|
1683 | *
|
---|
1684 | * RETURNS
|
---|
1685 | * Success: TRUE
|
---|
1686 | * Failure: FALSE
|
---|
1687 | */
|
---|
1688 |
|
---|
1689 | BOOL WINAPI
|
---|
1690 | DPA_DestroyCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
|
---|
1691 | {
|
---|
1692 | // TRACE (commctrl, "(%p %p %08lx)\n", hdpa, enumProc, lParam);
|
---|
1693 |
|
---|
1694 | DPA_EnumCallback (hdpa, enumProc, lParam);
|
---|
1695 |
|
---|
1696 | return DPA_Destroy (hdpa);
|
---|
1697 | }
|
---|
1698 |
|
---|
1699 |
|
---|
1700 | /**************************************************************************
|
---|
1701 | * DSA_EnumCallback [COMCTL32.387]
|
---|
1702 | *
|
---|
1703 | * Enumerates all items in a dynamic storage array.
|
---|
1704 | *
|
---|
1705 | * PARAMS
|
---|
1706 | * hdsa [I] handle to the dynamic storage array
|
---|
1707 | * enumProc [I]
|
---|
1708 | * lParam [I]
|
---|
1709 | *
|
---|
1710 | * RETURNS
|
---|
1711 | * none
|
---|
1712 | */
|
---|
1713 |
|
---|
1714 | VOID WINAPI
|
---|
1715 | DSA_EnumCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
|
---|
1716 | {
|
---|
1717 | INT i;
|
---|
1718 |
|
---|
1719 | // TRACE (commctrl, "(%p %p %08lx)\n", hdsa, enumProc, lParam);
|
---|
1720 |
|
---|
1721 | if (!hdsa)
|
---|
1722 | return;
|
---|
1723 | if (hdsa->nItemCount <= 0)
|
---|
1724 | return;
|
---|
1725 |
|
---|
1726 | for (i = 0; i < hdsa->nItemCount; i++) {
|
---|
1727 | LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
|
---|
1728 | if ((enumProc)(lpItem, lParam) == 0)
|
---|
1729 | return;
|
---|
1730 | }
|
---|
1731 |
|
---|
1732 | return;
|
---|
1733 | }
|
---|
1734 |
|
---|
1735 |
|
---|
1736 | /**************************************************************************
|
---|
1737 | * DSA_DestroyCallback [COMCTL32.388]
|
---|
1738 | *
|
---|
1739 | * Enumerates all items in a dynamic storage array and destroys it.
|
---|
1740 | *
|
---|
1741 | * PARAMS
|
---|
1742 | * hdsa [I] handle to the dynamic storage array
|
---|
1743 | * enumProc [I]
|
---|
1744 | * lParam [I]
|
---|
1745 | *
|
---|
1746 | * RETURNS
|
---|
1747 | * Success: TRUE
|
---|
1748 | * Failure: FALSE
|
---|
1749 | */
|
---|
1750 |
|
---|
1751 | BOOL WINAPI
|
---|
1752 | DSA_DestroyCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
|
---|
1753 | {
|
---|
1754 | // TRACE (commctrl, "(%p %p %08lx)\n", hdsa, enumProc, lParam);
|
---|
1755 |
|
---|
1756 | DSA_EnumCallback (hdsa, enumProc, lParam);
|
---|
1757 |
|
---|
1758 | return DSA_Destroy (hdsa);
|
---|
1759 | }
|
---|
1760 |
|
---|
1761 | /**************************************************************************
|
---|
1762 | * StrCSpnA [COMCTL32.356]
|
---|
1763 | *
|
---|
1764 | */
|
---|
1765 | INT WINAPI COMCTL32_StrCSpnA( LPCSTR lpStr, LPCSTR lpSet) {
|
---|
1766 | return strcspn(lpStr, lpSet);
|
---|
1767 | }
|
---|
1768 |
|
---|
1769 | /**************************************************************************
|
---|
1770 | * StrChrW [COMCTL32.358]
|
---|
1771 | *
|
---|
1772 | */
|
---|
1773 | LPWSTR WINAPI COMCTL32_StrChrW( LPCWSTR lpStart, WORD wMatch) {
|
---|
1774 | // return CRTDLL_wcschr(lpStart, wMatch);
|
---|
1775 | }
|
---|
1776 |
|
---|
1777 | /**************************************************************************
|
---|
1778 | * StrCmpNA [COMCTL32.352]
|
---|
1779 | *
|
---|
1780 | */
|
---|
1781 | INT WINAPI COMCTL32_StrCmpNA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
|
---|
1782 | // return lstrncmpA(lpStr1, lpStr2, nChar);
|
---|
1783 | }
|
---|
1784 |
|
---|
1785 | /**************************************************************************
|
---|
1786 | * StrCmpNW [COMCTL32.360]
|
---|
1787 | *
|
---|
1788 | */
|
---|
1789 | INT WINAPI COMCTL32_StrCmpNW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
|
---|
1790 | // return lstrncmpW(lpStr1, lpStr2, nChar);
|
---|
1791 | }
|
---|
1792 |
|
---|
1793 | /**************************************************************************
|
---|
1794 | * StrRChrA [COMCTL32.351]
|
---|
1795 | *
|
---|
1796 | */
|
---|
1797 | LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch) {
|
---|
1798 | // return lstrrchr(lpStart, lpEnd, wMatch);
|
---|
1799 | }
|
---|
1800 |
|
---|
1801 | /**************************************************************************
|
---|
1802 | * StrRChrW [COMCTL32.359]
|
---|
1803 | *
|
---|
1804 | */
|
---|
1805 | LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch) {
|
---|
1806 | // return lstrrchrw(lpStart, lpEnd, wMatch);
|
---|
1807 | }
|
---|
1808 |
|
---|
1809 | /**************************************************************************
|
---|
1810 | * StrStrA [COMCTL32.354]
|
---|
1811 | *
|
---|
1812 | */
|
---|
1813 | LPSTR WINAPI COMCTL32_StrStrA( LPCSTR lpFirst, LPCSTR lpSrch) {
|
---|
1814 | return strstr(lpFirst, lpSrch);
|
---|
1815 | }
|
---|
1816 |
|
---|
1817 | /**************************************************************************
|
---|
1818 | * StrStrW [COMCTL32.362]
|
---|
1819 | *
|
---|
1820 | */
|
---|
1821 | LPWSTR WINAPI COMCTL32_StrStrW( LPCWSTR lpFirst, LPCWSTR lpSrch) {
|
---|
1822 | // return strstrw(lpFirst, lpSrch);
|
---|
1823 | }
|
---|
1824 |
|
---|
1825 | /**************************************************************************
|
---|
1826 | * StrSpnW [COMCTL32.364]
|
---|
1827 | *
|
---|
1828 | */
|
---|
1829 | INT WINAPI COMCTL32_StrSpnW( LPWSTR lpStr, LPWSTR lpSet) {
|
---|
1830 | LPWSTR lpLoop = lpStr;
|
---|
1831 |
|
---|
1832 | /* validate ptr */
|
---|
1833 | if ((lpStr == 0) || (lpSet == 0)) return 0;
|
---|
1834 |
|
---|
1835 | /* while(*lpLoop) { if lpLoop++; } */
|
---|
1836 |
|
---|
1837 | // for(; (*lpLoop != 0); lpLoop++)
|
---|
1838 | // if( CRTDLL_wcschr(lpSet, *(WORD*)lpLoop))
|
---|
1839 | // return (INT)(lpLoop-lpStr);
|
---|
1840 |
|
---|
1841 | // return (INT)(lpLoop-lpStr);
|
---|
1842 | }
|
---|