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 */
28 #include "wine/unicode.h"
31 #include "debugtools.h"
33 DEFAULT_DEBUG_CHANNEL(commctrl);
36 extern HANDLE COMCTL32_hHeap; /* handle to the private heap */
39 typedef struct _STREAMDATA
44 } STREAMDATA, *PSTREAMDATA;
46 typedef struct _LOADDATA
50 } LOADDATA, *LPLOADDATA;
52 typedef HRESULT CALLBACK (*DPALOADPROC)(LPLOADDATA,IStream*,LPARAM);
54 INT __cdecl _wtoi(LPWSTR string);
56 /**************************************************************************
57 * DPA_LoadStream [COMCTL32.9]
59 * Loads a dynamic pointer array from a stream
62 * phDpa [O] pointer to a handle to a dynamic pointer array
63 * loadProc [I] pointer to a callback function
64 * pStream [I] pointer to a stream
65 * lParam [I] application specific value
68 * No more information available yet!
72 DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam)
75 LARGE_INTEGER position;
76 ULARGE_INTEGER newPosition;
77 STREAMDATA streamData;
83 FIXME ("phDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
84 phDpa, loadProc, pStream, lParam);
86 if (!phDpa || !loadProc || !pStream)
91 position.s.LowPart = 0;
92 position.s.HighPart = 0;
94 errCode = IStream_Seek (pStream, position, STREAM_SEEK_CUR, &newPosition);
98 errCode = IStream_Read (pStream, &streamData, sizeof(STREAMDATA), &ulRead);
102 FIXME ("dwSize=%lu dwData2=%lu dwItems=%lu\n",
103 streamData.dwSize, streamData.dwData2, streamData.dwItems);
105 if (lParam < sizeof(STREAMDATA) ||
106 streamData.dwSize < sizeof(STREAMDATA) ||
107 streamData.dwData2 < 1) {
112 hDpa = DPA_Create (streamData.dwItems);
114 return E_OUTOFMEMORY;
116 if (!DPA_Grow (hDpa, streamData.dwItems))
117 return E_OUTOFMEMORY;
119 /* load data from the stream into the dpa */
121 for (loadData.nCount = 0; loadData.nCount < streamData.dwItems; loadData.nCount++) {
122 errCode = (loadProc)(&loadData, pStream, lParam);
123 if (errCode != S_OK) {
132 /* set the number of items */
133 hDpa->nItemCount = loadData.nCount;
135 /* store the handle to the dpa */
137 FIXME ("new hDpa=%p\n", hDpa);
143 /**************************************************************************
144 * DPA_SaveStream [COMCTL32.10]
146 * Saves a dynamic pointer array to a stream
149 * hDpa [I] handle to a dynamic pointer array
150 * loadProc [I] pointer to a callback function
151 * pStream [I] pointer to a stream
152 * lParam [I] application specific value
155 * No more information available yet!
159 DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam)
162 FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n",
163 hDpa, loadProc, pStream, lParam);
169 /**************************************************************************
170 * DPA_Merge [COMCTL32.11]
173 * hdpa1 [I] handle to a dynamic pointer array
174 * hdpa2 [I] handle to a dynamic pointer array
176 * pfnCompare [I] pointer to sort function
177 * pfnMerge [I] pointer to merge function
178 * lParam [I] application specific value
181 * No more information available yet!
185 DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags,
186 PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
189 LPVOID *pWork1, *pWork2;
193 TRACE("%p %p %08lx %p %p %08lx)\n",
194 hdpa1, hdpa2, dwFlags, pfnCompare, pfnMerge, lParam);
196 if (IsBadWritePtr (hdpa1, sizeof(DPA)))
199 if (IsBadWritePtr (hdpa2, sizeof(DPA)))
202 if (IsBadCodePtr ((FARPROC)pfnCompare))
205 if (IsBadCodePtr ((FARPROC)pfnMerge))
208 if (dwFlags & DPAM_SORT) {
209 TRACE("sorting dpa's!\n");
210 if (hdpa1->nItemCount > 0)
211 DPA_Sort (hdpa1, pfnCompare, lParam);
212 TRACE ("dpa 1 sorted!\n");
213 if (hdpa2->nItemCount > 0)
214 DPA_Sort (hdpa2, pfnCompare, lParam);
215 TRACE ("dpa 2 sorted!\n");
218 if (hdpa2->nItemCount < 1)
221 TRACE("hdpa1->nItemCount=%d hdpa2->nItemCount=%d\n",
222 hdpa1->nItemCount, hdpa2->nItemCount);
225 /* working but untrusted implementation */
227 pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]);
228 pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]);
230 nIndex = hdpa1->nItemCount - 1;
231 nCount = hdpa2->nItemCount - 1;
235 if (nIndex < 0) break;
236 nResult = (pfnCompare)(*pWork1, *pWork2, lParam);
237 TRACE("compare result=%d, dpa1.cnt=%d, dpa2.cnt=%d\n",
238 nResult, nIndex, nCount);
244 ptr = (pfnMerge)(1, *pWork1, *pWork2, lParam);
254 else if (nResult < 0)
260 ptr = DPA_DeletePtr (hdpa1, hdpa1->nItemCount - 1);
262 (pfnMerge)(2, ptr, NULL, lParam);
273 ptr = (pfnMerge)(3, *pWork2, NULL, lParam);
276 DPA_InsertPtr (hdpa1, nIndex, ptr);
289 /**************************************************************************
290 * Alloc [COMCTL32.71]
292 * Allocates memory block from the dll's private heap
295 * dwSize [I] size of the allocated memory block
298 * Success: pointer to allocated memory block
303 COMCTL32_Alloc (DWORD dwSize)
307 TRACE("(0x%lx)\n", dwSize);
309 lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
311 TRACE("-- ret=%p\n", lpPtr);
317 /**************************************************************************
318 * ReAlloc [COMCTL32.72]
320 * Changes the size of an allocated memory block or allocates a memory
321 * block using the dll's private heap.
324 * lpSrc [I] pointer to memory block which will be resized
325 * dwSize [I] new size of the memory block.
328 * Success: pointer to the resized memory block
332 * If lpSrc is a NULL-pointer, then COMCTL32_ReAlloc allocates a memory
333 * block like COMCTL32_Alloc.
337 COMCTL32_ReAlloc (LPVOID lpSrc, DWORD dwSize)
341 TRACE("(%p 0x%08lx)\n", lpSrc, dwSize);
344 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
346 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
348 TRACE("-- ret=%p\n", lpDest);
354 /**************************************************************************
357 * Frees an allocated memory block from the dll's private heap.
360 * lpMem [I] pointer to memory block which will be freed
368 COMCTL32_Free (LPVOID lpMem)
370 TRACE("(%p)\n", lpMem);
372 return HeapFree (COMCTL32_hHeap, 0, lpMem);
376 /**************************************************************************
377 * GetSize [COMCTL32.74]
379 * Retrieves the size of the specified memory block from the dll's
383 * lpMem [I] pointer to an allocated memory block
386 * Success: size of the specified memory block
391 COMCTL32_GetSize (LPVOID lpMem)
393 TRACE("(%p)\n", lpMem);
395 return HeapSize (COMCTL32_hHeap, 0, lpMem);
399 /**************************************************************************
400 * The MRU-API is a set of functions to manipulate MRU(Most Recently Used)
403 * Stored in the reg. as a set of values under a single key. Each item in the
404 * list has a value name that is a single char. 'a' - 'z', '{', '|' or '}'.
405 * The order of the list is stored with value name 'MRUList' which is a string
406 * containing the value names (i.e. 'a', 'b', etc.) in the relevant order.
409 typedef struct tagCREATEMRULIST
411 DWORD cbSize; /* size of struct */
412 DWORD nMaxItems; /* max no. of items in list */
413 DWORD dwFlags; /* see below */
414 HKEY hKey; /* root reg. key under which list is saved */
415 LPCSTR lpszSubKey; /* reg. subkey */
416 PROC lpfnCompare; /* item compare proc */
417 } CREATEMRULIST, *LPCREATEMRULIST;
420 #define MRUF_STRING_LIST 0 /* list will contain strings */
421 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
422 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
424 /* If list is a string list lpfnCompare has the following prototype
425 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
426 * for binary lists the prototype is
427 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
428 * where cbData is the no. of bytes to compare.
429 * Need to check what return value means identical - 0?
432 typedef struct tagMRU
434 DWORD dwParam1; /* some kind of flag */
443 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
444 DWORD dwParam3, DWORD dwParam4);
447 /**************************************************************************
448 * CreateMRUListA [COMCTL32.151]
451 * lpcml [I] ptr to CREATEMRULIST structure.
454 * Handle to MRU list.
457 CreateMRUListA (LPCREATEMRULIST lpcml)
459 return CreateMRUListLazyA (lpcml, 0, 0, 0);
462 /**************************************************************************
463 * FreeMRUList [COMCTL32.152]
466 * hMRUList [I] Handle to list.
470 FreeMRUListA (HANDLE hMRUList)
472 FIXME("(%08x) empty stub!\n", hMRUList);
475 if (!(hmru->dwParam1 & 1001)) {
476 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
478 strlen (hmru->lpszMRUString));
482 RegClosKey (hmru->hkeyMRU
483 COMCTL32_Free32 (hmru->lpszMRUString);
486 return COMCTL32_Free ((LPVOID)hMRUList);
490 /**************************************************************************
491 * AddMRUData [COMCTL32.167]
493 * Add item to MRU binary list. If item already exists in list then it is
494 * simply moved up to the top of the list and not added again. If list is
495 * full then the least recently used item is removed to make room.
498 * hList [I] Handle to list.
499 * lpData [I] ptr to data to add.
500 * cbData [I] no. of bytes of data.
503 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
507 AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData)
509 FIXME("(%08x, %p, %ld) empty stub!\n", hList, lpData, cbData);
514 /**************************************************************************
515 * AddMRUStringA [COMCTL32.153]
517 * Add item to MRU string list. If item already exists in list them it is
518 * simply moved up to the top of the list and not added again. If list is
519 * full then the least recently used item is removed to make room.
522 * hList [I] Handle to list.
523 * lpszString [I] ptr to string to add.
526 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
530 AddMRUStringA(HANDLE hList, LPCSTR lpszString)
532 FIXME("(%08x, %s) empty stub!\n", hList, debugstr_a(lpszString));
537 /**************************************************************************
538 * DelMRUString [COMCTL32.156]
540 * Removes item from either string or binary list (despite its name)
543 * hList [I] list handle
544 * nItemPos [I] item position to remove 0 -> MRU
547 * TRUE if successful, FALSE if nItemPos is out of range.
550 DelMRUString(HANDLE hList, INT nItemPos)
552 FIXME("(%08x, %d): stub\n", hList, nItemPos);
556 /**************************************************************************
557 * FindMRUData [COMCTL32.169]
559 * Searches binary list for item that matches lpData of length cbData.
560 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
561 * corresponding to item's reg. name will be stored in it ('a' -> 0).
564 * hList [I] list handle
565 * lpData [I] data to find
566 * cbData [I] length of data
567 * lpRegNum [O] position in registry (maybe NULL)
570 * Position in list 0 -> MRU. -1 if item not found.
573 FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum)
575 FIXME("(%08x, %p, %ld, %p) empty stub!\n",
576 hList, lpData, cbData, lpRegNum);
581 /**************************************************************************
582 * FindMRUStringA [COMCTL32.155]
584 * Searches string list for item that matches lpszString.
585 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
586 * corresponding to item's reg. name will be stored in it ('a' -> 0).
589 * hList [I] list handle
590 * lpszString [I] string to find
591 * lpRegNum [O] position in registry (maybe NULL)
594 * Position in list 0 -> MRU. -1 if item not found.
597 FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum)
599 FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString),
605 /**************************************************************************
606 * CreateMRUListLazyA [COMCTL32.157]
609 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
618 * DWORD dwDisposition; */
620 /* internal variables */
623 FIXME("(%p) empty stub!\n", lpcml);
628 if (lpcml->cbSize < sizeof(CREATEMRULIST))
631 FIXME("(%lu %lu %lx %lx \"%s\" %p)\n",
632 lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
633 (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
635 /* dummy pointer creation */
636 ptr = COMCTL32_Alloc (32);
638 FIXME("-- ret = %p\n", ptr);
643 /**************************************************************************
644 * EnumMRUListA [COMCTL32.154]
646 * Enumerate item in a list
649 * hList [I] list handle
650 * nItemPos [I] item position to enumerate
651 * lpBuffer [O] buffer to receive item
652 * nBufferSize [I] size of buffer
655 * For binary lists specifies how many bytes were copied to buffer, for
656 * string lists specifies full length of string. Enumerating past the end
657 * of list returns -1.
658 * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
661 INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
664 FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer,
669 /**************************************************************************
670 * Str_GetPtrA [COMCTL32.233]
681 Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen)
685 TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
687 if (!lpDest && lpSrc)
688 return strlen (lpSrc);
698 len = strlen (lpSrc);
702 RtlMoveMemory (lpDest, lpSrc, len);
709 /**************************************************************************
710 * Str_SetPtrA [COMCTL32.234]
720 Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc)
722 TRACE("(%p %p)\n", lppDest, lpSrc);
725 LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
733 COMCTL32_Free (*lppDest);
742 /**************************************************************************
743 * Str_GetPtrW [COMCTL32.235]
754 Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
758 TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
760 if (!lpDest && lpSrc)
761 return strlenW (lpSrc);
771 len = strlenW (lpSrc);
775 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
782 /**************************************************************************
783 * Str_SetPtrW [COMCTL32.236]
793 Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc)
795 TRACE("(%p %p)\n", lppDest, lpSrc);
798 INT len = strlenW (lpSrc) + 1;
799 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
802 strcpyW (ptr, lpSrc);
807 COMCTL32_Free (*lppDest);
816 /**************************************************************************
817 * Str_GetPtrWtoA [internal]
819 * Converts a unicode string into a multi byte string
822 * lpSrc [I] Pointer to the unicode source string
823 * lpDest [O] Pointer to caller supplied storage for the multi byte string
824 * nMaxLen [I] Size, in bytes, of the destination buffer
827 * Length, in bytes, of the converted string.
831 Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen)
835 TRACE("(%s %p %d)\n", debugstr_w(lpSrc), lpDest, nMaxLen);
837 if (!lpDest && lpSrc)
838 return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
848 len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
852 WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL);
859 /**************************************************************************
860 * Str_SetPtrAtoW [internal]
862 * Converts a multi byte string to a unicode string.
863 * If the pointer to the destination buffer is NULL a buffer is allocated.
864 * If the destination buffer is too small to keep the converted multi byte
865 * string the destination buffer is reallocated. If the source pointer is
866 * NULL, the destination buffer is freed.
869 * lppDest [I/O] pointer to a pointer to the destination buffer
870 * lpSrc [I] pointer to a multi byte string
873 * TRUE: conversion successful
878 Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc)
880 TRACE("(%p %s)\n", lppDest, lpSrc);
883 INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0);
884 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR));
888 MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len);
893 COMCTL32_Free (*lppDest);
902 /**************************************************************************
903 * The DSA-API is a set of functions to create and manipulate arrays of
904 * fixed-size memory blocks. These arrays can store any kind of data
905 * (strings, icons...).
908 /**************************************************************************
909 * DSA_Create [COMCTL32.320] Creates a dynamic storage array
912 * nSize [I] size of the array elements
913 * nGrow [I] number of elements by which the array grows when it is filled
916 * Success: pointer to an array control structure. Use this like a handle.
921 DSA_Create (INT nSize, INT nGrow)
925 TRACE("(size=%d grow=%d)\n", nSize, nGrow);
927 hdsa = (HDSA)COMCTL32_Alloc (sizeof(DSA));
930 hdsa->nItemCount = 0;
933 hdsa->nItemSize = nSize;
934 hdsa->nGrow = max(1, nGrow);
941 /**************************************************************************
942 * DSA_Destroy [COMCTL32.321] Destroys a dynamic storage array
945 * hdsa [I] pointer to the array control structure
953 DSA_Destroy (const HDSA hdsa)
955 TRACE("(%p)\n", hdsa);
960 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
963 return COMCTL32_Free (hdsa);
967 /**************************************************************************
968 * DSA_GetItem [COMCTL32.322]
971 * hdsa [I] pointer to the array control structure
972 * nIndex [I] number of the Item to get
973 * pDest [O] destination buffer. Has to be >= dwElementSize.
981 DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest)
985 TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
989 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
992 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
993 memmove (pDest, pSrc, hdsa->nItemSize);
999 /**************************************************************************
1000 * DSA_GetItemPtr [COMCTL32.323]
1002 * Retrieves a pointer to the specified item.
1005 * hdsa [I] pointer to the array control structure
1006 * nIndex [I] index of the desired item
1009 * Success: pointer to an item
1014 DSA_GetItemPtr (const HDSA hdsa, INT nIndex)
1018 TRACE("(%p %d)\n", hdsa, nIndex);
1022 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
1025 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1027 TRACE("-- ret=%p\n", pSrc);
1033 /**************************************************************************
1034 * DSA_SetItem [COMCTL32.325]
1036 * Sets the contents of an item in the array.
1039 * hdsa [I] pointer to the array control structure
1040 * nIndex [I] index for the item
1041 * pSrc [I] pointer to the new item data
1049 DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
1051 INT nSize, nNewItems;
1052 LPVOID pDest, lpTemp;
1054 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
1056 if ((!hdsa) || nIndex < 0)
1059 if (hdsa->nItemCount <= nIndex) {
1060 /* within the old array */
1061 if (hdsa->nMaxCount > nIndex) {
1062 /* within the allocated space, set a new boundary */
1063 hdsa->nItemCount = nIndex + 1;
1066 /* resize the block of memory */
1068 hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
1069 nSize = hdsa->nItemSize * nNewItems;
1071 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1075 hdsa->nMaxCount = nNewItems;
1076 hdsa->nItemCount = nIndex + 1;
1077 hdsa->pData = lpTemp;
1081 /* put the new entry in */
1082 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1083 TRACE("-- move dest=%p src=%p size=%d\n",
1084 pDest, pSrc, hdsa->nItemSize);
1085 memmove (pDest, pSrc, hdsa->nItemSize);
1091 /**************************************************************************
1092 * DSA_InsertItem [COMCTL32.324]
1095 * hdsa [I] pointer to the array control structure
1096 * nIndex [I] index for the new item
1097 * pSrc [I] pointer to the element
1100 * Success: position of the new item
1105 DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
1107 INT nNewItems, nSize, i;
1108 LPVOID lpTemp, lpDest;
1111 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
1113 if ((!hdsa) || nIndex < 0)
1116 for (i = 0; i < hdsa->nItemSize; i += 4) {
1117 p = *(DWORD**)((char *) pSrc + i);
1118 if (IsBadStringPtrA ((char*)p, 256))
1119 TRACE("-- %d=%p\n", i, (DWORD*)p);
1121 TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
1124 /* when nIndex >= nItemCount then append */
1125 if (nIndex >= hdsa->nItemCount)
1126 nIndex = hdsa->nItemCount;
1128 /* do we need to resize ? */
1129 if (hdsa->nItemCount >= hdsa->nMaxCount) {
1130 nNewItems = hdsa->nMaxCount + hdsa->nGrow;
1131 nSize = hdsa->nItemSize * nNewItems;
1133 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1137 hdsa->nMaxCount = nNewItems;
1138 hdsa->pData = lpTemp;
1141 /* do we need to move elements ? */
1142 if (nIndex < hdsa->nItemCount) {
1143 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1144 lpDest = (char *) lpTemp + hdsa->nItemSize;
1145 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
1146 TRACE("-- move dest=%p src=%p size=%d\n",
1147 lpDest, lpTemp, nSize);
1148 memmove (lpDest, lpTemp, nSize);
1151 /* ok, we can put the new Item in */
1153 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1154 TRACE("-- move dest=%p src=%p size=%d\n",
1155 lpDest, pSrc, hdsa->nItemSize);
1156 memmove (lpDest, pSrc, hdsa->nItemSize);
1162 /**************************************************************************
1163 * DSA_DeleteItem [COMCTL32.326]
1166 * hdsa [I] pointer to the array control structure
1167 * nIndex [I] index for the element to delete
1170 * Success: number of the deleted element
1175 DSA_DeleteItem (const HDSA hdsa, INT nIndex)
1177 LPVOID lpDest,lpSrc;
1180 TRACE("(%p %d)\n", hdsa, nIndex);
1184 if (nIndex < 0 || nIndex >= hdsa->nItemCount)
1187 /* do we need to move ? */
1188 if (nIndex < hdsa->nItemCount - 1) {
1189 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1190 lpSrc = (char *) lpDest + hdsa->nItemSize;
1191 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
1192 TRACE("-- move dest=%p src=%p size=%d\n",
1193 lpDest, lpSrc, nSize);
1194 memmove (lpDest, lpSrc, nSize);
1200 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
1201 nSize = hdsa->nItemSize * hdsa->nItemCount;
1203 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1207 hdsa->nMaxCount = hdsa->nItemCount;
1208 hdsa->pData = lpDest;
1215 /**************************************************************************
1216 * DSA_DeleteAllItems [COMCTL32.327]
1218 * Removes all items and reinitializes the array.
1221 * hdsa [I] pointer to the array control structure
1229 DSA_DeleteAllItems (const HDSA hdsa)
1231 TRACE("(%p)\n", hdsa);
1235 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
1238 hdsa->nItemCount = 0;
1240 hdsa->nMaxCount = 0;
1246 /**************************************************************************
1247 * The DPA-API is a set of functions to create and manipulate arrays of
1251 /**************************************************************************
1252 * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
1255 * nGrow [I] number of items by which the array grows when it is filled
1258 * Success: handle (pointer) to the pointer array.
1263 DPA_Create (INT nGrow)
1267 TRACE("(%d)\n", nGrow);
1269 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1271 hdpa->nGrow = max(8, nGrow);
1272 hdpa->hHeap = COMCTL32_hHeap;
1273 hdpa->nMaxCount = hdpa->nGrow * 2;
1275 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
1278 TRACE("-- %p\n", hdpa);
1284 /**************************************************************************
1285 * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
1288 * hdpa [I] handle (pointer) to the pointer array
1296 DPA_Destroy (const HDPA hdpa)
1298 TRACE("(%p)\n", hdpa);
1303 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1306 return HeapFree (hdpa->hHeap, 0, hdpa);
1310 /**************************************************************************
1311 * DPA_Grow [COMCTL32.330]
1313 * Sets the growth amount.
1316 * hdpa [I] handle (pointer) to the existing (source) pointer array
1317 * nGrow [I] number of items by which the array grows when it's too small
1325 DPA_Grow (const HDPA hdpa, INT nGrow)
1327 TRACE("(%p %d)\n", hdpa, nGrow);
1332 hdpa->nGrow = max(8, nGrow);
1338 /**************************************************************************
1339 * DPA_Clone [COMCTL32.331]
1341 * Copies a pointer array to an other one or creates a copy
1344 * hdpa [I] handle (pointer) to the existing (source) pointer array
1345 * hdpaNew [O] handle (pointer) to the destination pointer array
1348 * Success: pointer to the destination pointer array.
1352 * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer
1353 * array will be created and it's handle (pointer) is returned.
1354 * - If 'hdpa' is a NULL-Pointer, the original implementation crashes,
1355 * this implementation just returns NULL.
1359 DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
1361 INT nNewItems, nSize;
1367 TRACE("(%p %p)\n", hdpa, hdpaNew);
1370 /* create a new DPA */
1371 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1373 hdpaTemp->hHeap = hdpa->hHeap;
1374 hdpaTemp->nGrow = hdpa->nGrow;
1379 if (hdpaTemp->ptrs) {
1380 /* remove old pointer array */
1381 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
1382 hdpaTemp->ptrs = NULL;
1383 hdpaTemp->nItemCount = 0;
1384 hdpaTemp->nMaxCount = 0;
1387 /* create a new pointer array */
1388 nNewItems = hdpaTemp->nGrow *
1389 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
1390 nSize = nNewItems * sizeof(LPVOID);
1392 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
1393 hdpaTemp->nMaxCount = nNewItems;
1395 /* clone the pointer array */
1396 hdpaTemp->nItemCount = hdpa->nItemCount;
1397 memmove (hdpaTemp->ptrs, hdpa->ptrs,
1398 hdpaTemp->nItemCount * sizeof(LPVOID));
1404 /**************************************************************************
1405 * DPA_GetPtr [COMCTL32.332]
1407 * Retrieves a pointer from a dynamic pointer array
1410 * hdpa [I] handle (pointer) to the pointer array
1411 * nIndex [I] array index of the desired pointer
1419 DPA_GetPtr (const HDPA hdpa, INT i)
1421 TRACE("(%p %d)\n", hdpa, i);
1426 WARN("no pointer array.\n");
1429 if ((i < 0) || (i >= hdpa->nItemCount)) {
1430 WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
1434 TRACE("-- %p\n", hdpa->ptrs[i]);
1436 return hdpa->ptrs[i];
1440 /**************************************************************************
1441 * DPA_GetPtrIndex [COMCTL32.333]
1443 * Retrieves the index of the specified pointer
1446 * hdpa [I] handle (pointer) to the pointer array
1450 * Success: index of the specified pointer
1455 DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
1462 for (i = 0; i < hdpa->nItemCount; i++) {
1463 if (hdpa->ptrs[i] == p)
1471 /**************************************************************************
1472 * DPA_InsertPtr [COMCTL32.334]
1474 * Inserts a pointer into a dynamic pointer array
1477 * hdpa [I] handle (pointer) to the array
1479 * p [I] pointer to insert
1482 * Success: index of the inserted pointer
1487 DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
1489 INT nNewItems, nSize, nIndex = 0;
1490 LPVOID *lpTemp, *lpDest;
1492 TRACE("(%p %d %p)\n", hdpa, i, p);
1494 if ((!hdpa) || (i < 0))
1499 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1500 2 * hdpa->nGrow * sizeof(LPVOID));
1503 hdpa->nMaxCount = hdpa->nGrow * 2;
1507 if (hdpa->nItemCount >= hdpa->nMaxCount) {
1508 TRACE("-- resizing\n");
1509 nNewItems = hdpa->nMaxCount + hdpa->nGrow;
1510 nSize = nNewItems * sizeof(LPVOID);
1512 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1516 hdpa->nMaxCount = nNewItems;
1517 hdpa->ptrs = lpTemp;
1520 if (i >= hdpa->nItemCount) {
1521 nIndex = hdpa->nItemCount;
1522 TRACE("-- appending at %d\n", nIndex);
1525 TRACE("-- inserting at %d\n", i);
1526 lpTemp = hdpa->ptrs + i;
1527 lpDest = lpTemp + 1;
1528 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID);
1529 TRACE("-- move dest=%p src=%p size=%x\n",
1530 lpDest, lpTemp, nSize);
1531 memmove (lpDest, lpTemp, nSize);
1538 hdpa->ptrs[nIndex] = p;
1544 /**************************************************************************
1545 * DPA_SetPtr [COMCTL32.335]
1547 * Sets a pointer in the pointer array
1550 * hdpa [I] handle (pointer) to the pointer array
1551 * i [I] index of the pointer that will be set
1552 * p [I] pointer to be set
1560 DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
1564 TRACE("(%p %d %p)\n", hdpa, i, p);
1566 if ((!hdpa) || i < 0)
1569 if (hdpa->nItemCount <= i) {
1570 /* within the old array */
1571 if (hdpa->nMaxCount > i) {
1572 /* within the allocated space, set a new boundary */
1573 hdpa->nItemCount = i+1;
1576 /* resize the block of memory */
1578 hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
1579 INT nSize = nNewItems * sizeof(LPVOID);
1581 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1586 hdpa->nItemCount = nNewItems;
1587 hdpa->ptrs = lpTemp;
1591 /* put the new entry in */
1598 /**************************************************************************
1599 * DPA_DeletePtr [COMCTL32.336]
1601 * Removes a pointer from the pointer array.
1604 * hdpa [I] handle (pointer) to the pointer array
1605 * i [I] index of the pointer that will be deleted
1608 * Success: deleted pointer
1613 DPA_DeletePtr (const HDPA hdpa, INT i)
1615 LPVOID *lpDest, *lpSrc, lpTemp = NULL;
1618 TRACE("(%p %d)\n", hdpa, i);
1620 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
1623 lpTemp = hdpa->ptrs[i];
1625 /* do we need to move ?*/
1626 if (i < hdpa->nItemCount - 1) {
1627 lpDest = hdpa->ptrs + i;
1629 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
1630 TRACE("-- move dest=%p src=%p size=%x\n",
1631 lpDest, lpSrc, nSize);
1632 memmove (lpDest, lpSrc, nSize);
1635 hdpa->nItemCount --;
1638 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
1639 INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
1640 nSize = nNewItems * sizeof(LPVOID);
1641 lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1646 hdpa->nMaxCount = nNewItems;
1647 hdpa->ptrs = (LPVOID*)lpDest;
1654 /**************************************************************************
1655 * DPA_DeleteAllPtrs [COMCTL32.337]
1657 * Removes all pointers and reinitializes the array.
1660 * hdpa [I] handle (pointer) to the pointer array
1668 DPA_DeleteAllPtrs (const HDPA hdpa)
1670 TRACE("(%p)\n", hdpa);
1675 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1678 hdpa->nItemCount = 0;
1679 hdpa->nMaxCount = hdpa->nGrow * 2;
1680 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1681 hdpa->nMaxCount * sizeof(LPVOID));
1687 /**************************************************************************
1688 * DPA_QuickSort [Internal]
1690 * Ordinary quicksort (used by DPA_Sort).
1693 * lpPtrs [I] pointer to the pointer array
1694 * l [I] index of the "left border" of the partition
1695 * r [I] index of the "right border" of the partition
1696 * pfnCompare [I] pointer to the compare function
1697 * lParam [I] user defined value (3rd parameter in compare function)
1704 DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
1705 PFNDPACOMPARE pfnCompare, LPARAM lParam)
1710 TRACE("l=%i r=%i\n", l, r);
1712 if (l==r) /* one element is always sorted */
1714 if (r<l) /* oops, got it in the wrong order */
1716 DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam);
1719 m = (l+r)/2; /* divide by two */
1720 DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam);
1721 DPA_QuickSort(lpPtrs, m+1, r, pfnCompare, lParam);
1723 /* join the two sides */
1724 while( (l<=m) && (m<r) )
1726 if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0)
1729 memmove(&lpPtrs[l+1],&lpPtrs[l],(m-l+1)*sizeof lpPtrs[l]);
1739 /**************************************************************************
1740 * DPA_Sort [COMCTL32.338]
1742 * Sorts a pointer array using a user defined compare function
1745 * hdpa [I] handle (pointer) to the pointer array
1746 * pfnCompare [I] pointer to the compare function
1747 * lParam [I] user defined value (3rd parameter of compare function)
1755 DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
1757 if (!hdpa || !pfnCompare)
1760 TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
1762 if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
1763 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
1764 pfnCompare, lParam);
1770 /**************************************************************************
1771 * DPA_Search [COMCTL32.339]
1773 * Searches a pointer array for a specified pointer
1776 * hdpa [I] handle (pointer) to the pointer array
1777 * pFind [I] pointer to search for
1778 * nStart [I] start index
1779 * pfnCompare [I] pointer to the compare function
1780 * lParam [I] user defined value (3rd parameter of compare function)
1781 * uOptions [I] search options
1784 * Success: index of the pointer in the array.
1788 * Binary search taken from R.Sedgewick "Algorithms in C"!
1789 * Function is NOT tested!
1790 * If something goes wrong, blame HIM not ME! (Eric Kohl)
1794 DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
1795 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
1797 if (!hdpa || !pfnCompare || !pFind)
1800 TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n",
1801 hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
1803 if (uOptions & DPAS_SORTED) {
1804 /* array is sorted --> use binary search */
1808 TRACE("binary search\n");
1810 l = (nStart == -1) ? 0 : nStart;
1811 r = hdpa->nItemCount - 1;
1815 n = (pfnCompare)(pFind, lpPtr[x], lParam);
1821 TRACE("-- ret=%d\n", n);
1826 if (uOptions & DPAS_INSERTBEFORE) {
1827 TRACE("-- ret=%d\n", r);
1831 if (uOptions & DPAS_INSERTAFTER) {
1832 TRACE("-- ret=%d\n", l);
1837 /* array is not sorted --> use linear search */
1841 TRACE("linear search\n");
1843 nIndex = (nStart == -1)? 0 : nStart;
1845 for (; nIndex < hdpa->nItemCount; nIndex++) {
1846 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
1847 TRACE("-- ret=%d\n", nIndex);
1853 TRACE("-- not found: ret=-1\n");
1858 /**************************************************************************
1859 * DPA_CreateEx [COMCTL32.340]
1861 * Creates a dynamic pointer array using the specified size and heap.
1864 * nGrow [I] number of items by which the array grows when it is filled
1865 * hHeap [I] handle to the heap where the array is stored
1868 * Success: handle (pointer) to the pointer array.
1873 DPA_CreateEx (INT nGrow, HANDLE hHeap)
1877 TRACE("(%d 0x%x)\n", nGrow, hHeap);
1880 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
1882 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1885 hdpa->nGrow = min(8, nGrow);
1886 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
1887 hdpa->nMaxCount = hdpa->nGrow * 2;
1889 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
1890 hdpa->nMaxCount * sizeof(LPVOID));
1893 TRACE("-- %p\n", hdpa);
1899 /**************************************************************************
1900 * Notification functions
1903 typedef struct tagNOTIFYDATA
1911 } NOTIFYDATA, *LPNOTIFYDATA;
1914 /**************************************************************************
1915 * DoNotify [Internal]
1919 DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr)
1922 LPNMHDR lpNmh = NULL;
1925 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
1926 lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
1927 lpNotify->dwParam5);
1929 if (!lpNotify->hwndTo)
1932 if (lpNotify->hwndFrom == -1) {
1934 idFrom = lpHdr->idFrom;
1937 if (lpNotify->hwndFrom) {
1938 HWND hwndParent = GetParent (lpNotify->hwndFrom);
1940 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
1942 idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
1946 lpNmh = (lpHdr) ? lpHdr : &nmhdr;
1948 lpNmh->hwndFrom = lpNotify->hwndFrom;
1949 lpNmh->idFrom = idFrom;
1950 lpNmh->code = uCode;
1953 return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh);
1957 /**************************************************************************
1958 * SendNotify [COMCTL32.341]
1967 * Success: return value from notification
1972 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
1973 UINT uCode, LPNMHDR lpHdr)
1977 TRACE("(0x%04x 0x%04x %d %p)\n",
1978 hwndFrom, hwndTo, uCode, lpHdr);
1980 notify.hwndFrom = hwndFrom;
1981 notify.hwndTo = hwndTo;
1982 notify.dwParam5 = 0;
1983 notify.dwParam6 = 0;
1985 return DoNotify (¬ify, uCode, lpHdr);
1989 /**************************************************************************
1990 * SendNotifyEx [COMCTL32.342]
2000 * Success: return value from notification
2005 COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
2006 LPNMHDR lpHdr, DWORD dwParam5)
2011 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
2012 hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
2014 hwndNotify = hwndTo;
2016 if (IsWindow (hwndFrom)) {
2017 hwndNotify = GetParent (hwndFrom);
2023 notify.hwndFrom = hwndFrom;
2024 notify.hwndTo = hwndNotify;
2025 notify.dwParam5 = dwParam5;
2026 notify.dwParam6 = 0;
2028 return DoNotify (¬ify, uCode, lpHdr);
2032 /**************************************************************************
2033 * StrChrA [COMCTL32.350]
2038 COMCTL32_StrChrA (LPCSTR lpString, CHAR cChar)
2040 return strchr (lpString, cChar);
2044 /**************************************************************************
2045 * StrStrIA [COMCTL32.355]
2049 COMCTL32_StrStrIA (LPCSTR lpStr1, LPCSTR lpStr2)
2055 return ((LPSTR)lpStr1);
2057 while (lpStr1[len1] != 0) ++len1;
2059 while (lpStr2[len2] != 0) ++len2;
2061 return ((LPSTR)(lpStr1 + len1));
2062 first = tolower (*lpStr2);
2063 while (len1 >= len2) {
2064 if (tolower(*lpStr1) == first) {
2065 for (i = 1; i < len2; ++i)
2066 if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
2069 return ((LPSTR)lpStr1);
2077 /**************************************************************************
2078 * StrToIntA [COMCTL32.357] Converts a string to a signed integer.
2082 COMCTL32_StrToIntA (LPSTR lpString)
2084 return atoi(lpString);
2087 /**************************************************************************
2088 * StrToIntW [COMCTL32.365] Converts a wide char string to a signed integer.
2092 COMCTL32_StrToIntW (LPWSTR lpString)
2094 return _wtoi(lpString);
2098 /**************************************************************************
2099 * DPA_EnumCallback [COMCTL32.385]
2101 * Enumerates all items in a dynamic pointer array.
2104 * hdpa [I] handle to the dynamic pointer array
2113 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2117 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
2121 if (hdpa->nItemCount <= 0)
2124 for (i = 0; i < hdpa->nItemCount; i++) {
2125 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
2133 /**************************************************************************
2134 * DPA_DestroyCallback [COMCTL32.386]
2136 * Enumerates all items in a dynamic pointer array and destroys it.
2139 * hdpa [I] handle to the dynamic pointer array
2149 DPA_DestroyCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2151 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
2153 DPA_EnumCallback (hdpa, enumProc, lParam);
2155 return DPA_Destroy (hdpa);
2159 /**************************************************************************
2160 * DSA_EnumCallback [COMCTL32.387]
2162 * Enumerates all items in a dynamic storage array.
2165 * hdsa [I] handle to the dynamic storage array
2174 DSA_EnumCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2178 TRACE("(%p %p %08lx)\n", hdsa, enumProc, lParam);
2182 if (hdsa->nItemCount <= 0)
2185 for (i = 0; i < hdsa->nItemCount; i++) {
2186 LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
2187 if ((enumProc)(lpItem, lParam) == 0)
2195 /**************************************************************************
2196 * DSA_DestroyCallback [COMCTL32.388]
2198 * Enumerates all items in a dynamic storage array and destroys it.
2201 * hdsa [I] handle to the dynamic storage array
2211 DSA_DestroyCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2213 TRACE("(%p %p %08lx)\n", hdsa, enumProc, lParam);
2215 DSA_EnumCallback (hdsa, enumProc, lParam);
2217 return DSA_Destroy (hdsa);
2220 /**************************************************************************
2221 * StrCSpnA [COMCTL32.356]
2224 INT WINAPI COMCTL32_StrCSpnA( LPCSTR lpStr, LPCSTR lpSet) {
2225 return strcspn(lpStr, lpSet);
2228 /**************************************************************************
2229 * StrChrW [COMCTL32.358]
2232 LPWSTR WINAPI COMCTL32_StrChrW( LPCWSTR lpStart, WORD wMatch) {
2233 return strchrW(lpStart, wMatch);
2236 /**************************************************************************
2237 * StrCmpNA [COMCTL32.352]
2240 INT WINAPI COMCTL32_StrCmpNA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
2241 return strncmp(lpStr1, lpStr2, nChar);
2244 /**************************************************************************
2245 * StrCmpNIA [COMCTL32.353]
2248 INT WINAPI COMCTL32_StrCmpNIA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
2249 return strncasecmp(lpStr1, lpStr2, nChar);
2252 /**************************************************************************
2253 * StrCmpNW [COMCTL32.360]
2256 INT WINAPI COMCTL32_StrCmpNW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
2257 return strncmpW(lpStr1, lpStr2, nChar);
2260 /**************************************************************************
2261 * StrCmpNIW [COMCTL32.361]
2264 INT WINAPI COMCTL32_StrCmpNIW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
2265 FIXME("(%s, %s, %i): stub\n", debugstr_w(lpStr1), debugstr_w(lpStr2), nChar);
2269 /**************************************************************************
2270 * StrRChrA [COMCTL32.351]
2273 LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
2275 LPCSTR lpGotIt = NULL;
2276 BOOL dbcs = IsDBCSLeadByte( LOBYTE(wMatch) );
2278 TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
2280 if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
2282 for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
2284 if (*lpStart != LOBYTE(wMatch)) continue;
2285 if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
2288 return (LPSTR)lpGotIt;
2292 /**************************************************************************
2293 * StrRChrW [COMCTL32.359]
2296 LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
2298 LPCWSTR lpGotIt = NULL;
2300 TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
2301 if (!lpEnd) lpEnd = lpStart + strlenW(lpStart);
2303 for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
2304 if (*lpStart == wMatch) lpGotIt = lpStart;
2306 return (LPWSTR)lpGotIt;
2310 /**************************************************************************
2311 * StrStrA [COMCTL32.354]
2314 LPSTR WINAPI COMCTL32_StrStrA( LPCSTR lpFirst, LPCSTR lpSrch) {
2315 return strstr(lpFirst, lpSrch);
2318 /**************************************************************************
2319 * StrStrW [COMCTL32.362]
2322 LPWSTR WINAPI COMCTL32_StrStrW( LPCWSTR lpFirst, LPCWSTR lpSrch) {
2323 return strstrW(lpFirst, lpSrch);
2326 /**************************************************************************
2327 * StrSpnW [COMCTL32.364]
2330 INT WINAPI COMCTL32_StrSpnW( LPWSTR lpStr, LPWSTR lpSet) {
2331 LPWSTR lpLoop = lpStr;
2334 if ((lpStr == 0) || (lpSet == 0)) return 0;
2336 /* while(*lpLoop) { if lpLoop++; } */
2338 for(; (*lpLoop != 0); lpLoop++)
2339 if( strchrW(lpSet, *(WORD*)lpLoop))
2340 return (INT)(lpLoop-lpStr);
2342 return (INT)(lpLoop-lpStr);
2345 /**************************************************************************
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_410( HWND hw, DWORD b, DWORD c, DWORD d) {
2354 FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
2359 /**************************************************************************
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_411( HWND hw, DWORD b, DWORD c) {
2368 FIXME("(%x, %lx, %lx): stub!\n", hw, b, c);
2373 /**************************************************************************
2376 * FIXME: What's this supposed to do?
2377 * Parameter 1 is an HWND, you're on your own for the rest.
2380 BOOL WINAPI COMCTL32_412( HWND hwnd, DWORD b, DWORD c)
2382 FIXME("(%x, %lx, %lx): stub!\n", hwnd, b, c);
2384 if (IsWindow (hwnd) == FALSE)
2394 /**************************************************************************
2397 * FIXME: What's this supposed to do?
2398 * Parameter 1 is an HWND, you're on your own for the rest.
2401 BOOL WINAPI COMCTL32_413( HWND hw, DWORD b, DWORD c, DWORD d) {
2403 FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
2409 /**************************************************************************
2412 * FIXME: What's this supposed to do?
2413 * Parameter 1 is an HWND, you're on your own for the rest.
2416 BOOL WINAPI COMCTL32_415( HWND hwnd, DWORD b, DWORD c, DWORD d, DWORD e)
2419 FIXME("(%x, %lx, %lx, %lx, %lx): stub!\n", hwnd, b, c, d, e);