2 * Undocumented functions from COMCTL32.DLL
4 * Copyright 1998 Eric Kohl
5 * 1998 Juergen Schmied <j.schmied@metronet.de>
6 * 2000 Eric Kohl for CodeWeavers
9 * All of these functions are UNDOCUMENTED!! And I mean UNDOCUMENTED!!!!
10 * Do NOT rely on names or contents of undocumented structures and types!!!
11 * These functions are used by EXPLORER.EXE, IEXPLORE.EXE and
12 * COMCTL32.DLL (internally).
15 * - Add more functions.
16 * - Write some documentation.
20 #include <stdlib.h> /* atoi */
25 #include "wine/unicode.h"
28 #include "debugtools.h"
30 DEFAULT_DEBUG_CHANNEL(commctrl);
33 extern HANDLE COMCTL32_hHeap; /* handle to the private heap */
36 typedef struct _STREAMDATA
41 } STREAMDATA, *PSTREAMDATA;
43 typedef struct _LOADDATA
47 } LOADDATA, *LPLOADDATA;
49 typedef HRESULT(CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
52 /**************************************************************************
53 * DPA_LoadStream [COMCTL32.9]
55 * Loads a dynamic pointer array from a stream
58 * phDpa [O] pointer to a handle to a dynamic pointer array
59 * loadProc [I] pointer to a callback function
60 * pStream [I] pointer to a stream
61 * lParam [I] application specific value
64 * No more information available yet!
68 DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam)
71 LARGE_INTEGER position;
72 ULARGE_INTEGER newPosition;
73 STREAMDATA streamData;
79 FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
80 phDpa, loadProc, pStream, lParam);
82 if (!phDpa || !loadProc || !pStream)
87 position.s.LowPart = 0;
88 position.s.HighPart = 0;
90 errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition);
94 errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead);
98 FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n",
99 streamData.dwSize, streamData.dwData2, streamData.dwItems);
101 if (lParam < sizeof(STREAMDATA) ||
102 streamData.dwSize < sizeof(STREAMDATA) ||
103 streamData.dwData2 < 1) {
108 hDpa = DPA_Create (streamData.dwItems);
110 return E_OUTOFMEMORY;
112 if (!DPA_Grow (hDpa, streamData.dwItems))
113 return E_OUTOFMEMORY;
115 /* load data from the stream into the dpa */
117 for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) {
118 errCode = (loadProc)(&loadData, pStream, lParam);
119 if (errCode != S_OK) {
128 /* set the number of items */
129 hDpa->nItemCount = loadData.nCount;
131 /* store the handle to the dpa */
133 FIXME ("new hDpa=%p\n", hDpa);
139 /**************************************************************************
140 * DPA_SaveStream [COMCTL32.10]
142 * Saves a dynamic pointer array to a stream
145 * hDpa [I] handle to a dynamic pointer array
146 * loadProc [I] pointer to a callback function
147 * pStream [I] pointer to a stream
148 * lParam [I] application specific value
151 * No more information available yet!
155 DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam)
158 FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
159 hDpa, loadProc, pStream, lParam);
165 /**************************************************************************
166 * DPA_Merge [COMCTL32.11]
169 * hdpa1 [I] handle to a dynamic pointer array
170 * hdpa2 [I] handle to a dynamic pointer array
172 * pfnCompare [I] pointer to sort function
173 * pfnMerge [I] pointer to merge function
174 * lParam [I] application specific value
177 * No more information available yet!
181 DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
182 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
185 LPVOID *pWork1, *pWork2;
189 TRACE("%p %p %08lx %p %p %08lx)\n",
190 hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
192 if (IsBadWritePtr (hdpa1, sizeof(DPA)))
195 if (IsBadWritePtr (hdpa2, sizeof(DPA)))
198 if (IsBadCodePtr ((FARPROC)pfnCompare))
201 if (IsBadCodePtr ((FARPROC)pfnMerge))
204 if (dwFlags & DPAM_SORT) {
205 TRACE("sorting dpa's!\n");
206 if (hdpa1->nItemCount > 0)
207 DPA_Sort (hdpa1, pfnCompare, lParam);
208 TRACE ("dpa 1 sorted!\n");
209 if (hdpa2->nItemCount > 0)
210 DPA_Sort (hdpa2, pfnCompare, lParam);
211 TRACE ("dpa 2 sorted!\n");
214 if (hdpa2->nItemCount < 1)
217 TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n",
218 hdpa1->nItemCount, hdpa2->nItemCount);
221 /* working but untrusted implementation */
223 pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]);
224 pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]);
226 nIndex = hdpa1->nItemCount - 1;
227 nCount = hdpa2->nItemCount - 1;
231 if (nIndex < 0) break;
232 nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
233 TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
234 nResult, nIndex, nCount);
240 ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam);
250 else if (nResult < 0)
256 ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
258 (pfnMerge)(2, ptr, NULL, lParam);
269 ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
272 DPA_InsertPtr (hdpa1, nIndex, ptr);
285 /**************************************************************************
286 * Alloc [COMCTL32.71]
288 * Allocates memory block from the dll's private heap
291 * dwSize [I] size of the allocated memory block
294 * Success: pointer to allocated memory block
299 COMCTL32_Alloc (DWORD dwSize)
303 TRACE("(0x%lx)\n", dwSize);
305 lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
307 TRACE("-- ret=%p\n", lpPtr);
313 /**************************************************************************
314 * ReAlloc [COMCTL32.72]
316 * Changes the size of an allocated memory block or allocates a memory
317 * block using the dll's private heap.
320 * lpSrc [I] pointer to memory block which will be resized
321 * dwSize [I] new size of the memory block.
324 * Success: pointer to the resized memory block
328 * If lpSrc is a NULL-pointer, then COMCTL32_ReAlloc allocates a memory
329 * block like COMCTL32_Alloc.
333 COMCTL32_ReAlloc (LPVOID lpSrc, DWORD dwSize)
337 TRACE("(%p 0x%08lx)\n", lpSrc, dwSize);
340 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
342 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
344 TRACE("-- ret=%p\n", lpDest);
350 /**************************************************************************
353 * Frees an allocated memory block from the dll's private heap.
356 * lpMem [I] pointer to memory block which will be freed
364 COMCTL32_Free (LPVOID lpMem)
366 TRACE("(%p)\n", lpMem);
368 return HeapFree (COMCTL32_hHeap, 0, lpMem);
372 /**************************************************************************
373 * GetSize [COMCTL32.74]
375 * Retrieves the size of the specified memory block from the dll's
379 * lpMem [I] pointer to an allocated memory block
382 * Success: size of the specified memory block
387 COMCTL32_GetSize (LPVOID lpMem)
389 TRACE("(%p)\n", lpMem);
391 return HeapSize (COMCTL32_hHeap, 0, lpMem);
395 /**************************************************************************
396 * The MRU-API is a set of functions to manipulate MRU(Most Recently Used)
399 * Stored in the reg. as a set of values under a single key. Each item in the
400 * list has a value name that is a single char. 'a' - 'z', '{', '|' or '}'.
401 * The order of the list is stored with value name 'MRUList' which is a string
402 * containing the value names (i.e. 'a', 'b', etc.) in the relevant order.
405 typedef struct tagCREATEMRULIST
407 DWORD cbSize; /* size of struct */
408 DWORD nMaxItems; /* max no. of items in list */
409 DWORD dwFlags; /* see below */
410 HKEY hKey; /* root reg. key under which list is saved */
411 LPCSTR lpszSubKey; /* reg. subkey */
412 PROC lpfnCompare; /* item compare proc */
413 } CREATEMRULIST, *LPCREATEMRULIST;
416 #define MRUF_STRING_LIST 0 /* list will contain strings */
417 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
418 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
420 /* If list is a string list lpfnCompare has the following prototype
421 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
422 * for binary lists the prototype is
423 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
424 * where cbData is the no. of bytes to compare.
425 * Need to check what return value means identical - 0?
428 typedef struct tagMRU
430 DWORD dwParam1; /* some kind of flag */
439 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
440 DWORD dwParam3, DWORD dwParam4);
443 /**************************************************************************
444 * CreateMRUListA [COMCTL32.151]
447 * lpcml [I] ptr to CREATEMRULIST structure.
450 * Handle to MRU list.
453 CreateMRUListA (LPCREATEMRULIST lpcml)
455 return CreateMRUListLazyA (lpcml, 0, 0, 0);
458 /**************************************************************************
459 * FreeMRUListA [COMCTL32.152]
462 * hMRUList [I] Handle to list.
466 FreeMRUListA (HANDLE hMRUList)
468 FIXME("(%08x) empty stub!\n", hMRUList);
471 if (!(hmru->dwParam1 & 1001)) {
472 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
474 strlen (hmru->lpszMRUString));
478 RegClosKey (hmru->hkeyMRU
479 COMCTL32_Free32 (hmru->lpszMRUString);
482 return COMCTL32_Free ((LPVOID)hMRUList);
486 /**************************************************************************
487 * AddMRUData [COMCTL32.167]
489 * Add item to MRU binary list. If item already exists in list them it is
490 * simply moved up to the top of the list and not added again. If list is
491 * full then the least recently used item is removed to make room.
494 * hList [I] Handle to list.
495 * lpData [I] ptr to data to add.
496 * cbData [I] no. of bytes of data.
499 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
503 AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData)
505 FIXME("(%08x, %p, %ld) empty stub!\n", hList, lpData, cbData);
510 /**************************************************************************
511 * AddMRUStringA [COMCTL32.153]
513 * Add item to MRU string list. If item already exists in list them it is
514 * simply moved up to the top of the list and not added again. If list is
515 * full then the least recently used item is removed to make room.
518 * hList [I] Handle to list.
519 * lpszString [I] ptr to string to add.
522 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
526 AddMRUStringA(HANDLE hList, LPCSTR lpszString)
528 FIXME("(%08x, %s) empty stub!\n", hList, debugstr_a(lpszString));
533 /**************************************************************************
534 * DelMRUString [COMCTL32.156]
536 * Removes item from either string or binary list (despite its name)
539 * hList [I] list handle
540 * nItemPos [I] item position to remove 0 -> MRU
543 * TRUE is successful, FALSE if nItemPos is out of range.
546 DelMRUString(HANDLE hList, INT nItemPos)
548 FIXME("(%08x, %d): stub\n", hList, nItemPos);
552 /**************************************************************************
553 * FindMRUData [COMCTL32.169]
555 * Searches binary list for item that matches lpData of length cbData.
556 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
557 * corresponding to item's reg. name will be stored in it ('a' -> 0).
560 * hList [I] list handle
561 * lpData [I] data to find
562 * cbData [I] length of data
563 * lpRegNum [O] position in registry (maybe NULL)
566 * Position in list 0 -> MRU. -1 if item not found.
569 FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum)
571 FIXME("(%08x, %p, %ld, %p) empty stub!\n",
572 hList, lpData, cbData, lpRegNum);
577 /**************************************************************************
578 * FindMRUStringA [COMCTL32.155]
580 * Searches string list for item that matches lpszString.
581 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
582 * corresponding to item's reg. name will be stored in it ('a' -> 0).
585 * hList [I] list handle
586 * lpszString [I] string to find
587 * lpRegNum [O] position in registry (maybe NULL)
590 * Position in list 0 -> MRU. -1 if item not found.
593 FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum)
595 FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString),
601 /**************************************************************************
602 * CreateMRUListLazyA [COMCTL32.157]
605 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
614 * DWORD dwDisposition; */
616 /* internal variables */
619 FIXME("(%p) empty stub!\n", lpcml);
624 if (lpcml->cbSize < sizeof(CREATEMRULIST))
627 FIXME("(%lu %lu %lx %lx \"%s\" %p)\n",
628 lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
629 (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
631 /* dummy pointer creation */
632 ptr = COMCTL32_Alloc (32);
634 FIXME("-- ret = %p\n", ptr);
639 /**************************************************************************
640 * EnumMRUListA [COMCTL32.154]
642 * Enumerate item in a list
645 * hList [I] list handle
646 * nItemPos [I] item position to enumerate
647 * lpBuffer [O] buffer to receive item
648 * nBufferSize [I] size of buffer
651 * For binary lists specifies how many bytes were copied to buffer, for
652 * string lists specifies full length of string. Enumerating past the end
653 * of list returns -1.
654 * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
657 INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
660 FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer,
665 /**************************************************************************
666 * Str_GetPtrA [COMCTL32.233]
677 Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen)
681 TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
683 if (!lpDest && lpSrc)
684 return strlen (lpSrc);
694 len = strlen (lpSrc);
698 RtlMoveMemory (lpDest, lpSrc, len);
705 /**************************************************************************
706 * Str_SetPtrA [COMCTL32.234]
716 Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc)
718 TRACE("(%p %p)\n", lppDest, lpSrc);
721 LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
729 COMCTL32_Free (*lppDest);
738 /**************************************************************************
739 * Str_GetPtrW [COMCTL32.235]
750 Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
754 TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
756 if (!lpDest && lpSrc)
757 return strlenW (lpSrc);
767 len = strlenW (lpSrc);
771 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
778 /**************************************************************************
779 * Str_SetPtrW [COMCTL32.236]
789 Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc)
791 TRACE("(%p %p)\n", lppDest, lpSrc);
794 INT len = strlenW (lpSrc) + 1;
795 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
798 strcpyW (ptr, lpSrc);
803 COMCTL32_Free (*lppDest);
812 /**************************************************************************
813 * Str_GetPtrWtoA [internal]
815 * Converts a unicode string into a multi byte string
818 * lpSrc [I] Pointer to the unicode source string
819 * lpDest [O] Pointer to caller supplied storage for the multi byte string
820 * nMaxLen [I] Size, in bytes, of the destination buffer
823 * Length, in bytes, of the converted string.
827 Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen)
831 TRACE("(%s %p %d)\n", debugstr_w(lpSrc), lpDest, nMaxLen);
833 if (!lpDest && lpSrc)
834 return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
844 len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
848 WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL);
855 /**************************************************************************
856 * Str_SetPtrAtoW [internal]
858 * Converts a multi byte string to a unicode string.
859 * If the pointer to the destination buffer is NULL a buffer is allocated.
860 * If the destination buffer is too small to keep the converted multi byte
861 * string the destination buffer is reallocated. If the source pointer is
862 * NULL, the destination buffer is freed.
865 * lppDest [I/O] pointer to a pointer to the destination buffer
866 * lpSrc [I] pointer to a multi byte string
869 * TRUE: conversion successful
874 Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc)
876 TRACE("(%p %s)\n", lppDest, lpSrc);
879 INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0);
880 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR));
884 MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len);
889 COMCTL32_Free (*lppDest);
898 /**************************************************************************
899 * The DSA-API is a set of functions to create and manipulate arrays of
900 * fixed-size memory blocks. These arrays can store any kind of data
901 * (strings, icons...).
904 /**************************************************************************
905 * DSA_Create [COMCTL32.320] Creates a dynamic storage array
908 * nSize [I] size of the array elements
909 * nGrow [I] number of elements by which the array grows when it is filled
912 * Success: pointer to an array control structure. Use this like a handle.
917 DSA_Create (INT nSize, INT nGrow)
921 TRACE("(size=%d grow=%d)\n", nSize, nGrow);
923 hdsa = (HDSA)COMCTL32_Alloc (sizeof(DSA));
926 hdsa->nItemCount = 0;
929 hdsa->nItemSize = nSize;
930 hdsa->nGrow = max(1, nGrow);
937 /**************************************************************************
938 * DSA_Destroy [COMCTL32.321] Destroys a dynamic storage array
941 * hdsa [I] pointer to the array control structure
949 DSA_Destroy (const HDSA hdsa)
951 TRACE("(%p)\n", hdsa);
956 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
959 return COMCTL32_Free (hdsa);
963 /**************************************************************************
964 * DSA_GetItem [COMCTL32.322]
967 * hdsa [I] pointer to the array control structure
968 * nIndex [I] number of the Item to get
969 * pDest [O] destination buffer. Has to be >= dwElementSize.
977 DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest)
981 TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
985 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
988 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
989 memmove (pDest, pSrc, hdsa->nItemSize);
995 /**************************************************************************
996 * DSA_GetItemPtr [COMCTL32.323]
998 * Retrieves a pointer to the specified item.
1001 * hdsa [I] pointer to the array control structure
1002 * nIndex [I] index of the desired item
1005 * Success: pointer to an item
1010 DSA_GetItemPtr (const HDSA hdsa, INT nIndex)
1014 TRACE("(%p %d)\n", hdsa, nIndex);
1018 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
1021 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1023 TRACE("-- ret=%p\n", pSrc);
1029 /**************************************************************************
1030 * DSA_SetItem [COMCTL32.325]
1032 * Sets the contents of an item in the array.
1035 * hdsa [I] pointer to the array control structure
1036 * nIndex [I] index for the item
1037 * pSrc [I] pointer to the new item data
1045 DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
1047 INT nSize, nNewItems;
1048 LPVOID pDest, lpTemp;
1050 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
1052 if ((!hdsa) || nIndex < 0)
1055 if (hdsa->nItemCount <= nIndex) {
1056 /* within the old array */
1057 if (hdsa->nMaxCount > nIndex) {
1058 /* within the allocated space, set a new boundary */
1059 hdsa->nItemCount = nIndex + 1;
1062 /* resize the block of memory */
1064 hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
1065 nSize = hdsa->nItemSize * nNewItems;
1067 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1071 hdsa->nMaxCount = nNewItems;
1072 hdsa->nItemCount = nIndex + 1;
1073 hdsa->pData = lpTemp;
1077 /* put the new entry in */
1078 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1079 TRACE("-- move dest=%p src=%p size=%d\n",
1080 pDest, pSrc, hdsa->nItemSize);
1081 memmove (pDest, pSrc, hdsa->nItemSize);
1087 /**************************************************************************
1088 * DSA_InsertItem [COMCTL32.325]
1091 * hdsa [I] pointer to the array control structure
1092 * nIndex [I] index for the new item
1093 * pSrc [I] pointer to the element
1096 * Success: position of the new item
1101 DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
1103 INT nNewItems, nSize, i;
1104 LPVOID lpTemp, lpDest;
1107 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
1109 if ((!hdsa) || nIndex < 0)
1112 for (i = 0; i < hdsa->nItemSize; i += 4) {
1113 p = *(DWORD**)((char *) pSrc + i);
1114 if (IsBadStringPtrA ((char*)p, 256))
1115 TRACE("-- %d=%p\n", i, (DWORD*)p);
1117 TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
1120 /* when nIndex >= nItemCount then append */
1121 if (nIndex >= hdsa->nItemCount)
1122 nIndex = hdsa->nItemCount;
1124 /* do we need to resize ? */
1125 if (hdsa->nItemCount >= hdsa->nMaxCount) {
1126 nNewItems = hdsa->nMaxCount + hdsa->nGrow;
1127 nSize = hdsa->nItemSize * nNewItems;
1129 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1133 hdsa->nMaxCount = nNewItems;
1134 hdsa->pData = lpTemp;
1137 /* do we need to move elements ? */
1138 if (nIndex < hdsa->nItemCount) {
1139 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1140 lpDest = (char *) lpTemp + hdsa->nItemSize;
1141 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
1142 TRACE("-- move dest=%p src=%p size=%d\n",
1143 lpDest, lpTemp, nSize);
1144 memmove (lpDest, lpTemp, nSize);
1147 /* ok, we can put the new Item in */
1149 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1150 TRACE("-- move dest=%p src=%p size=%d\n",
1151 lpDest, pSrc, hdsa->nItemSize);
1152 memmove (lpDest, pSrc, hdsa->nItemSize);
1158 /**************************************************************************
1159 * DSA_DeleteItem [COMCTL32.326]
1162 * hdsa [I] pointer to the array control structure
1163 * nIndex [I] index for the element to delete
1166 * Success: number of the deleted element
1171 DSA_DeleteItem (const HDSA hdsa, INT nIndex)
1173 LPVOID lpDest,lpSrc;
1176 TRACE("(%p %d)\n", hdsa, nIndex);
1180 if (nIndex < 0 || nIndex >= hdsa->nItemCount)
1183 /* do we need to move ? */
1184 if (nIndex < hdsa->nItemCount - 1) {
1185 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1186 lpSrc = (char *) lpDest + hdsa->nItemSize;
1187 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
1188 TRACE("-- move dest=%p src=%p size=%d\n",
1189 lpDest, lpSrc, nSize);
1190 memmove (lpDest, lpSrc, nSize);
1196 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
1197 nSize = hdsa->nItemSize * hdsa->nItemCount;
1199 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1203 hdsa->nMaxCount = hdsa->nItemCount;
1204 hdsa->pData = lpDest;
1211 /**************************************************************************
1212 * DSA_DeleteAllItems [COMCTL32.326]
1214 * Removes all items and reinitializes the array.
1217 * hdsa [I] pointer to the array control structure
1225 DSA_DeleteAllItems (const HDSA hdsa)
1227 TRACE("(%p)\n", hdsa);
1231 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
1234 hdsa->nItemCount = 0;
1236 hdsa->nMaxCount = 0;
1242 /**************************************************************************
1243 * The DPA-API is a set of functions to create and manipulate arrays of
1247 /**************************************************************************
1248 * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
1251 * nGrow [I] number of items by which the array grows when it is filled
1254 * Success: handle (pointer) to the pointer array.
1259 DPA_Create (INT nGrow)
1263 TRACE("(%d)\n", nGrow);
1265 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1267 hdpa->nGrow = max(8, nGrow);
1268 hdpa->hHeap = COMCTL32_hHeap;
1269 hdpa->nMaxCount = hdpa->nGrow * 2;
1271 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
1274 TRACE("-- %p\n", hdpa);
1280 /**************************************************************************
1281 * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
1284 * hdpa [I] handle (pointer) to the pointer array
1292 DPA_Destroy (const HDPA hdpa)
1294 TRACE("(%p)\n", hdpa);
1299 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1302 return HeapFree (hdpa->hHeap, 0, hdpa);
1306 /**************************************************************************
1307 * DPA_Grow [COMCTL32.330]
1309 * Sets the growth amount.
1312 * hdpa [I] handle (pointer) to the existing (source) pointer array
1313 * nGrow [I] number of items, the array grows, when it's too small
1321 DPA_Grow (const HDPA hdpa, INT nGrow)
1323 TRACE("(%p %d)\n", hdpa, nGrow);
1328 hdpa->nGrow = max(8, nGrow);
1334 /**************************************************************************
1335 * DPA_Clone [COMCTL32.331]
1337 * Copies a pointer array to an other one or creates a copy
1340 * hdpa [I] handle (pointer) to the existing (source) pointer array
1341 * hdpaNew [O] handle (pointer) to the destination pointer array
1344 * Success: pointer to the destination pointer array.
1348 * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer
1349 * array will be created and it's handle (pointer) is returned.
1350 * - If 'hdpa' is a NULL-Pointer, the original implementation crashes,
1351 * this implementation just returns NULL.
1355 DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
1357 INT nNewItems, nSize;
1363 TRACE("(%p %p)\n", hdpa, hdpaNew);
1366 /* create a new DPA */
1367 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1369 hdpaTemp->hHeap = hdpa->hHeap;
1370 hdpaTemp->nGrow = hdpa->nGrow;
1375 if (hdpaTemp->ptrs) {
1376 /* remove old pointer array */
1377 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
1378 hdpaTemp->ptrs = NULL;
1379 hdpaTemp->nItemCount = 0;
1380 hdpaTemp->nMaxCount = 0;
1383 /* create a new pointer array */
1384 nNewItems = hdpaTemp->nGrow *
1385 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
1386 nSize = nNewItems * sizeof(LPVOID);
1388 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
1389 hdpaTemp->nMaxCount = nNewItems;
1391 /* clone the pointer array */
1392 hdpaTemp->nItemCount = hdpa->nItemCount;
1393 memmove (hdpaTemp->ptrs, hdpa->ptrs,
1394 hdpaTemp->nItemCount * sizeof(LPVOID));
1400 /**************************************************************************
1401 * DPA_GetPtr [COMCTL32.332]
1403 * Retrieves a pointer from a dynamic pointer array
1406 * hdpa [I] handle (pointer) to the pointer array
1407 * nIndex [I] array index of the desired pointer
1415 DPA_GetPtr (const HDPA hdpa, INT i)
1417 TRACE("(%p %d)\n", hdpa, i);
1422 WARN("no pointer array.\n");
1425 if ((i < 0) || (i >= hdpa->nItemCount)) {
1426 WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
1430 TRACE("-- %p\n", hdpa->ptrs[i]);
1432 return hdpa->ptrs[i];
1436 /**************************************************************************
1437 * DPA_GetPtrIndex [COMCTL32.333]
1439 * Retrieves the index of the specified pointer
1442 * hdpa [I] handle (pointer) to the pointer array
1446 * Success: index of the specified pointer
1451 DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
1458 for (i = 0; i < hdpa->nItemCount; i++) {
1459 if (hdpa->ptrs[i] == p)
1467 /**************************************************************************
1468 * DPA_InsertPtr [COMCTL32.334]
1470 * Inserts a pointer into a dynamic pointer array
1473 * hdpa [I] handle (pointer) to the array
1475 * p [I] pointer to insert
1478 * Success: index of the inserted pointer
1483 DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
1485 INT nNewItems, nSize, nIndex = 0;
1486 LPVOID *lpTemp, *lpDest;
1488 TRACE("(%p %d %p)\n", hdpa, i, p);
1490 if ((!hdpa) || (i < 0))
1495 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1496 2 * hdpa->nGrow * sizeof(LPVOID));
1499 hdpa->nMaxCount = hdpa->nGrow * 2;
1503 if (hdpa->nItemCount >= hdpa->nMaxCount) {
1504 TRACE("-- resizing\n");
1505 nNewItems = hdpa->nMaxCount + hdpa->nGrow;
1506 nSize = nNewItems * sizeof(LPVOID);
1508 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1512 hdpa->nMaxCount = nNewItems;
1513 hdpa->ptrs = lpTemp;
1516 if (i >= hdpa->nItemCount) {
1517 nIndex = hdpa->nItemCount;
1518 TRACE("-- appending at %d\n", nIndex);
1521 TRACE("-- inserting at %d\n", i);
1522 lpTemp = hdpa->ptrs + i;
1523 lpDest = lpTemp + 1;
1524 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID);
1525 TRACE("-- move dest=%p src=%p size=%x\n",
1526 lpDest, lpTemp, nSize);
1527 memmove (lpDest, lpTemp, nSize);
1534 hdpa->ptrs[nIndex] = p;
1540 /**************************************************************************
1541 * DPA_SetPtr [COMCTL32.335]
1543 * Sets a pointer in the pointer array
1546 * hdpa [I] handle (pointer) to the pointer array
1547 * i [I] index of the pointer that will be set
1548 * p [I] pointer to be set
1556 DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
1560 TRACE("(%p %d %p)\n", hdpa, i, p);
1562 if ((!hdpa) || i < 0)
1565 if (hdpa->nItemCount <= i) {
1566 /* within the old array */
1567 if (hdpa->nMaxCount > i) {
1568 /* within the allocated space, set a new boundary */
1569 hdpa->nItemCount = i+1;
1572 /* resize the block of memory */
1574 hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
1575 INT nSize = nNewItems * sizeof(LPVOID);
1577 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1582 hdpa->nItemCount = nNewItems;
1583 hdpa->ptrs = lpTemp;
1587 /* put the new entry in */
1594 /**************************************************************************
1595 * DPA_DeletePtr [COMCTL32.336]
1597 * Removes a pointer from the pointer array.
1600 * hdpa [I] handle (pointer) to the pointer array
1601 * i [I] index of the pointer that will be deleted
1604 * Success: deleted pointer
1609 DPA_DeletePtr (const HDPA hdpa, INT i)
1611 LPVOID *lpDest, *lpSrc, lpTemp = NULL;
1614 TRACE("(%p %d)\n", hdpa, i);
1616 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
1619 lpTemp = hdpa->ptrs[i];
1621 /* do we need to move ?*/
1622 if (i < hdpa->nItemCount - 1) {
1623 lpDest = hdpa->ptrs + i;
1625 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
1626 TRACE("-- move dest=%p src=%p size=%x\n",
1627 lpDest, lpSrc, nSize);
1628 memmove (lpDest, lpSrc, nSize);
1631 hdpa->nItemCount --;
1634 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
1635 INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
1636 nSize = nNewItems * sizeof(LPVOID);
1637 lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1642 hdpa->nMaxCount = nNewItems;
1643 hdpa->ptrs = (LPVOID*)lpDest;
1650 /**************************************************************************
1651 * DPA_DeleteAllPtrs [COMCTL32.337]
1653 * Removes all pointers and reinitializes the array.
1656 * hdpa [I] handle (pointer) to the pointer array
1664 DPA_DeleteAllPtrs (const HDPA hdpa)
1666 TRACE("(%p)\n", hdpa);
1671 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1674 hdpa->nItemCount = 0;
1675 hdpa->nMaxCount = hdpa->nGrow * 2;
1676 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1677 hdpa->nMaxCount * sizeof(LPVOID));
1683 /**************************************************************************
1684 * DPA_QuickSort [Internal]
1686 * Ordinary quicksort (used by DPA_Sort).
1689 * lpPtrs [I] pointer to the pointer array
1690 * l [I] index of the "left border" of the partition
1691 * r [I] index of the "right border" of the partition
1692 * pfnCompare [I] pointer to the compare function
1693 * lParam [I] user defined value (3rd parameter in compare function)
1700 DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
1701 PFNDPACOMPARE pfnCompare, LPARAM lParam)
1706 TRACE("l=%i r=%i\n", l, r);
1708 if (l==r) /* one element is always sorted */
1710 if (r<l) /* oops, got it in the wrong order */
1712 DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam);
1715 m = (l+r)/2; /* divide by two */
1716 DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam);
1717 DPA_QuickSort(lpPtrs, m+1, r, pfnCompare, lParam);
1719 /* join the two sides */
1720 while( (l<=m) && (m<r) )
1722 if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0)
1725 memmove(&lpPtrs[l+1],&lpPtrs[l],(m-l+1)*sizeof lpPtrs[l]);
1735 /**************************************************************************
1736 * DPA_Sort [COMCTL32.338]
1738 * Sorts a pointer array using a user defined compare function
1741 * hdpa [I] handle (pointer) to the pointer array
1742 * pfnCompare [I] pointer to the compare function
1743 * lParam [I] user defined value (3rd parameter of compare function)
1751 DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
1753 if (!hdpa || !pfnCompare)
1756 TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
1758 if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
1759 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
1760 pfnCompare, lParam);
1766 /**************************************************************************
1767 * DPA_Search [COMCTL32.339]
1769 * Searches a pointer array for a specified pointer
1772 * hdpa [I] handle (pointer) to the pointer array
1773 * pFind [I] pointer to search for
1774 * nStart [I] start index
1775 * pfnCompare [I] pointer to the compare function
1776 * lParam [I] user defined value (3rd parameter of compare function)
1777 * uOptions [I] search options
1780 * Success: index of the pointer in the array.
1784 * Binary search taken from R.Sedgewick "Algorithms in C"!
1785 * Function is NOT tested!
1786 * If something goes wrong, blame HIM not ME! (Eric Kohl)
1790 DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
1791 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
1793 if (!hdpa || !pfnCompare || !pFind)
1796 TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n",
1797 hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
1799 if (uOptions & DPAS_SORTED) {
1800 /* array is sorted --> use binary search */
1804 TRACE("binary search\n");
1806 l = (nStart == -1) ? 0 : nStart;
1807 r = hdpa->nItemCount - 1;
1811 n = (pfnCompare)(pFind, lpPtr[x], lParam);
1817 TRACE("-- ret=%d\n", n);
1822 if (uOptions & DPAS_INSERTBEFORE) {
1823 TRACE("-- ret=%d\n", r);
1827 if (uOptions & DPAS_INSERTAFTER) {
1828 TRACE("-- ret=%d\n", l);
1833 /* array is not sorted --> use linear search */
1837 TRACE("linear search\n");
1839 nIndex = (nStart == -1)? 0 : nStart;
1841 for (; nIndex < hdpa->nItemCount; nIndex++) {
1842 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
1843 TRACE("-- ret=%d\n", nIndex);
1849 TRACE("-- not found: ret=-1\n");
1854 /**************************************************************************
1855 * DPA_CreateEx [COMCTL32.340]
1857 * Creates a dynamic pointer array using the specified size and heap.
1860 * nGrow [I] number of items by which the array grows when it is filled
1861 * hHeap [I] handle to the heap where the array is stored
1864 * Success: handle (pointer) to the pointer array.
1869 DPA_CreateEx (INT nGrow, HANDLE hHeap)
1873 TRACE("(%d 0x%x)\n", nGrow, hHeap);
1876 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
1878 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1881 hdpa->nGrow = min(8, nGrow);
1882 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
1883 hdpa->nMaxCount = hdpa->nGrow * 2;
1885 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
1886 hdpa->nMaxCount * sizeof(LPVOID));
1889 TRACE("-- %p\n", hdpa);
1895 /**************************************************************************
1896 * Notification functions
1899 typedef struct tagNOTIFYDATA
1907 } NOTIFYDATA, *LPNOTIFYDATA;
1910 /**************************************************************************
1911 * DoNotify [Internal]
1915 DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr)
1918 LPNMHDR lpNmh = NULL;
1921 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
1922 lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
1923 lpNotify->dwParam5);
1925 if (!lpNotify->hwndTo)
1928 if (lpNotify->hwndFrom == -1) {
1930 idFrom = lpHdr->idFrom;
1933 if (lpNotify->hwndFrom) {
1934 HWND hwndParent = GetParent (lpNotify->hwndFrom);
1936 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
1938 idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
1942 lpNmh = (lpHdr) ? lpHdr : &nmhdr;
1944 lpNmh->hwndFrom = lpNotify->hwndFrom;
1945 lpNmh->idFrom = idFrom;
1946 lpNmh->code = uCode;
1949 return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh);
1953 /**************************************************************************
1954 * SendNotify [COMCTL32.341]
1963 * Success: return value from notification
1968 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
1969 UINT uCode, LPNMHDR lpHdr)
1973 TRACE("(0x%04x 0x%04x %d %p)\n",
1974 hwndFrom, hwndTo, uCode, lpHdr);
1976 notify.hwndFrom = hwndFrom;
1977 notify.hwndTo = hwndTo;
1978 notify.dwParam5 = 0;
1979 notify.dwParam6 = 0;
1981 return DoNotify (¬ify, uCode, lpHdr);
1985 /**************************************************************************
1986 * SendNotifyEx [COMCTL32.342]
1996 * Success: return value from notification
2001 COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
2002 LPNMHDR lpHdr, DWORD dwParam5)
2007 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
2008 hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
2010 hwndNotify = hwndTo;
2012 if (IsWindow (hwndFrom)) {
2013 hwndNotify = GetParent (hwndFrom);
2019 notify.hwndFrom = hwndFrom;
2020 notify.hwndTo = hwndNotify;
2021 notify.dwParam5 = dwParam5;
2022 notify.dwParam6 = 0;
2024 return DoNotify (¬ify, uCode, lpHdr);
2028 /**************************************************************************
2029 * StrChrA [COMCTL32.350]
2034 COMCTL32_StrChrA (LPCSTR lpString, CHAR cChar)
2036 return strchr (lpString, cChar);
2040 /**************************************************************************
2041 * StrStrIA [COMCTL32.355]
2045 COMCTL32_StrStrIA (LPCSTR lpStr1, LPCSTR lpStr2)
2051 return ((LPSTR)lpStr1);
2053 while (lpStr1[len1] != 0) ++len1;
2055 while (lpStr2[len2] != 0) ++len2;
2057 return ((LPSTR)(lpStr1 + len1));
2058 first = tolower (*lpStr2);
2059 while (len1 >= len2) {
2060 if (tolower(*lpStr1) == first) {
2061 for (i = 1; i < len2; ++i)
2062 if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
2065 return ((LPSTR)lpStr1);
2073 /**************************************************************************
2074 * StrToIntA [COMCTL32.357] Converts a string to a signed integer.
2078 COMCTL32_StrToIntA (LPSTR lpString)
2080 return atoi(lpString);
2084 /**************************************************************************
2085 * DPA_EnumCallback [COMCTL32.385]
2087 * Enumerates all items in a dynamic pointer array.
2090 * hdpa [I] handle to the dynamic pointer array
2099 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2103 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
2107 if (hdpa->nItemCount <= 0)
2110 for (i = 0; i < hdpa->nItemCount; i++) {
2111 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
2119 /**************************************************************************
2120 * DPA_DestroyCallback [COMCTL32.386]
2122 * Enumerates all items in a dynamic pointer array and destroys it.
2125 * hdpa [I] handle to the dynamic pointer array
2135 DPA_DestroyCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2137 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
2139 DPA_EnumCallback (hdpa, enumProc, lParam);
2141 return DPA_Destroy (hdpa);
2145 /**************************************************************************
2146 * DSA_EnumCallback [COMCTL32.387]
2148 * Enumerates all items in a dynamic storage array.
2151 * hdsa [I] handle to the dynamic storage array
2160 DSA_EnumCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2164 TRACE("(%p %p %08lx)\n", hdsa, enumProc, lParam);
2168 if (hdsa->nItemCount <= 0)
2171 for (i = 0; i < hdsa->nItemCount; i++) {
2172 LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
2173 if ((enumProc)(lpItem, lParam) == 0)
2181 /**************************************************************************
2182 * DSA_DestroyCallback [COMCTL32.388]
2184 * Enumerates all items in a dynamic storage array and destroys it.
2187 * hdsa [I] handle to the dynamic storage array
2197 DSA_DestroyCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2199 TRACE("(%p %p %08lx)\n", hdsa, enumProc, lParam);
2201 DSA_EnumCallback (hdsa, enumProc, lParam);
2203 return DSA_Destroy (hdsa);
2206 /**************************************************************************
2207 * StrCSpnA [COMCTL32.356]
2210 INT WINAPI COMCTL32_StrCSpnA( LPCSTR lpStr, LPCSTR lpSet) {
2211 return strcspn(lpStr, lpSet);
2214 /**************************************************************************
2215 * StrChrW [COMCTL32.358]
2218 LPWSTR WINAPI COMCTL32_StrChrW( LPCWSTR lpStart, WORD wMatch) {
2219 return strchrW(lpStart, wMatch);
2222 /**************************************************************************
2223 * StrCmpNA [COMCTL32.352]
2226 INT WINAPI COMCTL32_StrCmpNA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
2227 return strncmp(lpStr1, lpStr2, nChar);
2230 /**************************************************************************
2231 * StrCmpNIA [COMCTL32.353]
2234 INT WINAPI COMCTL32_StrCmpNIA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
2235 return strncasecmp(lpStr1, lpStr2, nChar);
2238 /**************************************************************************
2239 * StrCmpNW [COMCTL32.360]
2242 INT WINAPI COMCTL32_StrCmpNW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
2243 return strncmpW(lpStr1, lpStr2, nChar);
2246 /**************************************************************************
2247 * StrCmpNIW [COMCTL32.361]
2250 INT WINAPI COMCTL32_StrCmpNIW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
2251 FIXME("(%s, %s, %i): stub\n", debugstr_w(lpStr1), debugstr_w(lpStr2), nChar);
2255 /**************************************************************************
2256 * StrRChrA [COMCTL32.351]
2259 LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
2261 LPCSTR lpGotIt = NULL;
2262 BOOL dbcs = IsDBCSLeadByte( LOBYTE(wMatch) );
2264 TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
2266 if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
2268 for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
2270 if (*lpStart != LOBYTE(wMatch)) continue;
2271 if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
2274 return (LPSTR)lpGotIt;
2278 /**************************************************************************
2279 * StrRChrW [COMCTL32.359]
2282 LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
2284 LPCWSTR lpGotIt = NULL;
2286 TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
2287 if (!lpEnd) lpEnd = lpStart + strlenW(lpStart);
2289 for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
2290 if (*lpStart == wMatch) lpGotIt = lpStart;
2292 return (LPWSTR)lpGotIt;
2296 /**************************************************************************
2297 * StrStrA [COMCTL32.354]
2300 LPSTR WINAPI COMCTL32_StrStrA( LPCSTR lpFirst, LPCSTR lpSrch) {
2301 return strstr(lpFirst, lpSrch);
2304 /**************************************************************************
2305 * StrStrW [COMCTL32.362]
2308 LPWSTR WINAPI COMCTL32_StrStrW( LPCWSTR lpFirst, LPCWSTR lpSrch) {
2309 return strstrW(lpFirst, lpSrch);
2312 /**************************************************************************
2313 * StrSpnW [COMCTL32.364]
2316 INT WINAPI COMCTL32_StrSpnW( LPWSTR lpStr, LPWSTR lpSet) {
2317 LPWSTR lpLoop = lpStr;
2320 if ((lpStr == 0) || (lpSet == 0)) return 0;
2322 /* while(*lpLoop) { if lpLoop++; } */
2324 for(; (*lpLoop != 0); lpLoop++)
2325 if( strchrW(lpSet, *(WORD*)lpLoop))
2326 return (INT)(lpLoop-lpStr);
2328 return (INT)(lpLoop-lpStr);
2331 /**************************************************************************
2332 * COMCTL32_410 [COMCTL32.410]
2334 * FIXME: What's this supposed to do?
2335 * Parameter 1 is an HWND, you're on your own for the rest.
2338 BOOL WINAPI COMCTL32_410( HWND hw, DWORD b, DWORD c, DWORD d) {
2340 FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
2345 /**************************************************************************
2346 * COMCTL32_411 [COMCTL32.411]
2348 * FIXME: What's this supposed to do?
2349 * Parameter 1 is an HWND, you're on your own for the rest.
2352 BOOL WINAPI COMCTL32_411( HWND hw, DWORD b, DWORD c) {
2354 FIXME("(%x, %lx, %lx): stub!\n", hw, b, c);
2359 /**************************************************************************
2360 * COMCTL32_412 [COMCTL32.412]
2362 * FIXME: What's this supposed to do?
2363 * Parameter 1 is an HWND, you're on your own for the rest.
2366 BOOL WINAPI COMCTL32_412( HWND hwnd, DWORD b, DWORD c)
2368 FIXME("(%x, %lx, %lx): stub!\n", hwnd, b, c);
2370 if (IsWindow (hwnd) == FALSE)
2380 /**************************************************************************
2381 * COMCTL32_413 [COMCTL32.413]
2383 * FIXME: What's this supposed to do?
2384 * Parameter 1 is an HWND, you're on your own for the rest.
2387 BOOL WINAPI COMCTL32_413( HWND hw, DWORD b, DWORD c, DWORD d) {
2389 FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
2395 /**************************************************************************
2396 * COMCTL32_415 [COMCTL32.415]
2398 * FIXME: What's this supposed to do?
2399 * Parameter 1 is an HWND, you're on your own for the rest.
2402 BOOL WINAPI COMCTL32_415( HWND hwnd, DWORD b, DWORD c, DWORD d, DWORD e)
2405 FIXME("(%x, %lx, %lx, %lx, %lx): stub!\n", hwnd, b, c, d, e);