source: trunk/src/comctl32/comctl32undoc.cpp@ 3585

Last change on this file since 3585 was 3585, checked in by cbratschi, 25 years ago

merged with Corel WINE 20000513, added new DPA_* functions

File size: 56.4 KB
Line 
1/* $Id: comctl32undoc.cpp,v 1.4 2000-05-22 17:25:07 cbratschi 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/*
15 - Corel 20000513 level
16 - (WINE 20000130 level)
17*/
18
19/* CB: todo
20 - porting/implementing string functions
21 - DPA_LoadStream
22 - DPA_SaveStream
23*/
24
25#include "comctl32.h"
26#include <memory.h>
27#include <string.h>
28#include <stdlib.h>
29#include <ctype.h>
30#include <wchar.h>
31#include <wcstr.h>
32#include <wctype.h>
33
34extern HANDLE COMCTL32_hHeap; /* handle to the private heap */
35
36/**************************************************************************
37 * DPA_Merge [COMCTL32.11]
38 *
39 * PARAMS
40 * hdpa1 [I] handle to a dynamic pointer array
41 * hdpa2 [I] handle to a dynamic pointer array
42 * dwFlags [I] flags
43 * pfnSort [I] pointer to sort function
44 * pfnMerge [I] pointer to merge function
45 * lParam [I] application specific value
46 *
47 * NOTES
48 * No more information available yet!
49 */
50
51BOOL WINAPI
52DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
53 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
54{
55 INT nCount;
56
57#if 0 /* these go with the "incomplete implementation" below */
58 LPVOID pWork1, pWork2;
59 INT nResult;
60 INT nIndex;
61 INT nNewItems;
62#endif
63
64
65 dprintf(("COMCTL32: DPA_Merge"));
66
67 if (IsBadWritePtr (hdpa1, sizeof(DPA)))
68 return FALSE;
69
70 if (IsBadWritePtr (hdpa2, sizeof(DPA)))
71 return FALSE;
72
73 if (IsBadCodePtr ((FARPROC)pfnCompare))
74 return FALSE;
75
76 if (IsBadCodePtr ((FARPROC)pfnMerge))
77 return FALSE;
78
79 if (dwFlags & DPAM_SORT) {
80// TRACE("sorting dpa's!\n");
81 if (hdpa1->nItemCount > 0)
82 DPA_Sort (hdpa1, pfnCompare, lParam);
83// TRACE ("dpa 1 sorted!\n");
84 if (hdpa2->nItemCount > 0)
85 DPA_Sort (hdpa2, pfnCompare, lParam);
86// TRACE ("dpa 2 sorted!\n");
87 }
88
89 if (hdpa2->nItemCount < 1)
90 return TRUE;
91
92// TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n",
93// hdpa1->nItemCount, hdpa2->nItemCount);
94
95
96 /* preliminary hack - simply append the pointer list hdpa2 to hdpa1*/
97 for (nCount = 0; nCount < hdpa2->nItemCount; nCount++)
98 DPA_InsertPtr (hdpa1, hdpa1->nItemCount + 1, hdpa2->ptrs[nCount]);
99
100#if 0
101 /* incomplete implementation */
102
103 pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]);
104 pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]);
105
106 nIndex = hdpa1->nItemCount - 1;
107 nCount = hdpa2->nItemCount - 1;
108
109 do
110 {
111 nResult = (pfnCompare)(pWork1, pWork2, lParam);
112
113 if (nResult == 0)
114 {
115 PVOID ptr;
116
117 ptr = (pfnMerge)(1, pWork1, pWork2, lParam);
118 if (!ptr)
119 return FALSE;
120
121 nCount--;
122 pWork2--;
123 pWork1 = ptr;
124 }
125 else if (nResult < 0)
126 {
127 if (!dwFlags & 8)
128 {
129 PVOID ptr;
130
131 ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
132
133 (pfnMerge)(2, ptr, NULL, lParam);
134 }
135 }
136 else
137 {
138 if (!dwFlags & 4)
139 {
140 PVOID ptr;
141
142 ptr = (pfnMerge)(3, pWork2, NULL, lParam);
143 if (!ptr)
144 return FALSE;
145 DPA_InsertPtr (hdpa1, nIndex, ptr);
146 }
147 nCount--;
148 pWork2--;
149 }
150
151 nIndex--;
152 pWork1--;
153
154 }
155 while (nCount >= 0);
156#endif
157
158 return TRUE;
159}
160
161
162/**************************************************************************
163 * Alloc [COMCTL32.71]
164 *
165 * Allocates memory block from the dll's private heap
166 *
167 * PARAMS
168 * dwSize [I] size of the allocated memory block
169 *
170 * RETURNS
171 * Success: pointer to allocated memory block
172 * Failure: NULL
173 */
174
175
176LPVOID WINAPI COMCTL32_Alloc (DWORD dwSize)
177{
178 LPVOID lpPtr;
179
180 dprintf2(("COMCTL32: COMCTL32_Alloc"));
181
182 lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
183
184 return lpPtr;
185}
186
187
188/**************************************************************************
189 * ReAlloc [COMCTL32.72]
190 *
191 * Changes the size of an allocated memory block or allocates a memory
192 * block using the dll's private heap.
193 *
194 * PARAMS
195 * lpSrc [I] pointer to memory block which will be resized
196 * dwSize [I] new size of the memory block.
197 *
198 * RETURNS
199 * Success: pointer to the resized memory block
200 * Failure: NULL
201 *
202 * NOTES
203 * If lpSrc is a NULL-pointer, then COMCTL32_ReAlloc allocates a memory
204 * block like COMCTL32_Alloc.
205 */
206
207LPVOID WINAPI COMCTL32_ReAlloc (LPVOID lpSrc, DWORD dwSize)
208{
209 LPVOID lpDest;
210
211 dprintf2(("COMCTL32: COMCTL32_ReAlloc"));
212
213 if (lpSrc)
214 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
215 else
216 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
217
218 return lpDest;
219}
220
221
222/**************************************************************************
223 * Free [COMCTL32.73]
224 *
225 * Frees an allocated memory block from the dll's private heap.
226 *
227 * PARAMS
228 * lpMem [I] pointer to memory block which will be freed
229 *
230 * RETURNS
231 * Success: TRUE
232 * Failure: FALSE
233 */
234
235BOOL WINAPI COMCTL32_Free (LPVOID lpMem)
236{
237 dprintf2(("COMCTL32: COMCTL32_Free"));
238
239 return HeapFree (COMCTL32_hHeap, 0, lpMem);
240}
241
242
243/**************************************************************************
244 * GetSize [COMCTL32.74]
245 *
246 * Retrieves the size of the specified memory block from the dll's
247 * private heap.
248 *
249 * PARAMS
250 * lpMem [I] pointer to an allocated memory block
251 *
252 * RETURNS
253 * Success: size of the specified memory block
254 * Failure: 0
255 */
256
257DWORD WINAPI COMCTL32_GetSize (LPVOID lpMem)
258{
259 dprintf2(("COMCTL32: COMCTL32_GetSize"));
260
261 return HeapSize (COMCTL32_hHeap, 0, lpMem);
262}
263
264
265/**************************************************************************
266 * The MRU-API is a set of functions to manipulate MRU(Most Recently Used)
267 * lists.
268 *
269 * Stored in the reg. as a set of values under a single key. Each item in the
270 * list has a value name that is a single char. 'a' - 'z', '{', '|' or '}'.
271 * The order of the list is stored with value name 'MRUList' which is a string
272 * containing the value names (i.e. 'a', 'b', etc.) in the relevant order.
273 */
274
275typedef struct tagCREATEMRULIST
276{
277 DWORD cbSize; /* size of struct */
278 DWORD nMaxItems; /* max no. of items in list */
279 DWORD dwFlags; /* see below */
280 HKEY hKey; /* root reg. key under which list is saved */
281 LPCSTR lpszSubKey; /* reg. subkey */
282 PROC lpfnCompare; /* item compare proc */
283} CREATEMRULIST, *LPCREATEMRULIST;
284
285/* dwFlags */
286#define MRUF_STRING_LIST 0 /* list will contain strings */
287#define MRUF_BINARY_LIST 1 /* list will contain binary data */
288#define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
289
290/* If list is a string list lpfnCompare has the following prototype
291 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
292 * for binary lists the prototype is
293 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
294 * where cbData is the no. of bytes to compare.
295 * Need to check what return value means identical - 0?
296 */
297
298typedef struct tagMRU
299{
300 DWORD dwParam1; /* some kind of flag */
301 DWORD dwParam2;
302 DWORD dwParam3;
303 HKEY hkeyMRU;
304 LPCSTR lpszSubKey;
305 DWORD dwParam6;
306} MRU, *HMRU;
307
308HANDLE WINAPI
309CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
310 DWORD dwParam3, DWORD dwParam4);
311
312
313/**************************************************************************
314 * CreateMRUListA [COMCTL32.151]
315 *
316 * PARAMS
317 * lpcml [I] ptr to CREATEMRULIST structure.
318 *
319 * RETURNS
320 * Handle to MRU list.
321 */
322HANDLE WINAPI
323CreateMRUListA (LPCREATEMRULIST lpcml)
324{
325 dprintf(("COMCTL32: CreateMRUListA"));
326
327 return CreateMRUListLazyA (lpcml, 0, 0, 0);
328}
329
330/**************************************************************************
331 * FreeMRUListA [COMCTL32.152]
332 *
333 * PARAMS
334 * hMRUList [I] Handle to list.
335 *
336 */
337DWORD WINAPI
338FreeMRUListA (HANDLE hMRUList)
339{
340 dprintf(("COMCTL32: FreeMRUListA"));
341 //FIXME("(%08x) empty stub!\n", hMRUList);
342
343#if 0
344 if (!(hmru->dwParam1 & 1001)) {
345 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
346 hmru->lpszMRUString,
347 lstrlenA (hmru->lpszMRUString));
348 }
349
350
351 RegClosKey (hmru->hkeyMRU
352 COMCTL32_Free32 (hmru->lpszMRUString);
353#endif
354
355 return COMCTL32_Free ((LPVOID)hMRUList);
356}
357
358
359/**************************************************************************
360 * AddMRUData [COMCTL32.167]
361 *
362 * Add item to MRU binary list. If item already exists in list them it is
363 * simply moved up to the top of the list and not added again. If list is
364 * full then the least recently used item is removed to make room.
365 *
366 * PARAMS
367 * hList [I] Handle to list.
368 * lpData [I] ptr to data to add.
369 * cbData [I] no. of bytes of data.
370 *
371 * RETURNS
372 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
373 * -1 on error.
374 */
375INT WINAPI
376AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData)
377{
378 dprintf(("COMCTL32: AddMRUData - empty stub!"));
379
380 return 0;
381}
382
383/**************************************************************************
384 * AddMRUStringA [COMCTL32.153]
385 *
386 * Add item to MRU string list. If item already exists in list them it is
387 * simply moved up to the top of the list and not added again. If list is
388 * full then the least recently used item is removed to make room.
389 *
390 * PARAMS
391 * hList [I] Handle to list.
392 * lpszString [I] ptr to string to add.
393 *
394 * RETURNS
395 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
396 * -1 on error.
397 */
398INT WINAPI
399AddMRUStringA(HANDLE hList, LPCSTR lpszString)
400{
401 dprintf(("COMCTL32: AddMRUStringA - empty stub!"));
402
403 return 0;
404}
405
406/**************************************************************************
407 * DelMRUString [COMCTL32.156]
408 *
409 * Removes item from either string or binary list (despite its name)
410 *
411 * PARAMS
412 * hList [I] list handle
413 * nItemPos [I] item position to remove 0 -> MRU
414 *
415 * RETURNS
416 * TRUE is successful, FALSE if nItemPos is out of range.
417 */
418BOOL WINAPI
419DelMRUString(HANDLE hList, INT nItemPos)
420{
421 dprintf(("COMCTL32: DelMRUString - empty stub!"));
422
423 return TRUE;
424}
425
426/**************************************************************************
427 * FindMRUData [COMCTL32.169]
428 *
429 * Searches binary list for item that matches lpData of length cbData.
430 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
431 * corresponding to item's reg. name will be stored in it ('a' -> 0).
432 *
433 * PARAMS
434 * hList [I] list handle
435 * lpData [I] data to find
436 * cbData [I] length of data
437 * lpRegNum [O] position in registry (maybe NULL)
438 *
439 * RETURNS
440 * Position in list 0 -> MRU. -1 if item not found.
441 */
442INT WINAPI
443FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum)
444{
445 dprintf(("COMCTL32: FindMRUData - empty stub!"));
446
447 return 0;
448}
449
450/**************************************************************************
451 * FindMRUStringA [COMCTL32.155]
452 *
453 * Searches string list for item that matches lpszString.
454 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
455 * corresponding to item's reg. name will be stored in it ('a' -> 0).
456 *
457 * PARAMS
458 * hList [I] list handle
459 * lpszString [I] string to find
460 * lpRegNum [O] position in registry (maybe NULL)
461 *
462 * RETURNS
463 * Position in list 0 -> MRU. -1 if item not found.
464 */
465INT WINAPI
466FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum)
467{
468 dprintf(("COMCTL32: FindMRUStringA - empty stub!"));
469
470 return 0;
471}
472
473HANDLE WINAPI
474CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
475{
476 /* DWORD dwLocal1; *
477 * HKEY hkeyResult; *
478 * DWORD dwLocal3; *
479 * LPVOID lMRU; *
480 * DWORD dwLocal5; *
481 * DWORD dwLocal6; *
482 * DWORD dwLocal7; *
483 * DWORD dwDisposition; */
484
485 /* internal variables */
486 LPVOID ptr;
487
488 dprintf(("COMCTL32: CreateMRUListLazyA - empty stub!"));
489
490 if (lpcml == NULL)
491 return 0;
492
493 if (lpcml->cbSize < sizeof(CREATEMRULIST))
494 return 0;
495
496 //FIXME("(%lu %lu %lx %lx \"%s\" %p)\n",
497 // lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
498 // (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
499
500 /* dummy pointer creation */
501 ptr = COMCTL32_Alloc (32);
502
503 //FIXME("-- ret = %p\n", ptr);
504
505 return (HANDLE)ptr;
506}
507
508/**************************************************************************
509 * EnumMRUListA [COMCTL32.154]
510 *
511 * Enumerate item in a list
512 *
513 * PARAMS
514 * hList [I] list handle
515 * nItemPos [I] item position to enumerate
516 * lpBuffer [O] buffer to receive item
517 * nBufferSize [I] size of buffer
518 *
519 * RETURNS
520 * For binary lists specifies how many bytes were copied to buffer, for
521 * string lists specifies full length of string. Enumerating past the end
522 * of list returns -1.
523 * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
524 * the list.
525 */
526INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
527DWORD nBufferSize)
528{
529 dprintf(("COMCTL32: EnumMRUListA - empty stub!"));
530
531 return 0;
532}
533
534
535
536/**************************************************************************
537 * Str_GetPtrA [COMCTL32.233]
538 *
539 * PARAMS
540 * lpSrc [I]
541 * lpDest [O]
542 * nMaxLen [I]
543 *
544 * RETURNS
545 */
546
547INT WINAPI
548Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen)
549{
550 INT len;
551
552 dprintf(("COMCTL32: Str_GetPtrA"));
553
554 if (!lpDest && lpSrc)
555 return lstrlenA (lpSrc);
556
557 if (nMaxLen == 0)
558 return 0;
559
560 if (lpSrc == NULL) {
561 lpDest[0] = '\0';
562 return 0;
563 }
564
565 len = lstrlenA (lpSrc);
566 if (len >= nMaxLen)
567 len = nMaxLen - 1;
568
569 RtlMoveMemory (lpDest, lpSrc, len);
570 lpDest[len] = '\0';
571
572 return len;
573}
574
575
576/**************************************************************************
577 * Str_SetPtrA [COMCTL32.234]
578 *
579 * PARAMS
580 * lppDest [O]
581 * lpSrc [I]
582 *
583 * RETURNS
584 */
585
586BOOL WINAPI
587Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc)
588{
589 dprintf(("COMCTL32: Str_SetPtrA"));
590
591 if (lpSrc) {
592 LPSTR ptr = (LPSTR)COMCTL32_ReAlloc (*lppDest, lstrlenA (lpSrc) + 1);
593 if (!ptr)
594 return FALSE;
595 lstrcpyA (ptr, lpSrc);
596 *lppDest = ptr;
597 }
598 else {
599 if (*lppDest) {
600 COMCTL32_Free (*lppDest);
601 *lppDest = NULL;
602 }
603 }
604
605 return TRUE;
606}
607
608
609/**************************************************************************
610 * Str_GetPtrW [COMCTL32.235]
611 *
612 * PARAMS
613 * lpSrc [I]
614 * lpDest [O]
615 * nMaxLen [I]
616 *
617 * RETURNS
618 */
619
620INT WINAPI
621Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
622{
623 INT len;
624
625 dprintf(("COMCTL32: Str_GetPtrW"));
626
627 if (!lpDest && lpSrc)
628 return lstrlenW (lpSrc);
629
630 if (nMaxLen == 0)
631 return 0;
632
633 if (lpSrc == NULL) {
634 lpDest[0] = L'\0';
635 return 0;
636 }
637
638 len = lstrlenW (lpSrc);
639 if (len >= nMaxLen)
640 len = nMaxLen - 1;
641
642 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
643 lpDest[len] = L'\0';
644
645 return len;
646}
647
648
649/**************************************************************************
650 * Str_SetPtrW [COMCTL32.236]
651 *
652 * PARAMS
653 * lpDest [O]
654 * lpSrc [I]
655 *
656 * RETURNS
657 */
658
659BOOL WINAPI
660Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc)
661{
662 dprintf(("COMCTL32: Str_SetPtrW"));
663
664 if (lpSrc) {
665 INT len = lstrlenW (lpSrc) + 1;
666 LPWSTR ptr = (LPWSTR)COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
667 if (!ptr)
668 return FALSE;
669 lstrcpyW (ptr, lpSrc);
670 *lppDest = ptr;
671 }
672 else {
673 if (*lppDest) {
674 COMCTL32_Free (*lppDest);
675 *lppDest = NULL;
676 }
677 }
678
679 return TRUE;
680}
681
682
683/**************************************************************************
684 * The DSA-API is a set of functions to create and manipulate arrays of
685 * fix sized memory blocks. These arrays can store any kind of data
686 * (strings, icons...).
687 */
688
689/**************************************************************************
690 * DSA_Create [COMCTL32.320] Creates a dynamic storage array
691 *
692 * PARAMS
693 * nSize [I] size of the array elements
694 * nGrow [I] number of elements by which the array grows when it is filled
695 *
696 * RETURNS
697 * Success: pointer to a array control structure. use this like a handle.
698 * Failure: NULL
699 */
700
701HDSA WINAPI
702DSA_Create (INT nSize, INT nGrow)
703{
704 HDSA hdsa;
705
706 dprintf(("COMCTL32: DSA_Create"));
707
708 hdsa = (HDSA)COMCTL32_Alloc (sizeof(DSA));
709 if (hdsa)
710 {
711 hdsa->nItemCount = 0;
712 hdsa->pData = NULL;
713 hdsa->nMaxCount = 0;
714 hdsa->nItemSize = nSize;
715 hdsa->nGrow = MAX(1, nGrow);
716 }
717
718 return hdsa;
719}
720
721
722/**************************************************************************
723 * DSA_Destroy [COMCTL32.321] Destroys a dynamic storage array
724 *
725 * PARAMS
726 * hdsa [I] pointer to the array control structure
727 *
728 * RETURNS
729 * Success: TRUE
730 * Failure: FALSE
731 */
732
733BOOL WINAPI
734DSA_Destroy (const HDSA hdsa)
735{
736 dprintf(("COMCTL32: DSA_Destroy"));
737
738 if (!hdsa)
739 return FALSE;
740
741 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
742 return FALSE;
743
744 return COMCTL32_Free (hdsa);
745}
746
747
748/**************************************************************************
749 * DSA_GetItem [COMCTL32.322]
750 *
751 * PARAMS
752 * hdsa [I] pointer to the array control structure
753 * nIndex [I] number of the Item to get
754 * pDest [O] destination buffer. Has to be >= dwElementSize.
755 *
756 * RETURNS
757 * Success: TRUE
758 * Failure: FALSE
759 */
760
761BOOL WINAPI
762DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest)
763{
764 LPVOID pSrc;
765
766 dprintf2(("COMCTL32: DSA_GetItem"));
767
768 if (!hdsa)
769 return FALSE;
770 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
771 return FALSE;
772
773 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
774 memmove (pDest, pSrc, hdsa->nItemSize);
775
776 return TRUE;
777}
778
779
780/**************************************************************************
781 * DSA_GetItemPtr [COMCTL32.323]
782 *
783 * Retrieves a pointer to the specified item.
784 *
785 * PARAMS
786 * hdsa [I] pointer to the array control structure
787 * nIndex [I] index of the desired item
788 *
789 * RETURNS
790 * Success: pointer to an item
791 * Failure: NULL
792 */
793
794LPVOID WINAPI
795DSA_GetItemPtr (const HDSA hdsa, INT nIndex)
796{
797 LPVOID pSrc;
798
799 dprintf2(("COMCTL32: DSA_GetItemPtr"));
800
801 if (!hdsa)
802 return NULL;
803 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
804 return NULL;
805
806 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
807
808// TRACE (commctrl, "-- ret=%p\n", pSrc);
809
810 return pSrc;
811}
812
813
814/**************************************************************************
815 * DSA_SetItem [COMCTL32.325]
816 *
817 * Sets the contents of an item in the array.
818 *
819 * PARAMS
820 * hdsa [I] pointer to the array control structure
821 * nIndex [I] index for the item
822 * pSrc [I] pointer to the new item data
823 *
824 * RETURNS
825 * Success: TRUE
826 * Failure: FALSE
827 */
828
829BOOL WINAPI
830DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
831{
832 INT nSize, nNewItems;
833 LPVOID pDest, lpTemp;
834
835 dprintf2(("COMCTL32: DSA_SetItem"));
836
837 if ((!hdsa) || nIndex < 0)
838 return FALSE;
839
840 if (hdsa->nItemCount <= nIndex) {
841 /* within the old array */
842 if (hdsa->nMaxCount > nIndex) {
843 /* within the allocated space, set a new boundary */
844 hdsa->nItemCount = nIndex + 1;
845 }
846 else {
847 /* resize the block of memory */
848 nNewItems =
849 hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
850 nSize = hdsa->nItemSize * nNewItems;
851
852 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
853 if (!lpTemp)
854 return FALSE;
855
856 hdsa->nMaxCount = nNewItems;
857 hdsa->nItemCount = nIndex + 1;
858 hdsa->pData = lpTemp;
859 }
860 }
861
862 /* put the new entry in */
863 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
864// TRACE("-- move dest=%p src=%p size=%d\n",
865// pDest, pSrc, hdsa->nItemSize);
866 memmove (pDest, pSrc, hdsa->nItemSize);
867
868 return TRUE;
869}
870
871
872/**************************************************************************
873 * DSA_InsertItem [COMCTL32.325]
874 *
875 * PARAMS
876 * hdsa [I] pointer to the array control structure
877 * nIndex [I] index for the new item
878 * pSrc [I] pointer to the element
879 *
880 * RETURNS
881 * Success: position of the new item
882 * Failure: -1
883 */
884
885INT WINAPI
886DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
887{
888 INT nNewItems, nSize, i;
889 LPVOID lpTemp, lpDest;
890 LPDWORD p;
891
892 dprintf2(("COMCTL32: DSA_InsertItem"));
893
894 if ((!hdsa) || nIndex < 0)
895 return -1;
896
897 for (i = 0; i < hdsa->nItemSize; i += 4) {
898 p = *(DWORD**)((char *) pSrc + i);
899// if (IsBadStringPtrA ((char*)p, 256))
900// TRACE("-- %d=%p\n", i, (DWORD*)p);
901// else
902// TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
903 }
904
905 /* when nIndex > nItemCount then append */
906 if (nIndex >= hdsa->nItemCount)
907 nIndex = hdsa->nItemCount;
908
909 /* do we need to resize ? */
910 if (hdsa->nItemCount >= hdsa->nMaxCount) {
911 nNewItems = hdsa->nMaxCount + hdsa->nGrow;
912 nSize = hdsa->nItemSize * nNewItems;
913
914 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
915 if (!lpTemp)
916 return -1;
917
918 hdsa->nMaxCount = nNewItems;
919 hdsa->pData = lpTemp;
920 }
921
922 /* do we need to move elements ? */
923 if (nIndex < hdsa->nItemCount) {
924 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
925 lpDest = (char *) lpTemp + hdsa->nItemSize;
926 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
927// TRACE("-- move dest=%p src=%p size=%d\n",
928// lpDest, lpTemp, nSize);
929 memmove (lpDest, lpTemp, nSize);
930 }
931
932 /* ok, we can put the new Item in */
933 hdsa->nItemCount++;
934 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
935// TRACE("-- move dest=%p src=%p size=%d\n",
936// lpDest, pSrc, hdsa->nItemSize);
937 memmove (lpDest, pSrc, hdsa->nItemSize);
938
939 return hdsa->nItemCount;
940}
941
942
943/**************************************************************************
944 * DSA_DeleteItem [COMCTL32.326]
945 *
946 * PARAMS
947 * hdsa [I] pointer to the array control structure
948 * nIndex [I] index for the element to delete
949 *
950 * RETURNS
951 * Success: number of the deleted element
952 * Failure: -1
953 */
954
955INT WINAPI
956DSA_DeleteItem (const HDSA hdsa, INT nIndex)
957{
958 LPVOID lpDest,lpSrc;
959 INT nSize;
960
961 dprintf2(("COMCTL32: DSA_DeleteItem"));
962
963 if (!hdsa)
964 return -1;
965 if (nIndex < 0 || nIndex >= hdsa->nItemCount)
966 return -1;
967
968 /* do we need to move ? */
969 if (nIndex < hdsa->nItemCount - 1) {
970 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
971 lpSrc = (char *) lpDest + hdsa->nItemSize;
972 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
973// TRACE (commctrl, "-- move dest=%p src=%p size=%d\n",
974// lpDest, lpSrc, nSize);
975 memmove (lpDest, lpSrc, nSize);
976 }
977
978 hdsa->nItemCount--;
979
980 /* free memory ? */
981 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
982 nSize = MAX(2*hdsa->nGrow,hdsa->nItemSize)*hdsa->nItemCount;
983
984 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
985 if (!lpDest)
986 return -1;
987
988 hdsa->nMaxCount = hdsa->nItemCount;
989 hdsa->pData = lpDest;
990 }
991
992 return nIndex;
993}
994
995
996/**************************************************************************
997 * DSA_DeleteAllItems [COMCTL32.326]
998 *
999 * Removes all items and reinitializes the array.
1000 *
1001 * PARAMS
1002 * hdsa [I] pointer to the array control structure
1003 *
1004 * RETURNS
1005 * Success: TRUE
1006 * Failure: FALSE
1007 */
1008
1009BOOL WINAPI
1010DSA_DeleteAllItems (const HDSA hdsa)
1011{
1012 dprintf(("COMCTL32: DSA_DeleteAllItems"));
1013
1014 if (!hdsa)
1015 return FALSE;
1016 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
1017 return FALSE;
1018
1019 hdsa->nItemCount = 0;
1020 hdsa->pData = NULL;
1021 hdsa->nMaxCount = 0;
1022
1023 return TRUE;
1024}
1025
1026
1027/**************************************************************************
1028 * The DPA-API is a set of functions to create and manipulate arrays of
1029 * pointers.
1030 */
1031
1032/**************************************************************************
1033 * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
1034 *
1035 * PARAMS
1036 * nGrow [I] number of items by which the array grows when it is filled
1037 *
1038 * RETURNS
1039 * Success: handle (pointer) to the pointer array.
1040 * Failure: NULL
1041 */
1042
1043HDPA WINAPI
1044DPA_Create (INT nGrow)
1045{
1046 HDPA hdpa;
1047
1048 dprintf2(("COMCTL32: DPA_Create"));
1049
1050 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1051 if (hdpa) {
1052 hdpa->nGrow = MAX(8, nGrow);
1053 hdpa->hHeap = COMCTL32_hHeap;
1054 hdpa->nMaxCount = hdpa->nGrow * 2;
1055 hdpa->ptrs =
1056 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
1057 }
1058
1059// TRACE (commctrl, "-- %p\n", hdpa);
1060
1061 return hdpa;
1062}
1063
1064
1065/**************************************************************************
1066 * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
1067 *
1068 * PARAMS
1069 * hdpa [I] handle (pointer) to the pointer array
1070 *
1071 * RETURNS
1072 * Success: TRUE
1073 * Failure: FALSE
1074 */
1075
1076BOOL WINAPI
1077DPA_Destroy (const HDPA hdpa)
1078{
1079 dprintf2(("COMCTL32: DPA_Destroy"));
1080
1081 if (!hdpa)
1082 return FALSE;
1083
1084 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1085 return FALSE;
1086
1087 return HeapFree (hdpa->hHeap, 0, hdpa);
1088}
1089
1090
1091/**************************************************************************
1092 * DPA_Grow [COMCTL32.330]
1093 *
1094 * Sets the growth amount.
1095 *
1096 * PARAMS
1097 * hdpa [I] handle (pointer) to the existing (source) pointer array
1098 * nGrow [I] number of items, the array grows, when it's too small
1099 *
1100 * RETURNS
1101 * Success: TRUE
1102 * Failure: FALSE
1103 */
1104
1105BOOL WINAPI
1106DPA_Grow (const HDPA hdpa, INT nGrow)
1107{
1108 dprintf2(("COMCTL32: DPA_Grow"));
1109
1110 if (!hdpa)
1111 return FALSE;
1112
1113 hdpa->nGrow = MAX(8, nGrow);
1114
1115 return TRUE;
1116}
1117
1118
1119/**************************************************************************
1120 * DPA_Clone [COMCTL32.331]
1121 *
1122 * Copies a pointer array to an other one or creates a copy
1123 *
1124 * PARAMS
1125 * hdpa [I] handle (pointer) to the existing (source) pointer array
1126 * hdpaNew [O] handle (pointer) to the destination pointer array
1127 *
1128 * RETURNS
1129 * Success: pointer to the destination pointer array.
1130 * Failure: NULL
1131 *
1132 * NOTES
1133 * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer
1134 * array will be created and it's handle (pointer) is returned.
1135 * - If 'hdpa' is a NULL-Pointer, the original implementation crashes,
1136 * this implementation just returns NULL.
1137 */
1138
1139HDPA WINAPI
1140DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
1141{
1142 INT nNewItems, nSize;
1143 HDPA hdpaTemp;
1144
1145 dprintf2(("COMCTL32: DPA_Clone"));
1146
1147 if (!hdpa)
1148 return NULL;
1149
1150 if (!hdpaNew) {
1151 /* create a new DPA */
1152 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1153 sizeof(DPA));
1154 hdpaTemp->hHeap = hdpa->hHeap;
1155 hdpaTemp->nGrow = hdpa->nGrow;
1156 }
1157 else
1158 hdpaTemp = hdpaNew;
1159
1160 if (hdpaTemp->ptrs) {
1161 /* remove old pointer array */
1162 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
1163 hdpaTemp->ptrs = NULL;
1164 hdpaTemp->nItemCount = 0;
1165 hdpaTemp->nMaxCount = 0;
1166 }
1167
1168 /* create a new pointer array */
1169 nNewItems = hdpaTemp->nGrow *
1170 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
1171 nSize = nNewItems * sizeof(LPVOID);
1172 hdpaTemp->ptrs =
1173 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
1174 hdpaTemp->nMaxCount = nNewItems;
1175
1176 /* clone the pointer array */
1177 hdpaTemp->nItemCount = hdpa->nItemCount;
1178 memmove (hdpaTemp->ptrs, hdpa->ptrs,
1179 hdpaTemp->nItemCount * sizeof(LPVOID));
1180
1181 return hdpaTemp;
1182}
1183
1184
1185/**************************************************************************
1186 * DPA_GetPtr [COMCTL32.332]
1187 *
1188 * Retrieves a pointer from a dynamic pointer array
1189 *
1190 * PARAMS
1191 * hdpa [I] handle (pointer) to the pointer array
1192 * nIndex [I] array index of the desired pointer
1193 *
1194 * RETURNS
1195 * Success: pointer
1196 * Failure: NULL
1197 */
1198
1199LPVOID WINAPI
1200DPA_GetPtr (const HDPA hdpa, INT i)
1201{
1202 dprintf2(("COMCTL32: DPA_GetPtr"));
1203
1204 if (!hdpa)
1205 return NULL;
1206 if (!hdpa->ptrs)
1207 return NULL;
1208 if ((i < 0) || (i >= hdpa->nItemCount))
1209 return NULL;
1210
1211// TRACE (commctrl, "-- %p\n", hdpa->ptrs[i]);
1212
1213 return hdpa->ptrs[i];
1214}
1215
1216
1217/**************************************************************************
1218 * DPA_GetPtrIndex [COMCTL32.333]
1219 *
1220 * Retrieves the index of the specified pointer
1221 *
1222 * PARAMS
1223 * hdpa [I] handle (pointer) to the pointer array
1224 * p [I] pointer
1225 *
1226 * RETURNS
1227 * Success: index of the specified pointer
1228 * Failure: -1
1229 */
1230
1231INT WINAPI
1232DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
1233{
1234 INT i;
1235
1236 dprintf2(("COMCTL32: DPA_GetPtrIndex"));
1237
1238 if (!hdpa->ptrs)
1239 return -1;
1240
1241 for (i = 0; i < hdpa->nItemCount; i++) {
1242 if (hdpa->ptrs[i] == p)
1243 return i;
1244 }
1245
1246 return -1;
1247}
1248
1249
1250/**************************************************************************
1251 * DPA_InsertPtr [COMCTL32.334]
1252 *
1253 * Inserts a pointer into a dynamic pointer array
1254 *
1255 * PARAMS
1256 * hdpa [I] handle (pointer) to the array
1257 * i [I] array index
1258 * p [I] pointer to insert
1259 *
1260 * RETURNS
1261 * Success: index of the inserted pointer
1262 * Failure: -1
1263 */
1264
1265INT WINAPI
1266DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
1267{
1268 INT nNewItems, nSize, nIndex = 0;
1269 LPVOID *lpTemp, *lpDest;
1270
1271 dprintf2(("COMCTL32: DPA_InsertPtr"));
1272
1273 if ((!hdpa) || (i < 0))
1274 return -1;
1275
1276 if (!hdpa->ptrs) {
1277 hdpa->ptrs =
1278 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1279 hdpa->nGrow * sizeof(LPVOID));
1280 if (!hdpa->ptrs)
1281 return -1;
1282 hdpa->nMaxCount = hdpa->nGrow;
1283 nIndex = 0;
1284 }
1285 else {
1286 if (hdpa->nItemCount == hdpa->nMaxCount) {
1287// TRACE (commctrl, "-- resizing\n");
1288 nNewItems = hdpa->nMaxCount + hdpa->nGrow;
1289 nSize = nNewItems * sizeof(LPVOID);
1290
1291 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1292 hdpa->ptrs, nSize);
1293 if (!lpTemp)
1294 return -1;
1295 hdpa->nMaxCount = nNewItems;
1296 hdpa->ptrs = lpTemp;
1297 }
1298
1299 if (i >= hdpa->nItemCount) {
1300 nIndex = hdpa->nItemCount;
1301// TRACE (commctrl, "-- appending at %d\n", nIndex);
1302 }
1303 else {
1304// TRACE (commctrl, "-- inserting at %d\n", i);
1305 lpTemp = hdpa->ptrs + i;
1306 lpDest = lpTemp + 1;
1307 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID);
1308// TRACE (commctrl, "-- move dest=%p src=%p size=%x\n",
1309// lpDest, lpTemp, nSize);
1310 memmove (lpDest, lpTemp, nSize);
1311 nIndex = i;
1312 }
1313 }
1314
1315 /* insert item */
1316 hdpa->nItemCount++;
1317 hdpa->ptrs[nIndex] = p;
1318
1319 return nIndex;
1320}
1321
1322
1323/**************************************************************************
1324 * DPA_SetPtr [COMCTL32.335]
1325 *
1326 * Sets a pointer in the pointer array
1327 *
1328 * PARAMS
1329 * hdpa [I] handle (pointer) to the pointer array
1330 * i [I] index of the pointer that will be set
1331 * p [I] pointer to be set
1332 *
1333 * RETURNS
1334 * Success: TRUE
1335 * Failure: FALSE
1336 */
1337
1338BOOL WINAPI
1339DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
1340{
1341 LPVOID *lpTemp;
1342
1343 dprintf2(("COMCTL32: DPA_SetPtr"));
1344
1345 if ((!hdpa) || i < 0)
1346 return FALSE;
1347
1348 if (hdpa->nItemCount <= i) {
1349 /* within the old array */
1350 if (hdpa->nMaxCount > i) {
1351 /* within the allocated space, set a new boundary */
1352 hdpa->nItemCount = i+1;
1353 }
1354 else {
1355 /* resize the block of memory */
1356 INT nNewItems =
1357 hdpa->nGrow * (((i+1) / hdpa->nGrow) + 1);
1358 INT nSize = nNewItems * sizeof(LPVOID);
1359
1360 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1361 hdpa->ptrs, nSize);
1362 if (!lpTemp)
1363 return FALSE;
1364
1365 hdpa->nItemCount = nNewItems;
1366 hdpa->ptrs = lpTemp;
1367 }
1368 }
1369
1370 /* put the new entry in */
1371 hdpa->ptrs[i] = p;
1372
1373 return TRUE;
1374}
1375
1376
1377/**************************************************************************
1378 * DPA_DeletePtr [COMCTL32.336]
1379 *
1380 * Removes a pointer from the pointer array.
1381 *
1382 * PARAMS
1383 * hdpa [I] handle (pointer) to the pointer array
1384 * i [I] index of the pointer that will be deleted
1385 *
1386 * RETURNS
1387 * Success: deleted pointer
1388 * Failure: NULL
1389 */
1390
1391LPVOID WINAPI
1392DPA_DeletePtr (const HDPA hdpa, INT i)
1393{
1394 LPVOID *lpDest, *lpSrc, lpTemp = NULL;
1395 INT nSize;
1396
1397 dprintf2(("COMCTL32: DPA_DeletePtr"));
1398
1399 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
1400 return NULL;
1401
1402 lpTemp = hdpa->ptrs[i];
1403
1404 /* do we need to move ?*/
1405 if (i < hdpa->nItemCount - 1) {
1406 lpDest = hdpa->ptrs + i;
1407 lpSrc = lpDest + 1;
1408 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
1409// TRACE (commctrl,"-- move dest=%p src=%p size=%x\n",
1410// lpDest, lpSrc, nSize);
1411 memmove (lpDest, lpSrc, nSize);
1412 }
1413
1414 hdpa->nItemCount --;
1415 hdpa->ptrs[hdpa->nItemCount] = NULL;
1416
1417 /* free memory ?*/
1418 if ((hdpa->nMaxCount - hdpa->nItemCount) > hdpa->nGrow) {
1419 INT nNewItems = hdpa->nMaxCount - hdpa->nGrow;
1420
1421 nSize = nNewItems * sizeof(LPVOID);
1422 lpDest = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1423 hdpa->ptrs, nSize);
1424 if (!lpDest)
1425 return NULL;
1426
1427 hdpa->nMaxCount = nNewItems;
1428 hdpa->ptrs = (LPVOID*)lpDest;
1429 }
1430
1431 return lpTemp;
1432}
1433
1434
1435/**************************************************************************
1436 * DPA_DeleteAllPtrs [COMCTL32.337]
1437 *
1438 * Removes all pointers and reinitializes the array.
1439 *
1440 * PARAMS
1441 * hdpa [I] handle (pointer) to the pointer array
1442 *
1443 * RETURNS
1444 * Success: TRUE
1445 * Failure: FALSE
1446 */
1447
1448BOOL WINAPI
1449DPA_DeleteAllPtrs (const HDPA hdpa)
1450{
1451 dprintf2(("COMCTL32: DPA_DeleteAllPtrs"));
1452
1453 if (!hdpa)
1454 return FALSE;
1455
1456 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1457 return FALSE;
1458
1459 hdpa->nItemCount = 0;
1460 hdpa->nMaxCount = hdpa->nGrow * 2;
1461 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1462 hdpa->nMaxCount * sizeof(LPVOID));
1463
1464 return TRUE;
1465}
1466
1467
1468/**************************************************************************
1469 * DPA_QuickSort [Internal]
1470 *
1471 * Ordinary quicksort (used by DPA_Sort).
1472 *
1473 * PARAMS
1474 * lpPtrs [I] pointer to the pointer array
1475 * l [I] index of the "left border" of the partition
1476 * r [I] index of the "right border" of the partition
1477 * pfnCompare [I] pointer to the compare function
1478 * lParam [I] user defined value (3rd parameter in compare function)
1479 *
1480 * RETURNS
1481 * NONE
1482 *
1483 * NOTES:
1484 * Reverted back to the orginal quick sort, because the existing sort did not sort.
1485 * Kudos to the orginal author of the quick sort.
1486 */
1487
1488static VOID
1489DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
1490 PFNDPACOMPARE pfnCompare, LPARAM lParam)
1491{
1492 LPVOID t, v;
1493 INT i, j;
1494
1495 //TRACE("l=%i r=%i\n", l, r);
1496
1497 i = l;
1498 j = r;
1499 v = lpPtrs[(int)(l+r)/2];
1500 do {
1501 while ((pfnCompare)(lpPtrs[i], v, lParam) < 0) i++;
1502 while ((pfnCompare)(lpPtrs[j], v, lParam) > 0) j--;
1503 if (i <= j)
1504 {
1505 t = lpPtrs[i];
1506 lpPtrs[i++] = lpPtrs[j];
1507 lpPtrs[j--] = t;
1508 }
1509 } while (i <= j);
1510 if (l < j) DPA_QuickSort (lpPtrs, l, j, pfnCompare, lParam);
1511 if (i < r) DPA_QuickSort (lpPtrs, i, r, pfnCompare, lParam);
1512}
1513
1514//internal API
1515INT DPA_InsertPtrSorted(const HDPA hdpa,LPVOID p,PFNDPACOMPARE pfnCompare,LPARAM lParam)
1516{
1517 INT pos,minPos,maxPos,res;
1518
1519 if (!hdpa || !pfnCompare) return -1;
1520
1521 if (hdpa->nItemCount == 0)
1522 return DPA_InsertPtr(hdpa,0,p);
1523
1524 //check last
1525 if ((pfnCompare)(p,hdpa->ptrs[hdpa->nItemCount-1],lParam) >= 0)
1526 {
1527 return DPA_InsertPtr(hdpa,hdpa->nItemCount,p);
1528 }
1529 //check first
1530 if ((pfnCompare)(p,hdpa->ptrs[0],lParam) < 0)
1531 {
1532 return DPA_InsertPtr(hdpa,0,p);
1533 }
1534
1535 minPos = 1;
1536 maxPos = hdpa->nItemCount-1;
1537
1538 while (minPos != maxPos)
1539 {
1540 pos = (minPos+maxPos)/2;
1541 res = (pfnCompare)(p,hdpa->ptrs[pos],lParam);
1542 if (res < 0)
1543 maxPos = pos;
1544 else
1545 minPos = pos+1;
1546 }
1547
1548 return DPA_InsertPtr(hdpa,minPos,p);
1549}
1550
1551/**************************************************************************
1552 * DPA_Sort [COMCTL32.338]
1553 *
1554 * Sorts a pointer array using a user defined compare function
1555 *
1556 * PARAMS
1557 * hdpa [I] handle (pointer) to the pointer array
1558 * pfnCompare [I] pointer to the compare function
1559 * lParam [I] user defined value (3rd parameter of compare function)
1560 *
1561 * RETURNS
1562 * Success: TRUE
1563 * Failure: FALSE
1564 */
1565
1566BOOL WINAPI
1567DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
1568{
1569 dprintf2(("COMCTL32: DPA_Sort"));
1570
1571 if (!hdpa || !pfnCompare)
1572 return FALSE;
1573
1574 if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
1575 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
1576 pfnCompare, lParam);
1577
1578 return TRUE;
1579}
1580
1581
1582/**************************************************************************
1583 * DPA_Search [COMCTL32.339]
1584 *
1585 * Searches a pointer array for a specified pointer
1586 *
1587 * PARAMS
1588 * hdpa [I] handle (pointer) to the pointer array
1589 * pFind [I] pointer to search for
1590 * nStart [I] start index
1591 * pfnCompare [I] pointer to the compare function
1592 * lParam [I] user defined value (3rd parameter of compare function)
1593 * uOptions [I] search options
1594 *
1595 * RETURNS
1596 * Success: index of the pointer in the array.
1597 * Failure: -1
1598 *
1599 * NOTES
1600 * Binary search taken from R.Sedgewick "Algorithms in C"!
1601 * Function is NOT tested!
1602 * If something goes wrong, blame HIM not ME! (Eric Kohl)
1603 */
1604
1605INT WINAPI
1606DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
1607 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
1608{
1609 dprintf2(("COMCTL32: DPA_Search"));
1610
1611 if (!hdpa || !pfnCompare || !pFind)
1612 return -1;
1613
1614 if (uOptions & DPAS_SORTED) {
1615 /* array is sorted --> use binary search */
1616 INT l, r, x, n;
1617 LPVOID *lpPtr;
1618
1619// TRACE (commctrl, "binary search\n");
1620
1621 l = (nStart == -1) ? 0 : nStart;
1622 r = hdpa->nItemCount - 1;
1623 lpPtr = hdpa->ptrs;
1624 while (r >= l) {
1625 x = (l + r) / 2;
1626 n = (pfnCompare)(pFind, lpPtr[x], lParam);
1627 if (n < 0)
1628 r = x - 1;
1629 else
1630 l = x + 1;
1631 if (n == 0) {
1632// TRACE (commctrl, "-- ret=%d\n", n);
1633 return n;
1634 }
1635 }
1636
1637 if (uOptions & DPAS_INSERTBEFORE) {
1638// TRACE (commctrl, "-- ret=%d\n", r);
1639 return r;
1640 }
1641
1642 if (uOptions & DPAS_INSERTAFTER) {
1643// TRACE (commctrl, "-- ret=%d\n", l);
1644 return l;
1645 }
1646 }
1647 else {
1648 /* array is not sorted --> use linear search */
1649 LPVOID *lpPtr;
1650 INT nIndex;
1651
1652// TRACE (commctrl, "linear search\n");
1653
1654 nIndex = (nStart == -1)? 0 : nStart;
1655 lpPtr = hdpa->ptrs;
1656 for (; nIndex < hdpa->nItemCount; nIndex++) {
1657 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
1658// TRACE (commctrl, "-- ret=%d\n", nIndex);
1659 return nIndex;
1660 }
1661 }
1662 }
1663
1664// TRACE (commctrl, "-- not found: ret=-1\n");
1665 return -1;
1666}
1667
1668
1669/**************************************************************************
1670 * DPA_CreateEx [COMCTL32.340]
1671 *
1672 * Creates a dynamic pointer array using the specified size and heap.
1673 *
1674 * PARAMS
1675 * nGrow [I] number of items by which the array grows when it is filled
1676 * hHeap [I] handle to the heap where the array is stored
1677 *
1678 * RETURNS
1679 * Success: handle (pointer) to the pointer array.
1680 * Failure: NULL
1681 */
1682
1683HDPA WINAPI
1684DPA_CreateEx (INT nGrow, HANDLE hHeap)
1685{
1686 HDPA hdpa;
1687
1688 dprintf2(("COMCTL32: DPA_CreateEx"));
1689
1690 if (hHeap)
1691 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
1692 else
1693 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1694
1695 if (hdpa) {
1696 hdpa->nGrow = MIN(8, nGrow);
1697 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
1698 hdpa->nMaxCount = hdpa->nGrow * 2;
1699 hdpa->ptrs =
1700 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
1701 hdpa->nMaxCount * sizeof(LPVOID));
1702 }
1703
1704// TRACE (commctrl, "-- %p\n", hdpa);
1705
1706 return hdpa;
1707}
1708#if 0
1709/**************************************************************************
1710 * DPA_LoadStream [COMCTL32.9]
1711 *
1712 * Loads a dynamic pointer array from a stream
1713 *
1714 * PARAMS
1715 * phDpa [O] pointer to a handle to a dynamic pointer array
1716 * loadProc [I] pointer to a callback function
1717 * pStream [I] pointer to a stream
1718 * lParam [I] application specific value
1719 *
1720 * NOTES
1721 * No more information available yet!
1722 */
1723HRESULT WINAPI
1724DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam)
1725{
1726 HRESULT errCode;
1727 LARGE_INTEGER position;
1728 ULARGE_INTEGER newPosition;
1729 STREAMDATA streamData;
1730 LOADDATA loadData;
1731 ULONG ulRead;
1732 HDPA hDpa;
1733 PVOID *ptr;
1734
1735 //FIXME ("phDpa=3D%p loadProc=3D%p pStream=3D%p lParam=3D%lx\n",phDpa, loadProc, pStream, lParam);
1736
1737 if (!phDpa || !loadProc || !pStream)
1738 return E_INVALIDARG;
1739
1740 *phDpa = (HDPA)NULL;
1741
1742 position.s.LowPart = 0;
1743 position.s.HighPart = 0;
1744
1745
1746
1747 errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition);
1748
1749 if (errCode != S_OK)
1750 return errCode;
1751
1752
1753 errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), = &ulRead);
1754
1755 if (errCode != S_OK)
1756 return errCode;
1757
1758 //FIXME ("dwSize=3D%lu dwData2=3D%lu dwItems=3D%lu\n",streamData.dwSize, streamData.dwData2, streamData.dwItems);
1759
1760 if (lParam < sizeof(STREAMDATA) ||
1761 streamData.dwSize < sizeof(STREAMDATA) ||
1762 streamData.dwData2 < 1) {
1763 errCode = E_FAIL;
1764 }
1765
1766 /* create the dpa */
1767
1768 hDpa = DPA_Create (streamData.dwItems);
1769
1770 if (!hDpa)
1771 return E_OUTOFMEMORY;
1772
1773 if (!DPA_Grow (hDpa, streamData.dwItems))
1774 return E_OUTOFMEMORY;
1775
1776 /* load data from the stream into the dpa */
1777
1778 ptr = hDpa->ptrs;
1779 for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) {
1780 errCode = (loadProc)(&loadData, pStream, lParam);
1781
1782 if (errCode != S_OK) {
1783 errCode = S_FALSE;
1784 break;
1785 }
1786
1787 *ptr = loadData.ptr;
1788 ptr++;
1789 }
1790
1791 /* set the number of items */
1792
1793 hDpa->nItemCount = loadData.nCount;
1794
1795 /* store the handle to the dpa */
1796
1797 *phDpa = hDpa;
1798
1799 //FIXME ("new hDpa=3D%p\n", hDpa);
1800
1801 return errCode;
1802
1803}
1804
1805/**************************************************************************
1806 * DPA_SaveStream [COMCTL32.10]
1807 *
1808 * Saves a dynamic pointer array to a stream
1809 *
1810 * PARAMS
1811 * hDpa [I] handle to a dynamic pointer array
1812 * loadProc [I] pointer to a callback function
1813 * pStream [I] pointer to a stream
1814 * lParam [I] application specific value
1815 *
1816 * NOTES
1817 * No more information available yet!
1818 */
1819HRESULT WINAPI
1820DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, IStream *pStream,LPARAM lParam)
1821{
1822 //FIXME ("hDpa=3D%p loadProc=3D%p pStream=3D%p lParam=3D%lx\n",hDpa, loadProc, pStream, lParam);
1823
1824 return E_FAIL;
1825}
1826#endif
1827/**************************************************************************
1828 * Notification functions
1829 */
1830
1831typedef struct tagNOTIFYDATA
1832{
1833 HWND hwndFrom;
1834 HWND hwndTo;
1835 DWORD dwParam3;
1836 DWORD dwParam4;
1837 DWORD dwParam5;
1838 DWORD dwParam6;
1839} NOTIFYDATA, *LPNOTIFYDATA;
1840
1841
1842/**************************************************************************
1843 * DoNotify [Internal]
1844 */
1845
1846static LRESULT
1847DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr)
1848{
1849 NMHDR nmhdr;
1850 LPNMHDR lpNmh = NULL;
1851 UINT idFrom = 0;
1852
1853// TRACE (commctrl, "(0x%04x 0x%04x %d %p 0x%08lx)\n",
1854// lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
1855// lpNotify->dwParam5);
1856
1857 if (!lpNotify->hwndTo)
1858 return 0;
1859
1860 if (lpNotify->hwndFrom == -1) {
1861 lpNmh = lpHdr;
1862 idFrom = lpHdr->idFrom;
1863 }
1864 else {
1865 if (lpNotify->hwndFrom) {
1866 HWND hwndParent = GetParent (lpNotify->hwndFrom);
1867 if (hwndParent) {
1868 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
1869 if (hwndParent)
1870 idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
1871 }
1872 }
1873
1874 lpNmh = (lpHdr) ? lpHdr : &nmhdr;
1875
1876 lpNmh->hwndFrom = lpNotify->hwndFrom;
1877 lpNmh->idFrom = idFrom;
1878 lpNmh->code = uCode;
1879 }
1880
1881 return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh);
1882}
1883
1884
1885/**************************************************************************
1886 * SendNotify [COMCTL32.341]
1887 *
1888 * PARAMS
1889 * hwndFrom [I]
1890 * hwndTo [I]
1891 * uCode [I]
1892 * lpHdr [I]
1893 *
1894 * RETURNS
1895 * Success: return value from notification
1896 * Failure: 0
1897 */
1898
1899LRESULT WINAPI
1900COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
1901 UINT uCode, LPNMHDR lpHdr)
1902{
1903 NOTIFYDATA notify;
1904
1905 dprintf(("COMCTL32: SendNotify"));
1906
1907 notify.hwndFrom = hwndFrom;
1908 notify.hwndTo = hwndTo;
1909 notify.dwParam5 = 0;
1910 notify.dwParam6 = 0;
1911
1912 return DoNotify (&notify, uCode, lpHdr);
1913}
1914
1915
1916/**************************************************************************
1917 * SendNotifyEx [COMCTL32.342]
1918 *
1919 * PARAMS
1920 * hwndFrom [I]
1921 * hwndTo [I]
1922 * uCode [I]
1923 * lpHdr [I]
1924 * dwParam5 [I]
1925 *
1926 * RETURNS
1927 * Success: return value from notification
1928 * Failure: 0
1929 */
1930
1931LRESULT WINAPI
1932COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
1933 LPNMHDR lpHdr, DWORD dwParam5)
1934{
1935 NOTIFYDATA notify;
1936 HWND hwndNotify;
1937
1938 dprintf(("COMCTL32: SendNotifyEx"));
1939
1940 hwndNotify = hwndTo;
1941 if (!hwndTo) {
1942 if (IsWindow (hwndFrom)) {
1943 hwndNotify = GetParent (hwndFrom);
1944 if (!hwndNotify)
1945 return 0;
1946 }
1947 }
1948
1949 notify.hwndFrom = hwndFrom;
1950 notify.hwndTo = hwndNotify;
1951 notify.dwParam5 = dwParam5;
1952 notify.dwParam6 = 0;
1953
1954 return DoNotify (&notify, uCode, lpHdr);
1955}
1956
1957
1958/**************************************************************************
1959 * StrChrA [COMCTL32.350]
1960 *
1961 */
1962
1963LPSTR WINAPI
1964COMCTL32_StrChrA (LPCSTR lpString, CHAR cChar)
1965{
1966 dprintf(("COMCTL32: StrChrA"));
1967
1968 return strchr (lpString, cChar);
1969}
1970
1971
1972/**************************************************************************
1973 * StrStrIA [COMCTL32.355]
1974 */
1975
1976LPSTR WINAPI
1977COMCTL32_StrStrIA (LPCSTR lpStr1, LPCSTR lpStr2)
1978{
1979 INT len1, len2, i;
1980 CHAR first;
1981
1982 dprintf(("COMCTL32: StrStrIA"));
1983
1984 if (*lpStr2 == 0)
1985 return ((LPSTR)lpStr1);
1986 len1 = 0;
1987 while (lpStr1[len1] != 0) ++len1;
1988 len2 = 0;
1989 while (lpStr2[len2] != 0) ++len2;
1990 if (len2 == 0)
1991 return ((LPSTR)(lpStr1 + len1));
1992 first = tolower (*lpStr2);
1993 while (len1 >= len2) {
1994 if (tolower(*lpStr1) == first) {
1995 for (i = 1; i < len2; ++i)
1996 if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
1997 break;
1998 if (i >= len2)
1999 return ((LPSTR)lpStr1);
2000 }
2001 ++lpStr1; --len1;
2002 }
2003 return (NULL);
2004}
2005
2006
2007/**************************************************************************
2008 * StrToIntA [COMCTL32.357] Converts a string to a signed integer.
2009 */
2010
2011INT WINAPI
2012COMCTL32_StrToIntA (LPSTR lpString)
2013{
2014 dprintf(("COMCTL32: StrToIntA"));
2015
2016 return atoi(lpString);
2017}
2018
2019/**************************************************************************
2020 * DPA_EnumCallback [COMCTL32.385]
2021 *
2022 * Enumerates all items in a dynamic pointer array.
2023 *
2024 * PARAMS
2025 * hdpa [I] handle to the dynamic pointer array
2026 * enumProc [I]
2027 * lParam [I]
2028 *
2029 * RETURNS
2030 * none
2031 */
2032
2033
2034VOID WINAPI
2035DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2036{
2037 INT i;
2038
2039 dprintf(("COMCTL32: DPA_EnumCallback"));
2040
2041 if (!hdpa)
2042 return;
2043 if (hdpa->nItemCount <= 0)
2044 return;
2045
2046 for (i = 0; i < hdpa->nItemCount; i++) {
2047 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
2048 return;
2049 }
2050
2051 return;
2052}
2053
2054
2055/**************************************************************************
2056 * DPA_DestroyCallback [COMCTL32.386]
2057 *
2058 * Enumerates all items in a dynamic pointer array and destroys it.
2059 *
2060 * PARAMS
2061 * hdpa [I] handle to the dynamic pointer array
2062 * enumProc [I]
2063 * lParam [I]
2064 *
2065 * RETURNS
2066 * Success: TRUE
2067 * Failure: FALSE
2068 */
2069
2070BOOL WINAPI
2071DPA_DestroyCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2072{
2073 dprintf(("COMCTL32: DPA_DestroyCallback"));
2074
2075 DPA_EnumCallback (hdpa, enumProc, lParam);
2076
2077 return DPA_Destroy (hdpa);
2078}
2079
2080
2081/**************************************************************************
2082 * DSA_EnumCallback [COMCTL32.387]
2083 *
2084 * Enumerates all items in a dynamic storage array.
2085 *
2086 * PARAMS
2087 * hdsa [I] handle to the dynamic storage array
2088 * enumProc [I]
2089 * lParam [I]
2090 *
2091 * RETURNS
2092 * none
2093 */
2094
2095VOID WINAPI
2096DSA_EnumCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2097{
2098 INT i;
2099
2100 dprintf(("COMCTL32: DSA_EnumCallback"));
2101
2102 if (!hdsa)
2103 return;
2104 if (hdsa->nItemCount <= 0)
2105 return;
2106
2107 for (i = 0; i < hdsa->nItemCount; i++) {
2108 LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
2109 if ((enumProc)(lpItem, lParam) == 0)
2110 return;
2111 }
2112
2113 return;
2114}
2115
2116
2117/**************************************************************************
2118 * DSA_DestroyCallback [COMCTL32.388]
2119 *
2120 * Enumerates all items in a dynamic storage array and destroys it.
2121 *
2122 * PARAMS
2123 * hdsa [I] handle to the dynamic storage array
2124 * enumProc [I]
2125 * lParam [I]
2126 *
2127 * RETURNS
2128 * Success: TRUE
2129 * Failure: FALSE
2130 */
2131
2132BOOL WINAPI
2133DSA_DestroyCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2134{
2135 dprintf(("COMCTL32: DSA_DestroyCallback"));
2136
2137 DSA_EnumCallback (hdsa, enumProc, lParam);
2138
2139 return DSA_Destroy (hdsa);
2140}
2141
2142/**************************************************************************
2143 * StrCSpnA [COMCTL32.356]
2144 *
2145 */
2146INT WINAPI COMCTL32_StrCSpnA( LPCSTR lpStr, LPCSTR lpSet)
2147{
2148 dprintf(("COMCTL32: StrCSpnA"));
2149
2150 return strcspn(lpStr, lpSet);
2151}
2152
2153/**************************************************************************
2154 * StrChrW [COMCTL32.358]
2155 *
2156 */
2157LPWSTR WINAPI COMCTL32_StrChrW( LPCWSTR lpStart, WORD wMatch)
2158{
2159 dprintf(("COMCTL32: StrChrW"));
2160
2161 return (unsigned short*)wcschr((wchar_t*)lpStart, wMatch);
2162}
2163
2164/**************************************************************************
2165 * StrCmpNA [COMCTL32.352]
2166 *
2167 */
2168INT WINAPI COMCTL32_StrCmpNA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar)
2169{
2170 dprintf(("COMCTL32: StrCmpNA"));
2171
2172 return strncmp(lpStr1, lpStr2, nChar);
2173}
2174
2175/**************************************************************************
2176 * StrCmpNIA [COMCTL32.353]
2177 *
2178 */
2179INT WINAPI COMCTL32_StrCmpNIA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar)
2180{
2181 //AH: Inline helper function from WINE
2182 int res;
2183
2184 dprintf(("COMCTL32: StrCmpNIA"));
2185
2186 if (!nChar) return 0;
2187 while ((--nChar > 0) && *lpStr1)
2188 {
2189 res = toupper(*lpStr1++) - toupper(*lpStr2++);
2190 if (res) return res;
2191 }
2192 return toupper(*lpStr1) - toupper(*lpStr2);
2193}
2194
2195/**************************************************************************
2196 * StrCmpNW [COMCTL32.360]
2197 *
2198 */
2199INT WINAPI COMCTL32_StrCmpNW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar)
2200{
2201 dprintf(("COMCTL32: StrCmpNW"));
2202
2203 return wcsncmp((wchar_t*)lpStr1,(wchar_t*)lpStr2,nChar);
2204}
2205
2206/**************************************************************************
2207 * StrCmpNIW [COMCTL32.361]
2208 *
2209 */
2210INT WINAPI COMCTL32_StrCmpNIW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar)
2211{
2212 dprintf(("COMCTL32: StrCmpNIW - unimplemented stub\n"));
2213
2214 return 0;
2215}
2216
2217/***********************************************************************
2218 * ChrCmpA
2219 * This fuction returns FALSE if both words match, TRUE otherwise...
2220 */
2221static BOOL ChrCmpA( WORD word1, WORD word2) {
2222 if (LOBYTE(word1) == LOBYTE(word2)) {
2223 if (IsDBCSLeadByte(LOBYTE(word1))) {
2224 return (word1 != word2);
2225 }
2226 return FALSE;
2227 }
2228 return TRUE;
2229}
2230
2231/**************************************************************************
2232 * StrRChrA [COMCTL32.351]
2233 *
2234 */
2235LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch)
2236{
2237 LPCSTR lpGotIt = NULL;
2238
2239 dprintf(("COMCTL32: StrRChrA"));
2240
2241 if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
2242
2243 for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
2244 if (!ChrCmpA( GET_WORD(lpStart), wMatch))
2245 lpGotIt = lpStart;
2246
2247 return ((LPSTR)lpGotIt);
2248
2249 return 0;
2250}
2251
2252/***********************************************************************
2253 * ChrCmpW
2254 * This fuction returns FALSE if both words match, TRUE otherwise...
2255 */
2256static BOOL ChrCmpW( WORD word1, WORD word2) {
2257 return (word1 != word2);
2258}
2259
2260/**************************************************************************
2261 * StrRChrW [COMCTL32.359]
2262 *
2263 */
2264LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
2265{
2266 //AH: Inline Wine helper function
2267 LPCWSTR lpGotIt = NULL;
2268
2269 dprintf(("COMCTL32: StrRChrW"));
2270
2271 if (!lpEnd) lpEnd = lpStart + lstrlenW(lpStart);
2272
2273 for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
2274 if (!ChrCmpW( GET_WORD(lpStart), wMatch))
2275 lpGotIt = lpStart;
2276
2277 return (LPWSTR)lpGotIt;
2278}
2279
2280
2281/**************************************************************************
2282 * StrStrA [COMCTL32.354]
2283 *
2284 */
2285LPSTR WINAPI COMCTL32_StrStrA( LPCSTR lpFirst, LPCSTR lpSrch)
2286{
2287 dprintf(("COMCTL32: StrStrA"));
2288
2289 return strstr(lpFirst, lpSrch);
2290}
2291
2292/**************************************************************************
2293 * StrStrW [COMCTL32.362]
2294 *
2295 */
2296LPWSTR WINAPI COMCTL32_StrStrW( LPCWSTR lpFirst, LPCWSTR lpSrch)
2297{
2298 dprintf(("COMCTL32: StrStrW"));
2299
2300 return (unsigned short*)wcsstr((wchar_t*)lpFirst,(wchar_t*)lpSrch);
2301}
2302
2303/**************************************************************************
2304 * StrSpnW [COMCTL32.364]
2305 *
2306 */
2307INT WINAPI COMCTL32_StrSpnW( LPWSTR lpStr, LPWSTR lpSet)
2308{
2309 LPWSTR lpLoop = lpStr;
2310
2311 dprintf(("COMCTL32: StrSpnW"));
2312
2313 /* validate ptr */
2314 if ((lpStr == 0) || (lpSet == 0)) return 0;
2315
2316/* while(*lpLoop) { if lpLoop++; } */
2317
2318 for(; (*lpLoop != 0); lpLoop++)
2319 if (wcschr((wchar_t*)lpSet, *(WORD*)lpLoop))
2320 return (INT)(lpLoop-lpStr);
2321
2322 return (INT)(lpLoop-lpStr);
2323}
2324
2325/**************************************************************************
2326 * comctl32_410 [COMCTL32.410]
2327 *
2328 * FIXME: What's this supposed to do?
2329 * Parameter 1 is an HWND, you're on your own for the rest.
2330 */
2331
2332BOOL WINAPI comctl32_410( HWND hw, DWORD b, DWORD c, DWORD d)
2333{
2334 dprintf(("COMCTL32: comctl32_410 - empty stub!"));
2335
2336 return TRUE;
2337}
2338
2339/**************************************************************************
2340 * comctl32_411 [COMCTL32.411]
2341 *
2342 * FIXME: What's this supposed to do?
2343 * Parameter 1 is an HWND, you're on your own for the rest.
2344 */
2345
2346BOOL WINAPI comctl32_411( HWND hw, DWORD b, DWORD c)
2347{
2348 dprintf(("COMCTL32: comctl32_411 - empty stub!"));
2349
2350 return TRUE;
2351}
2352
2353/**************************************************************************
2354 * comctl32_412 [COMCTL32.412]
2355 *
2356 * FIXME: What's this supposed to do?
2357 * Parameter 1 is an HWND, you're on your own for the rest.
2358 */
2359
2360BOOL WINAPI comctl32_412( HWND hwnd, DWORD b, DWORD c)
2361{
2362 dprintf(("COMCTL32: comctl32_412 - empty stub!"));
2363
2364 if (IsWindow (hwnd) == FALSE)
2365 return FALSE;
2366
2367 if (b == 0)
2368 return FALSE;
2369
2370
2371 return TRUE;
2372}
2373
2374/**************************************************************************
2375 * comctl32_413 [COMCTL32.413]
2376 *
2377 * FIXME: What's this supposed to do?
2378 * Parameter 1 is an HWND, you're on your own for the rest.
2379 */
2380
2381BOOL WINAPI comctl32_413( HWND hw, DWORD b, DWORD c, DWORD d)
2382{
2383 dprintf(("COMCTL32: comctl32_413 - empty stub!"));
2384
2385 return TRUE;
2386}
2387
2388/*************************************************************************
2389 * InitMUILanguage [COMCTL32.70]
2390 *
2391 * FIXME: What's this supposed to do? Apparently some i18n thing.
2392 *
2393 */
2394
2395BOOL WINAPI InitMUILanguage( LANGID uiLang)
2396{
2397 dprintf(("COMCTL32: InitMUILanguage - empty stub!"));
2398
2399 return TRUE;
2400}
Note: See TracBrowser for help on using the repository browser.