source: trunk/src/comctl32/comctl32undoc.c@ 94

Last change on this file since 94 was 94, checked in by achimha, 26 years ago

Added CVS tag to many files (comctl32 and headers) .

File size: 39.9 KB
Line 
1/* $Id: comctl32undoc.c,v 1.6 1999-06-10 16:21:58 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
20extern 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
37BOOL WINAPI
38DPA_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
113LPVOID 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
142LPVOID 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
168BOOL 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
188DWORD 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
202typedef 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
213typedef 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
223LPVOID WINAPI
224CreateMRUListLazyA (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
237LPVOID WINAPI
238CreateMRUListA (LPMRUINFO lpmi)
239{
240 return CreateMRUListLazyA (lpmi, 0, 0, 0);
241}
242
243
244DWORD WINAPI
245FreeMRUListA (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
266DWORD WINAPI
267AddMRUData (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
277DWORD WINAPI
278FindMRUData (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
288LPVOID WINAPI
289CreateMRUListLazyA (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
332INT WINAPI
333Str_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
371BOOL WINAPI
372Str_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
405INT WINAPI
406Str_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
444BOOL WINAPI
445Str_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
486HDSA WINAPI
487DSA_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
518BOOL WINAPI
519DSA_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
546BOOL WINAPI
547DSA_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
579LPVOID WINAPI
580DSA_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
614BOOL WINAPI
615DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
616{
617 INT nSize, nNewItems;
618 LPVOID pDest, lpTemp;
619
620// TRACE (commctrl, "(%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;
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->pData = lpTemp;
643 }
644 }
645
646 /* put the new entry in */
647 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
648// TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
649// pDest, pSrc, hdsa->nItemSize);
650 memmove (pDest, pSrc, hdsa->nItemSize);
651
652 return TRUE;
653}
654
655
656/**************************************************************************
657 * DSA_InsertItem [COMCTL32.325]
658 *
659 * PARAMS
660 * hdsa [I] pointer to the array control structure
661 * nIndex [I] index for the new item
662 * pSrc [I] pointer to the element
663 *
664 * RETURNS
665 * Success: position of the new item
666 * Failure: -1
667 */
668
669INT WINAPI
670DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
671{
672 INT nNewItems, nSize, i;
673 LPVOID lpTemp, lpDest;
674 LPDWORD p;
675
676// TRACE(commctrl, "(%p %d %p)\n", hdsa, nIndex, pSrc);
677
678 if ((!hdsa) || nIndex < 0)
679 return -1;
680
681 for (i = 0; i < hdsa->nItemSize; i += 4) {
682 p = *(DWORD**)((char *) pSrc + i);
683// if (IsBadStringPtrA ((char*)p, 256))
684// TRACE (commctrl, "-- %d=%p\n", i, (DWORD*)p);
685// else
686// TRACE (commctrl, "-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
687 }
688
689 /* when nIndex > nItemCount then append */
690 if (nIndex >= hdsa->nItemCount)
691 nIndex = hdsa->nItemCount;
692
693 /* do we need to resize ? */
694 if (hdsa->nItemCount >= hdsa->nMaxCount) {
695 nNewItems = hdsa->nMaxCount + hdsa->nGrow;
696 nSize = hdsa->nItemSize * nNewItems;
697
698 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
699 if (!lpTemp)
700 return -1;
701
702 hdsa->nMaxCount = nNewItems;
703 hdsa->pData = lpTemp;
704 }
705
706 /* do we need to move elements ? */
707 if (nIndex < hdsa->nItemCount) {
708 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
709 lpDest = (char *) lpTemp + hdsa->nItemSize;
710 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
711// TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
712// lpDest, lpTemp, nSize);
713 memmove (lpDest, lpTemp, nSize);
714 }
715
716 /* ok, we can put the new Item in */
717 hdsa->nItemCount++;
718 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
719// TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
720// lpDest, pSrc, hdsa->nItemSize);
721 memmove (lpDest, pSrc, hdsa->nItemSize);
722
723 return hdsa->nItemCount;
724}
725
726
727/**************************************************************************
728 * DSA_DeleteItem [COMCTL32.326]
729 *
730 * PARAMS
731 * hdsa [I] pointer to the array control structure
732 * nIndex [I] index for the element to delete
733 *
734 * RETURNS
735 * Success: number of the deleted element
736 * Failure: -1
737 */
738
739INT WINAPI
740DSA_DeleteItem (const HDSA hdsa, INT nIndex)
741{
742 LPVOID lpDest,lpSrc;
743 INT nSize;
744
745// TRACE (commctrl, "(%p %d)\n", hdsa, nIndex);
746
747 if (!hdsa)
748 return -1;
749 if (nIndex < 0 || nIndex >= hdsa->nItemCount)
750 return -1;
751
752 /* do we need to move ? */
753 if (nIndex < hdsa->nItemCount - 1) {
754 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
755 lpSrc = (char *) lpDest + hdsa->nItemSize;
756 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
757// TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
758// lpDest, lpSrc, nSize);
759 memmove (lpDest, lpSrc, nSize);
760 }
761
762 hdsa->nItemCount--;
763
764 /* free memory ? */
765 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
766 nSize = hdsa->nItemSize * hdsa->nItemCount;
767
768 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
769 if (!lpDest)
770 return -1;
771
772 hdsa->nMaxCount = hdsa->nItemCount;
773 hdsa->pData = lpDest;
774 }
775
776 return nIndex;
777}
778
779
780/**************************************************************************
781 * DSA_DeleteAllItems [COMCTL32.326]
782 *
783 * Removes all items and reinitializes the array.
784 *
785 * PARAMS
786 * hdsa [I] pointer to the array control structure
787 *
788 * RETURNS
789 * Success: TRUE
790 * Failure: FALSE
791 */
792
793BOOL WINAPI
794DSA_DeleteAllItems (const HDSA hdsa)
795{
796// TRACE (commctrl, "(%p)\n", hdsa);
797
798 if (!hdsa)
799 return FALSE;
800 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
801 return FALSE;
802
803 hdsa->nItemCount = 0;
804 hdsa->pData = NULL;
805 hdsa->nMaxCount = 0;
806
807 return TRUE;
808}
809
810
811/**************************************************************************
812 * The DPA-API is a set of functions to create and manipulate arrays of
813 * pointers.
814 */
815
816/**************************************************************************
817 * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
818 *
819 * PARAMS
820 * nGrow [I] number of items by which the array grows when it is filled
821 *
822 * RETURNS
823 * Success: handle (pointer) to the pointer array.
824 * Failure: NULL
825 */
826
827HDPA WINAPI
828DPA_Create (INT nGrow)
829{
830 HDPA hdpa;
831
832// TRACE (commctrl, "(%d)\n", nGrow);
833
834 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
835 if (hdpa) {
836 hdpa->nGrow = MAX(8, nGrow);
837 hdpa->hHeap = COMCTL32_hHeap;
838 hdpa->nMaxCount = hdpa->nGrow * 2;
839 hdpa->ptrs =
840 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
841 }
842
843// TRACE (commctrl, "-- %p\n", hdpa);
844
845 return hdpa;
846}
847
848
849/**************************************************************************
850 * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
851 *
852 * PARAMS
853 * hdpa [I] handle (pointer) to the pointer array
854 *
855 * RETURNS
856 * Success: TRUE
857 * Failure: FALSE
858 */
859
860BOOL WINAPI
861DPA_Destroy (const HDPA hdpa)
862{
863// TRACE (commctrl, "(%p)\n", hdpa);
864
865 if (!hdpa)
866 return FALSE;
867
868 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
869 return FALSE;
870
871 return HeapFree (hdpa->hHeap, 0, hdpa);
872}
873
874
875/**************************************************************************
876 * DPA_Grow [COMCTL32.330]
877 *
878 * Sets the growth amount.
879 *
880 * PARAMS
881 * hdpa [I] handle (pointer) to the existing (source) pointer array
882 * nGrow [I] number of items, the array grows, when it's too small
883 *
884 * RETURNS
885 * Success: TRUE
886 * Failure: FALSE
887 */
888
889BOOL WINAPI
890DPA_Grow (const HDPA hdpa, INT nGrow)
891{
892// TRACE (commctrl, "(%p %d)\n", hdpa, nGrow);
893
894 if (!hdpa)
895 return FALSE;
896
897 hdpa->nGrow = MAX(8, nGrow);
898
899 return TRUE;
900}
901
902
903/**************************************************************************
904 * DPA_Clone [COMCTL32.331]
905 *
906 * Copies a pointer array to an other one or creates a copy
907 *
908 * PARAMS
909 * hdpa [I] handle (pointer) to the existing (source) pointer array
910 * hdpaNew [O] handle (pointer) to the destination pointer array
911 *
912 * RETURNS
913 * Success: pointer to the destination pointer array.
914 * Failure: NULL
915 *
916 * NOTES
917 * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer
918 * array will be created and it's handle (pointer) is returned.
919 * - If 'hdpa' is a NULL-Pointer, the original implementation crashes,
920 * this implementation just returns NULL.
921 */
922
923HDPA WINAPI
924DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
925{
926 INT nNewItems, nSize;
927 HDPA hdpaTemp;
928
929 if (!hdpa)
930 return NULL;
931
932// TRACE (commctrl, "(%p %p)\n", hdpa, hdpaNew);
933
934 if (!hdpaNew) {
935 /* create a new DPA */
936 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
937 sizeof(DPA));
938 hdpaTemp->hHeap = hdpa->hHeap;
939 hdpaTemp->nGrow = hdpa->nGrow;
940 }
941 else
942 hdpaTemp = hdpaNew;
943
944 if (hdpaTemp->ptrs) {
945 /* remove old pointer array */
946 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
947 hdpaTemp->ptrs = NULL;
948 hdpaTemp->nItemCount = 0;
949 hdpaTemp->nMaxCount = 0;
950 }
951
952 /* create a new pointer array */
953 nNewItems = hdpaTemp->nGrow *
954 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
955 nSize = nNewItems * sizeof(LPVOID);
956 hdpaTemp->ptrs =
957 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
958 hdpaTemp->nMaxCount = nNewItems;
959
960 /* clone the pointer array */
961 hdpaTemp->nItemCount = hdpa->nItemCount;
962 memmove (hdpaTemp->ptrs, hdpa->ptrs,
963 hdpaTemp->nItemCount * sizeof(LPVOID));
964
965 return hdpaTemp;
966}
967
968
969/**************************************************************************
970 * DPA_GetPtr [COMCTL32.332]
971 *
972 * Retrieves a pointer from a dynamic pointer array
973 *
974 * PARAMS
975 * hdpa [I] handle (pointer) to the pointer array
976 * nIndex [I] array index of the desired pointer
977 *
978 * RETURNS
979 * Success: pointer
980 * Failure: NULL
981 */
982
983LPVOID WINAPI
984DPA_GetPtr (const HDPA hdpa, INT i)
985{
986// TRACE (commctrl, "(%p %d)\n", hdpa, i);
987
988 if (!hdpa)
989 return NULL;
990 if (!hdpa->ptrs)
991 return NULL;
992 if ((i < 0) || (i >= hdpa->nItemCount))
993 return NULL;
994
995// TRACE (commctrl, "-- %p\n", hdpa->ptrs[i]);
996
997 return hdpa->ptrs[i];
998}
999
1000
1001/**************************************************************************
1002 * DPA_GetPtrIndex [COMCTL32.333]
1003 *
1004 * Retrieves the index of the specified pointer
1005 *
1006 * PARAMS
1007 * hdpa [I] handle (pointer) to the pointer array
1008 * p [I] pointer
1009 *
1010 * RETURNS
1011 * Success: index of the specified pointer
1012 * Failure: -1
1013 */
1014
1015INT WINAPI
1016DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
1017{
1018 INT i;
1019
1020 if (!hdpa->ptrs)
1021 return -1;
1022
1023 for (i = 0; i < hdpa->nItemCount; i++) {
1024 if (hdpa->ptrs[i] == p)
1025 return i;
1026 }
1027
1028 return -1;
1029}
1030
1031
1032/**************************************************************************
1033 * DPA_InsertPtr [COMCTL32.334]
1034 *
1035 * Inserts a pointer into a dynamic pointer array
1036 *
1037 * PARAMS
1038 * hdpa [I] handle (pointer) to the array
1039 * i [I] array index
1040 * p [I] pointer to insert
1041 *
1042 * RETURNS
1043 * Success: index of the inserted pointer
1044 * Failure: -1
1045 */
1046
1047INT WINAPI
1048DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
1049{
1050 INT nNewItems, nSize, nIndex = 0;
1051 LPVOID *lpTemp, *lpDest;
1052
1053// TRACE (commctrl, "(%p %d %p)\n", hdpa, i, p);
1054
1055 if ((!hdpa) || (i < 0))
1056 return -1;
1057
1058 if (!hdpa->ptrs) {
1059 hdpa->ptrs =
1060 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1061 2 * hdpa->nGrow * sizeof(LPVOID));
1062 if (!hdpa->ptrs)
1063 return -1;
1064 hdpa->nMaxCount = hdpa->nGrow * 2;
1065 nIndex = 0;
1066 }
1067 else {
1068 if (hdpa->nItemCount >= hdpa->nMaxCount) {
1069// TRACE (commctrl, "-- resizing\n");
1070 nNewItems = hdpa->nMaxCount + hdpa->nGrow;
1071 nSize = nNewItems * sizeof(LPVOID);
1072
1073 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1074 hdpa->ptrs, nSize);
1075 if (!lpTemp)
1076 return -1;
1077 hdpa->nMaxCount = nNewItems;
1078 hdpa->ptrs = lpTemp;
1079 }
1080
1081 if (i >= hdpa->nItemCount) {
1082 nIndex = hdpa->nItemCount;
1083// TRACE (commctrl, "-- appending at %d\n", nIndex);
1084 }
1085 else {
1086// TRACE (commctrl, "-- inserting at %d\n", i);
1087 lpTemp = hdpa->ptrs + i;
1088 lpDest = lpTemp + 1;
1089 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID);
1090// TRACE (commctrl, "-- move dest=%p src=%p size=%x\n",
1091// lpDest, lpTemp, nSize);
1092 memmove (lpDest, lpTemp, nSize);
1093 nIndex = i;
1094 }
1095 }
1096
1097 /* insert item */
1098 hdpa->nItemCount++;
1099 hdpa->ptrs[nIndex] = p;
1100
1101 return nIndex;
1102}
1103
1104
1105/**************************************************************************
1106 * DPA_SetPtr [COMCTL32.335]
1107 *
1108 * Sets a pointer in the pointer array
1109 *
1110 * PARAMS
1111 * hdpa [I] handle (pointer) to the pointer array
1112 * i [I] index of the pointer that will be set
1113 * p [I] pointer to be set
1114 *
1115 * RETURNS
1116 * Success: TRUE
1117 * Failure: FALSE
1118 */
1119
1120BOOL WINAPI
1121DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
1122{
1123 LPVOID *lpTemp;
1124
1125// TRACE (commctrl, "(%p %d %p)\n", hdpa, i, p);
1126
1127 if ((!hdpa) || i < 0)
1128 return FALSE;
1129
1130 if (hdpa->nItemCount <= i) {
1131 /* within the old array */
1132 if (hdpa->nMaxCount > i) {
1133 /* within the allocated space, set a new boundary */
1134 hdpa->nItemCount = i;
1135 }
1136 else {
1137 /* resize the block of memory */
1138 INT nNewItems =
1139 hdpa->nGrow * ((INT)((i - 1) / hdpa->nGrow) + 1);
1140 INT nSize = nNewItems * sizeof(LPVOID);
1141
1142 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1143 hdpa->ptrs, nSize);
1144 if (!lpTemp)
1145 return FALSE;
1146
1147 hdpa->nItemCount = nNewItems;
1148 hdpa->ptrs = lpTemp;
1149 }
1150 }
1151
1152 /* put the new entry in */
1153 hdpa->ptrs[i] = p;
1154
1155 return TRUE;
1156}
1157
1158
1159/**************************************************************************
1160 * DPA_DeletePtr [COMCTL32.336]
1161 *
1162 * Removes a pointer from the pointer array.
1163 *
1164 * PARAMS
1165 * hdpa [I] handle (pointer) to the pointer array
1166 * i [I] index of the pointer that will be deleted
1167 *
1168 * RETURNS
1169 * Success: deleted pointer
1170 * Failure: NULL
1171 */
1172
1173LPVOID WINAPI
1174DPA_DeletePtr (const HDPA hdpa, INT i)
1175{
1176 LPVOID *lpDest, *lpSrc, lpTemp = NULL;
1177 INT nSize;
1178
1179// TRACE (commctrl, "(%p %d)\n", hdpa, i);
1180
1181 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
1182 return NULL;
1183
1184 lpTemp = hdpa->ptrs[i];
1185
1186 /* do we need to move ?*/
1187 if (i < hdpa->nItemCount - 1) {
1188 lpDest = hdpa->ptrs + i;
1189 lpSrc = lpDest + 1;
1190 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
1191// TRACE (commctrl,"-- move dest=%p src=%p size=%x\n",
1192// lpDest, lpSrc, nSize);
1193 memmove (lpDest, lpSrc, nSize);
1194 }
1195
1196 hdpa->nItemCount --;
1197
1198 /* free memory ?*/
1199 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
1200 INT nNewItems = MIN(hdpa->nGrow * 2, hdpa->nItemCount);
1201 nSize = nNewItems * sizeof(LPVOID);
1202 lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1203 hdpa->ptrs, nSize);
1204 if (!lpDest)
1205 return NULL;
1206
1207 hdpa->nMaxCount = nNewItems;
1208 hdpa->ptrs = (LPVOID*)lpDest;
1209 }
1210
1211 return lpTemp;
1212}
1213
1214
1215/**************************************************************************
1216 * DPA_DeleteAllPtrs [COMCTL32.337]
1217 *
1218 * Removes all pointers and reinitializes the array.
1219 *
1220 * PARAMS
1221 * hdpa [I] handle (pointer) to the pointer array
1222 *
1223 * RETURNS
1224 * Success: TRUE
1225 * Failure: FALSE
1226 */
1227
1228BOOL WINAPI
1229DPA_DeleteAllPtrs (const HDPA hdpa)
1230{
1231// TRACE (commctrl, "(%p)\n", hdpa);
1232
1233 if (!hdpa)
1234 return FALSE;
1235
1236 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1237 return FALSE;
1238
1239 hdpa->nItemCount = 0;
1240 hdpa->nMaxCount = hdpa->nGrow * 2;
1241 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1242 hdpa->nMaxCount * sizeof(LPVOID));
1243
1244 return TRUE;
1245}
1246
1247
1248/**************************************************************************
1249 * DPA_QuickSort [Internal]
1250 *
1251 * Ordinary quicksort (used by DPA_Sort).
1252 *
1253 * PARAMS
1254 * lpPtrs [I] pointer to the pointer array
1255 * l [I] index of the "left border" of the partition
1256 * r [I] index of the "right border" of the partition
1257 * pfnCompare [I] pointer to the compare function
1258 * lParam [I] user defined value (3rd parameter in compare function)
1259 *
1260 * RETURNS
1261 * NONE
1262 */
1263
1264static VOID
1265DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
1266 PFNDPACOMPARE pfnCompare, LPARAM lParam)
1267{
1268 LPVOID t, v;
1269 INT i, j;
1270
1271// TRACE (commctrl, "l=%i r=%i\n", l, r);
1272
1273 i = l;
1274 j = r;
1275 v = lpPtrs[(int)(l+r)/2];
1276 do {
1277 while ((pfnCompare)(lpPtrs[i], v, lParam) > 0) i++;
1278 while ((pfnCompare)(lpPtrs[j], v, lParam) < 0) j--;
1279 if (i <= j)
1280 {
1281 t = lpPtrs[i];
1282 lpPtrs[i++] = lpPtrs[j];
1283 lpPtrs[j--] = t;
1284 }
1285 } while (i <= j);
1286 if (l < j) DPA_QuickSort (lpPtrs, l, j, pfnCompare, lParam);
1287 if (i < r) DPA_QuickSort (lpPtrs, i, r, pfnCompare, lParam);
1288}
1289
1290
1291/**************************************************************************
1292 * DPA_Sort [COMCTL32.338]
1293 *
1294 * Sorts a pointer array using a user defined compare function
1295 *
1296 * PARAMS
1297 * hdpa [I] handle (pointer) to the pointer array
1298 * pfnCompare [I] pointer to the compare function
1299 * lParam [I] user defined value (3rd parameter of compare function)
1300 *
1301 * RETURNS
1302 * Success: TRUE
1303 * Failure: FALSE
1304 */
1305
1306BOOL WINAPI
1307DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
1308{
1309 if (!hdpa || !pfnCompare)
1310 return FALSE;
1311
1312// TRACE (commctrl, "(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
1313
1314 if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
1315 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
1316 pfnCompare, lParam);
1317
1318 return TRUE;
1319}
1320
1321
1322/**************************************************************************
1323 * DPA_Search [COMCTL32.339]
1324 *
1325 * Searches a pointer array for a specified pointer
1326 *
1327 * PARAMS
1328 * hdpa [I] handle (pointer) to the pointer array
1329 * pFind [I] pointer to search for
1330 * nStart [I] start index
1331 * pfnCompare [I] pointer to the compare function
1332 * lParam [I] user defined value (3rd parameter of compare function)
1333 * uOptions [I] search options
1334 *
1335 * RETURNS
1336 * Success: index of the pointer in the array.
1337 * Failure: -1
1338 *
1339 * NOTES
1340 * Binary search taken from R.Sedgewick "Algorithms in C"!
1341 * Function is NOT tested!
1342 * If something goes wrong, blame HIM not ME! (Eric Kohl)
1343 */
1344
1345INT WINAPI
1346DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
1347 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
1348{
1349 if (!hdpa || !pfnCompare || !pFind)
1350 return -1;
1351
1352// TRACE (commctrl, "(%p %p %d %p 0x%08lx 0x%08x)\n",
1353// hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
1354
1355 if (uOptions & DPAS_SORTED) {
1356 /* array is sorted --> use binary search */
1357 INT l, r, x, n;
1358 LPVOID *lpPtr;
1359
1360// TRACE (commctrl, "binary search\n");
1361
1362 l = (nStart == -1) ? 0 : nStart;
1363 r = hdpa->nItemCount - 1;
1364 lpPtr = hdpa->ptrs;
1365 while (r >= l) {
1366 x = (l + r) / 2;
1367 n = (pfnCompare)(pFind, lpPtr[x], lParam);
1368 if (n < 0)
1369 r = x - 1;
1370 else
1371 l = x + 1;
1372 if (n == 0) {
1373// TRACE (commctrl, "-- ret=%d\n", n);
1374 return n;
1375 }
1376 }
1377
1378 if (uOptions & DPAS_INSERTBEFORE) {
1379// TRACE (commctrl, "-- ret=%d\n", r);
1380 return r;
1381 }
1382
1383 if (uOptions & DPAS_INSERTAFTER) {
1384// TRACE (commctrl, "-- ret=%d\n", l);
1385 return l;
1386 }
1387 }
1388 else {
1389 /* array is not sorted --> use linear search */
1390 LPVOID *lpPtr;
1391 INT nIndex;
1392
1393// TRACE (commctrl, "linear search\n");
1394
1395 nIndex = (nStart == -1)? 0 : nStart;
1396 lpPtr = hdpa->ptrs;
1397 for (; nIndex < hdpa->nItemCount; nIndex++) {
1398 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
1399// TRACE (commctrl, "-- ret=%d\n", nIndex);
1400 return nIndex;
1401 }
1402 }
1403 }
1404
1405// TRACE (commctrl, "-- not found: ret=-1\n");
1406 return -1;
1407}
1408
1409
1410/**************************************************************************
1411 * DPA_CreateEx [COMCTL32.340]
1412 *
1413 * Creates a dynamic pointer array using the specified size and heap.
1414 *
1415 * PARAMS
1416 * nGrow [I] number of items by which the array grows when it is filled
1417 * hHeap [I] handle to the heap where the array is stored
1418 *
1419 * RETURNS
1420 * Success: handle (pointer) to the pointer array.
1421 * Failure: NULL
1422 */
1423
1424HDPA WINAPI
1425DPA_CreateEx (INT nGrow, HANDLE hHeap)
1426{
1427 HDPA hdpa;
1428
1429// TRACE (commctrl, "(%d 0x%x)\n", nGrow, hHeap);
1430
1431 if (hHeap)
1432 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
1433 else
1434 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1435
1436 if (hdpa) {
1437 hdpa->nGrow = MIN(8, nGrow);
1438 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
1439 hdpa->nMaxCount = hdpa->nGrow * 2;
1440 hdpa->ptrs =
1441 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
1442 hdpa->nMaxCount * sizeof(LPVOID));
1443 }
1444
1445// TRACE (commctrl, "-- %p\n", hdpa);
1446
1447 return hdpa;
1448}
1449
1450/**************************************************************************
1451 * Notification functions
1452 */
1453
1454typedef struct tagNOTIFYDATA
1455{
1456 HWND hwndFrom;
1457 HWND hwndTo;
1458 DWORD dwParam3;
1459 DWORD dwParam4;
1460 DWORD dwParam5;
1461 DWORD dwParam6;
1462} NOTIFYDATA, *LPNOTIFYDATA;
1463
1464
1465/**************************************************************************
1466 * DoNotify [Internal]
1467 */
1468
1469static LRESULT
1470DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr)
1471{
1472 NMHDR nmhdr;
1473 LPNMHDR lpNmh = NULL;
1474 UINT idFrom = 0;
1475
1476// TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
1477// lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
1478// lpNotify->dwParam5);
1479
1480 if (!lpNotify->hwndTo)
1481 return 0;
1482
1483 if (lpNotify->hwndFrom == -1) {
1484 lpNmh = lpHdr;
1485 idFrom = lpHdr->idFrom;
1486 }
1487 else {
1488 if (lpNotify->hwndFrom) {
1489 HWND hwndParent = GetParent (lpNotify->hwndFrom);
1490 if (hwndParent) {
1491 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
1492 if (hwndParent)
1493 idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
1494 }
1495 }
1496
1497 lpNmh = (lpHdr) ? lpHdr : &nmhdr;
1498
1499 lpNmh->hwndFrom = lpNotify->hwndFrom;
1500 lpNmh->idFrom = idFrom;
1501 lpNmh->code = uCode;
1502 }
1503
1504 return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh);
1505}
1506
1507
1508/**************************************************************************
1509 * SendNotify [COMCTL32.341]
1510 *
1511 * PARAMS
1512 * hwndFrom [I]
1513 * hwndTo [I]
1514 * uCode [I]
1515 * lpHdr [I]
1516 *
1517 * RETURNS
1518 * Success: return value from notification
1519 * Failure: 0
1520 */
1521
1522LRESULT WINAPI
1523COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
1524 UINT uCode, LPNMHDR lpHdr)
1525{
1526 NOTIFYDATA notify;
1527
1528// TRACE (commctrl, "(0x%04x 0x%04x %d %p)\n",
1529// hwndFrom, hwndTo, uCode, lpHdr);
1530
1531 notify.hwndFrom = hwndFrom;
1532 notify.hwndTo = hwndTo;
1533 notify.dwParam5 = 0;
1534 notify.dwParam6 = 0;
1535
1536 return DoNotify (&notify, uCode, lpHdr);
1537}
1538
1539
1540/**************************************************************************
1541 * SendNotifyEx [COMCTL32.342]
1542 *
1543 * PARAMS
1544 * hwndFrom [I]
1545 * hwndTo [I]
1546 * uCode [I]
1547 * lpHdr [I]
1548 * dwParam5 [I]
1549 *
1550 * RETURNS
1551 * Success: return value from notification
1552 * Failure: 0
1553 */
1554
1555LRESULT WINAPI
1556COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
1557 LPNMHDR lpHdr, DWORD dwParam5)
1558{
1559 NOTIFYDATA notify;
1560 HWND hwndNotify;
1561
1562// TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
1563// hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
1564
1565 hwndNotify = hwndTo;
1566 if (!hwndTo) {
1567 if (IsWindow (hwndFrom)) {
1568 hwndNotify = GetParent (hwndFrom);
1569 if (!hwndNotify)
1570 return 0;
1571 }
1572 }
1573
1574 notify.hwndFrom = hwndFrom;
1575 notify.hwndTo = hwndNotify;
1576 notify.dwParam5 = dwParam5;
1577 notify.dwParam6 = 0;
1578
1579 return DoNotify (&notify, uCode, lpHdr);
1580}
1581
1582
1583/**************************************************************************
1584 * StrChrA [COMCTL32.350]
1585 *
1586 */
1587
1588LPSTR WINAPI
1589COMCTL32_StrChrA (LPCSTR lpString, CHAR cChar)
1590{
1591 return strchr (lpString, cChar);
1592}
1593
1594
1595/**************************************************************************
1596 * StrStrIA [COMCTL32.355]
1597 */
1598
1599LPSTR WINAPI
1600COMCTL32_StrStrIA (LPCSTR lpStr1, LPCSTR lpStr2)
1601{
1602 INT len1, len2, i;
1603 CHAR first;
1604
1605 if (*lpStr2 == 0)
1606 return ((LPSTR)lpStr1);
1607 len1 = 0;
1608 while (lpStr1[len1] != 0) ++len1;
1609 len2 = 0;
1610 while (lpStr2[len2] != 0) ++len2;
1611 if (len2 == 0)
1612 return ((LPSTR)(lpStr1 + len1));
1613 first = tolower (*lpStr2);
1614 while (len1 >= len2) {
1615 if (tolower(*lpStr1) == first) {
1616 for (i = 1; i < len2; ++i)
1617 if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
1618 break;
1619 if (i >= len2)
1620 return ((LPSTR)lpStr1);
1621 }
1622 ++lpStr1; --len1;
1623 }
1624 return (NULL);
1625}
1626
1627
1628/**************************************************************************
1629 * StrToIntA [COMCTL32.357] Converts a string to a signed integer.
1630 */
1631
1632INT WINAPI
1633COMCTL32_StrToIntA (LPSTR lpString)
1634{
1635 return atoi(lpString);
1636}
1637
1638/**************************************************************************
1639 * DPA_EnumCallback [COMCTL32.385]
1640 *
1641 * Enumerates all items in a dynamic pointer array.
1642 *
1643 * PARAMS
1644 * hdpa [I] handle to the dynamic pointer array
1645 * enumProc [I]
1646 * lParam [I]
1647 *
1648 * RETURNS
1649 * none
1650 */
1651
1652VOID WINAPI
1653DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
1654{
1655 INT i;
1656
1657// TRACE (commctrl, "(%p %p %08lx)\n", hdpa, enumProc, lParam);
1658
1659 if (!hdpa)
1660 return;
1661 if (hdpa->nItemCount <= 0)
1662 return;
1663
1664 for (i = 0; i < hdpa->nItemCount; i++) {
1665 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
1666 return;
1667 }
1668
1669 return;
1670}
1671
1672
1673/**************************************************************************
1674 * DPA_DestroyCallback [COMCTL32.386]
1675 *
1676 * Enumerates all items in a dynamic pointer array and destroys it.
1677 *
1678 * PARAMS
1679 * hdpa [I] handle to the dynamic pointer array
1680 * enumProc [I]
1681 * lParam [I]
1682 *
1683 * RETURNS
1684 * Success: TRUE
1685 * Failure: FALSE
1686 */
1687
1688BOOL WINAPI
1689DPA_DestroyCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
1690{
1691// TRACE (commctrl, "(%p %p %08lx)\n", hdpa, enumProc, lParam);
1692
1693 DPA_EnumCallback (hdpa, enumProc, lParam);
1694
1695 return DPA_Destroy (hdpa);
1696}
1697
1698
1699/**************************************************************************
1700 * DSA_EnumCallback [COMCTL32.387]
1701 *
1702 * Enumerates all items in a dynamic storage array.
1703 *
1704 * PARAMS
1705 * hdsa [I] handle to the dynamic storage array
1706 * enumProc [I]
1707 * lParam [I]
1708 *
1709 * RETURNS
1710 * none
1711 */
1712
1713VOID WINAPI
1714DSA_EnumCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
1715{
1716 INT i;
1717
1718// TRACE (commctrl, "(%p %p %08lx)\n", hdsa, enumProc, lParam);
1719
1720 if (!hdsa)
1721 return;
1722 if (hdsa->nItemCount <= 0)
1723 return;
1724
1725 for (i = 0; i < hdsa->nItemCount; i++) {
1726 LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
1727 if ((enumProc)(lpItem, lParam) == 0)
1728 return;
1729 }
1730
1731 return;
1732}
1733
1734
1735/**************************************************************************
1736 * DSA_DestroyCallback [COMCTL32.388]
1737 *
1738 * Enumerates all items in a dynamic storage array and destroys it.
1739 *
1740 * PARAMS
1741 * hdsa [I] handle to the dynamic storage array
1742 * enumProc [I]
1743 * lParam [I]
1744 *
1745 * RETURNS
1746 * Success: TRUE
1747 * Failure: FALSE
1748 */
1749
1750BOOL WINAPI
1751DSA_DestroyCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
1752{
1753// TRACE (commctrl, "(%p %p %08lx)\n", hdsa, enumProc, lParam);
1754
1755 DSA_EnumCallback (hdsa, enumProc, lParam);
1756
1757 return DSA_Destroy (hdsa);
1758}
1759
1760/**************************************************************************
1761 * StrCSpnA [COMCTL32.356]
1762 *
1763 */
1764INT WINAPI COMCTL32_StrCSpnA( LPCSTR lpStr, LPCSTR lpSet) {
1765 return strcspn(lpStr, lpSet);
1766}
1767
1768/**************************************************************************
1769 * StrChrW [COMCTL32.358]
1770 *
1771 */
1772LPWSTR WINAPI COMCTL32_StrChrW( LPCWSTR lpStart, WORD wMatch) {
1773// return CRTDLL_wcschr(lpStart, wMatch);
1774}
1775
1776/**************************************************************************
1777 * StrCmpNA [COMCTL32.352]
1778 *
1779 */
1780INT WINAPI COMCTL32_StrCmpNA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
1781// return lstrncmpA(lpStr1, lpStr2, nChar);
1782}
1783
1784/**************************************************************************
1785 * StrCmpNW [COMCTL32.360]
1786 *
1787 */
1788INT WINAPI COMCTL32_StrCmpNW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
1789// return lstrncmpW(lpStr1, lpStr2, nChar);
1790}
1791
1792/**************************************************************************
1793 * StrRChrA [COMCTL32.351]
1794 *
1795 */
1796LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch) {
1797// return lstrrchr(lpStart, lpEnd, wMatch);
1798}
1799
1800/**************************************************************************
1801 * StrRChrW [COMCTL32.359]
1802 *
1803 */
1804LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch) {
1805// return lstrrchrw(lpStart, lpEnd, wMatch);
1806}
1807
1808/**************************************************************************
1809 * StrStrA [COMCTL32.354]
1810 *
1811 */
1812LPSTR WINAPI COMCTL32_StrStrA( LPCSTR lpFirst, LPCSTR lpSrch) {
1813 return strstr(lpFirst, lpSrch);
1814}
1815
1816/**************************************************************************
1817 * StrStrW [COMCTL32.362]
1818 *
1819 */
1820LPWSTR WINAPI COMCTL32_StrStrW( LPCWSTR lpFirst, LPCWSTR lpSrch) {
1821// return strstrw(lpFirst, lpSrch);
1822}
1823
1824/**************************************************************************
1825 * StrSpnW [COMCTL32.364]
1826 *
1827 */
1828INT WINAPI COMCTL32_StrSpnW( LPWSTR lpStr, LPWSTR lpSet) {
1829 LPWSTR lpLoop = lpStr;
1830
1831 /* validate ptr */
1832 if ((lpStr == 0) || (lpSet == 0)) return 0;
1833
1834/* while(*lpLoop) { if lpLoop++; } */
1835
1836// for(; (*lpLoop != 0); lpLoop++)
1837// if( CRTDLL_wcschr(lpSet, *(WORD*)lpLoop))
1838// return (INT)(lpLoop-lpStr);
1839
1840// return (INT)(lpLoop-lpStr);
1841}
Note: See TracBrowser for help on using the repository browser.