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 * pfnSort [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)
186 #if 0 /* these go with the "incomplete implementation" below */
187 LPVOID pWork1, pWork2;
193 TRACE("(%p %p %08lx %p %p %08lx): semi stub!\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 /* preliminary hack - simply append the pointer list hdpa2 to hdpa1 */
226 for (nCount = 0; nCount < hdpa2->nItemCount; nCount++)
227 DPA_InsertPtr (hdpa1, hdpa1->nItemCount + 1, hdpa2->ptrs[nCount]);
230 /* incomplete implementation */
232 pWork1 = &(hdpa1->ptrs[hdpa1->nItemCount - 1]);
233 pWork2 = &(hdpa2->ptrs[hdpa2->nItemCount - 1]);
235 nIndex = hdpa1->nItemCount - 1;
236 nCount = hdpa2->nItemCount - 1;
240 nResult = (pfnCompare)(pWork1, pWork2, lParam);
246 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);
271 ptr = (pfnMerge)(3, pWork2, NULL, lParam);
274 DPA_InsertPtr (hdpa1, nIndex, ptr);
291 /**************************************************************************
292 * Alloc [COMCTL32.71]
294 * Allocates memory block from the dll's private heap
297 * dwSize [I] size of the allocated memory block
300 * Success: pointer to allocated memory block
305 COMCTL32_Alloc (DWORD dwSize)
309 TRACE("(0x%lx)\n", dwSize);
311 lpPtr = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
313 TRACE("-- ret=%p\n", lpPtr);
319 /**************************************************************************
320 * ReAlloc [COMCTL32.72]
322 * Changes the size of an allocated memory block or allocates a memory
323 * block using the dll's private heap.
326 * lpSrc [I] pointer to memory block which will be resized
327 * dwSize [I] new size of the memory block.
330 * Success: pointer to the resized memory block
334 * If lpSrc is a NULL-pointer, then COMCTL32_ReAlloc allocates a memory
335 * block like COMCTL32_Alloc.
339 COMCTL32_ReAlloc (LPVOID lpSrc, DWORD dwSize)
343 TRACE("(%p 0x%08lx)\n", lpSrc, dwSize);
346 lpDest = HeapReAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, lpSrc, dwSize);
348 lpDest = HeapAlloc (COMCTL32_hHeap, HEAP_ZERO_MEMORY, dwSize);
350 TRACE("-- ret=%p\n", lpDest);
356 /**************************************************************************
359 * Frees an allocated memory block from the dll's private heap.
362 * lpMem [I] pointer to memory block which will be freed
370 COMCTL32_Free (LPVOID lpMem)
372 TRACE("(%p)\n", lpMem);
374 return HeapFree (COMCTL32_hHeap, 0, lpMem);
378 /**************************************************************************
379 * GetSize [COMCTL32.74]
381 * Retrieves the size of the specified memory block from the dll's
385 * lpMem [I] pointer to an allocated memory block
388 * Success: size of the specified memory block
393 COMCTL32_GetSize (LPVOID lpMem)
395 TRACE("(%p)\n", lpMem);
397 return HeapSize (COMCTL32_hHeap, 0, lpMem);
401 /**************************************************************************
402 * The MRU-API is a set of functions to manipulate MRU(Most Recently Used)
405 * Stored in the reg. as a set of values under a single key. Each item in the
406 * list has a value name that is a single char. 'a' - 'z', '{', '|' or '}'.
407 * The order of the list is stored with value name 'MRUList' which is a string
408 * containing the value names (i.e. 'a', 'b', etc.) in the relevant order.
411 typedef struct tagCREATEMRULIST
413 DWORD cbSize; /* size of struct */
414 DWORD nMaxItems; /* max no. of items in list */
415 DWORD dwFlags; /* see below */
416 HKEY hKey; /* root reg. key under which list is saved */
417 LPCSTR lpszSubKey; /* reg. subkey */
418 PROC lpfnCompare; /* item compare proc */
419 } CREATEMRULIST, *LPCREATEMRULIST;
422 #define MRUF_STRING_LIST 0 /* list will contain strings */
423 #define MRUF_BINARY_LIST 1 /* list will contain binary data */
424 #define MRUF_DELAYED_SAVE 2 /* only save list order to reg. is FreeMRUList */
426 /* If list is a string list lpfnCompare has the following prototype
427 * int CALLBACK MRUCompareString(LPCSTR s1, LPCSTR s2)
428 * for binary lists the prototype is
429 * int CALLBACK MRUCompareBinary(LPCVOID data1, LPCVOID data2, DWORD cbData)
430 * where cbData is the no. of bytes to compare.
431 * Need to check what return value means identical - 0?
434 typedef struct tagMRU
436 DWORD dwParam1; /* some kind of flag */
445 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2,
446 DWORD dwParam3, DWORD dwParam4);
449 /**************************************************************************
450 * CreateMRUListA [COMCTL32.151]
453 * lpcml [I] ptr to CREATEMRULIST structure.
456 * Handle to MRU list.
459 CreateMRUListA (LPCREATEMRULIST lpcml)
461 return CreateMRUListLazyA (lpcml, 0, 0, 0);
464 /**************************************************************************
465 * FreeMRUListA [COMCTL32.152]
468 * hMRUList [I] Handle to list.
472 FreeMRUListA (HANDLE hMRUList)
474 FIXME("(%08x) empty stub!\n", hMRUList);
477 if (!(hmru->dwParam1 & 1001)) {
478 RegSetValueExA (hmru->hKeyMRU, "MRUList", 0, REG_SZ,
480 strlen (hmru->lpszMRUString));
484 RegClosKey (hmru->hkeyMRU
485 COMCTL32_Free32 (hmru->lpszMRUString);
488 return COMCTL32_Free ((LPVOID)hMRUList);
492 /**************************************************************************
493 * AddMRUData [COMCTL32.167]
495 * Add item to MRU binary list. If item already exists in list them it is
496 * simply moved up to the top of the list and not added again. If list is
497 * full then the least recently used item is removed to make room.
500 * hList [I] Handle to list.
501 * lpData [I] ptr to data to add.
502 * cbData [I] no. of bytes of data.
505 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
509 AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData)
511 FIXME("(%08x, %p, %ld) empty stub!\n", hList, lpData, cbData);
516 /**************************************************************************
517 * AddMRUStringA [COMCTL32.153]
519 * Add item to MRU string list. If item already exists in list them it is
520 * simply moved up to the top of the list and not added again. If list is
521 * full then the least recently used item is removed to make room.
524 * hList [I] Handle to list.
525 * lpszString [I] ptr to string to add.
528 * No. corresponding to registry name where value is stored 'a' -> 0 etc.
532 AddMRUStringA(HANDLE hList, LPCSTR lpszString)
534 FIXME("(%08x, %s) empty stub!\n", hList, debugstr_a(lpszString));
539 /**************************************************************************
540 * DelMRUString [COMCTL32.156]
542 * Removes item from either string or binary list (despite its name)
545 * hList [I] list handle
546 * nItemPos [I] item position to remove 0 -> MRU
549 * TRUE is successful, FALSE if nItemPos is out of range.
552 DelMRUString(HANDLE hList, INT nItemPos)
554 FIXME("(%08x, %d): stub\n", hList, nItemPos);
558 /**************************************************************************
559 * FindMRUData [COMCTL32.169]
561 * Searches binary list for item that matches lpData of length cbData.
562 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
563 * corresponding to item's reg. name will be stored in it ('a' -> 0).
566 * hList [I] list handle
567 * lpData [I] data to find
568 * cbData [I] length of data
569 * lpRegNum [O] position in registry (maybe NULL)
572 * Position in list 0 -> MRU. -1 if item not found.
575 FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum)
577 FIXME("(%08x, %p, %ld, %p) empty stub!\n",
578 hList, lpData, cbData, lpRegNum);
583 /**************************************************************************
584 * FindMRUStringA [COMCTL32.155]
586 * Searches string list for item that matches lpszString.
587 * Returns position in list order 0 -> MRU and if lpRegNum != NULL then value
588 * corresponding to item's reg. name will be stored in it ('a' -> 0).
591 * hList [I] list handle
592 * lpszString [I] string to find
593 * lpRegNum [O] position in registry (maybe NULL)
596 * Position in list 0 -> MRU. -1 if item not found.
599 FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum)
601 FIXME("(%08x, %s, %p) empty stub!\n", hList, debugstr_a(lpszString),
607 /**************************************************************************
608 * CreateMRUListLazyA [COMCTL32.157]
611 CreateMRUListLazyA (LPCREATEMRULIST lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4)
620 * DWORD dwDisposition; */
622 /* internal variables */
625 FIXME("(%p) empty stub!\n", lpcml);
630 if (lpcml->cbSize < sizeof(CREATEMRULIST))
633 FIXME("(%lu %lu %lx %lx \"%s\" %p)\n",
634 lpcml->cbSize, lpcml->nMaxItems, lpcml->dwFlags,
635 (DWORD)lpcml->hKey, lpcml->lpszSubKey, lpcml->lpfnCompare);
637 /* dummy pointer creation */
638 ptr = COMCTL32_Alloc (32);
640 FIXME("-- ret = %p\n", ptr);
645 /**************************************************************************
646 * EnumMRUListA [COMCTL32.154]
648 * Enumerate item in a list
651 * hList [I] list handle
652 * nItemPos [I] item position to enumerate
653 * lpBuffer [O] buffer to receive item
654 * nBufferSize [I] size of buffer
657 * For binary lists specifies how many bytes were copied to buffer, for
658 * string lists specifies full length of string. Enumerating past the end
659 * of list returns -1.
660 * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in
663 INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer,
666 FIXME("(%08x, %d, %p, %ld): stub\n", hList, nItemPos, lpBuffer,
671 /**************************************************************************
672 * Str_GetPtrA [COMCTL32.233]
683 Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen)
687 TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
689 if (!lpDest && lpSrc)
690 return strlen (lpSrc);
700 len = strlen (lpSrc);
704 RtlMoveMemory (lpDest, lpSrc, len);
711 /**************************************************************************
712 * Str_SetPtrA [COMCTL32.234]
722 Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc)
724 TRACE("(%p %p)\n", lppDest, lpSrc);
727 LPSTR ptr = COMCTL32_ReAlloc (*lppDest, strlen (lpSrc) + 1);
735 COMCTL32_Free (*lppDest);
744 /**************************************************************************
745 * Str_GetPtrW [COMCTL32.235]
756 Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen)
760 TRACE("(%p %p %d)\n", lpSrc, lpDest, nMaxLen);
762 if (!lpDest && lpSrc)
763 return strlenW (lpSrc);
773 len = strlenW (lpSrc);
777 RtlMoveMemory (lpDest, lpSrc, len*sizeof(WCHAR));
784 /**************************************************************************
785 * Str_SetPtrW [COMCTL32.236]
795 Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc)
797 TRACE("(%p %p)\n", lppDest, lpSrc);
800 INT len = strlenW (lpSrc) + 1;
801 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len * sizeof(WCHAR));
804 strcpyW (ptr, lpSrc);
809 COMCTL32_Free (*lppDest);
818 /**************************************************************************
819 * Str_GetPtrWtoA [internal]
821 * Converts a unicode string into a multi byte string
824 * lpSrc [I] Pointer to the unicode source string
825 * lpDest [O] Pointer to caller supplied storage for the multi byte string
826 * nMaxLen [I] Size, in bytes, of the destination buffer
829 * Length, in bytes, of the converted string.
833 Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen)
837 TRACE("(%s %p %d)\n", debugstr_w(lpSrc), lpDest, nMaxLen);
839 if (!lpDest && lpSrc)
840 return WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
850 len = WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, 0, 0, NULL, NULL);
854 WideCharToMultiByte(CP_ACP, 0, lpSrc, -1, lpDest, len, NULL, NULL);
861 /**************************************************************************
862 * Str_SetPtrAtoW [internal]
864 * Converts a multi byte string to a unicode string.
865 * If the pointer to the destination buffer is NULL a buffer is allocated.
866 * If the destination buffer is too small to keep the converted multi byte
867 * string the destination buffer is reallocated. If the source pointer is
868 * NULL, the destination buffer is freed.
871 * lppDest [I/O] pointer to a pointer to the destination buffer
872 * lpSrc [I] pointer to a multi byte string
875 * TRUE: conversion successful
880 Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc)
882 TRACE("(%p %s)\n", lppDest, lpSrc);
885 INT len = MultiByteToWideChar(CP_ACP,0,lpSrc,-1,NULL,0);
886 LPWSTR ptr = COMCTL32_ReAlloc (*lppDest, len*sizeof(WCHAR));
890 MultiByteToWideChar(CP_ACP,0,lpSrc,-1,ptr,len);
895 COMCTL32_Free (*lppDest);
904 /**************************************************************************
905 * The DSA-API is a set of functions to create and manipulate arrays of
906 * fixed-size memory blocks. These arrays can store any kind of data
907 * (strings, icons...).
910 /**************************************************************************
911 * DSA_Create [COMCTL32.320] Creates a dynamic storage array
914 * nSize [I] size of the array elements
915 * nGrow [I] number of elements by which the array grows when it is filled
918 * Success: pointer to an array control structure. Use this like a handle.
923 DSA_Create (INT nSize, INT nGrow)
927 TRACE("(size=%d grow=%d)\n", nSize, nGrow);
929 hdsa = (HDSA)COMCTL32_Alloc (sizeof(DSA));
932 hdsa->nItemCount = 0;
935 hdsa->nItemSize = nSize;
936 hdsa->nGrow = max(1, nGrow);
943 /**************************************************************************
944 * DSA_Destroy [COMCTL32.321] Destroys a dynamic storage array
947 * hdsa [I] pointer to the array control structure
955 DSA_Destroy (const HDSA hdsa)
957 TRACE("(%p)\n", hdsa);
962 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
965 return COMCTL32_Free (hdsa);
969 /**************************************************************************
970 * DSA_GetItem [COMCTL32.322]
973 * hdsa [I] pointer to the array control structure
974 * nIndex [I] number of the Item to get
975 * pDest [O] destination buffer. Has to be >= dwElementSize.
983 DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest)
987 TRACE("(%p %d %p)\n", hdsa, nIndex, pDest);
991 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
994 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
995 memmove (pDest, pSrc, hdsa->nItemSize);
1001 /**************************************************************************
1002 * DSA_GetItemPtr [COMCTL32.323]
1004 * Retrieves a pointer to the specified item.
1007 * hdsa [I] pointer to the array control structure
1008 * nIndex [I] index of the desired item
1011 * Success: pointer to an item
1016 DSA_GetItemPtr (const HDSA hdsa, INT nIndex)
1020 TRACE("(%p %d)\n", hdsa, nIndex);
1024 if ((nIndex < 0) || (nIndex >= hdsa->nItemCount))
1027 pSrc = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1029 TRACE("-- ret=%p\n", pSrc);
1035 /**************************************************************************
1036 * DSA_SetItem [COMCTL32.325]
1038 * Sets the contents of an item in the array.
1041 * hdsa [I] pointer to the array control structure
1042 * nIndex [I] index for the item
1043 * pSrc [I] pointer to the new item data
1051 DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
1053 INT nSize, nNewItems;
1054 LPVOID pDest, lpTemp;
1056 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
1058 if ((!hdsa) || nIndex < 0)
1061 if (hdsa->nItemCount <= nIndex) {
1062 /* within the old array */
1063 if (hdsa->nMaxCount > nIndex) {
1064 /* within the allocated space, set a new boundary */
1065 hdsa->nItemCount = nIndex + 1;
1068 /* resize the block of memory */
1070 hdsa->nGrow * ((INT)(((nIndex + 1) - 1) / hdsa->nGrow) + 1);
1071 nSize = hdsa->nItemSize * nNewItems;
1073 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1077 hdsa->nMaxCount = nNewItems;
1078 hdsa->nItemCount = nIndex + 1;
1079 hdsa->pData = lpTemp;
1083 /* put the new entry in */
1084 pDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1085 TRACE("-- move dest=%p src=%p size=%d\n",
1086 pDest, pSrc, hdsa->nItemSize);
1087 memmove (pDest, pSrc, hdsa->nItemSize);
1093 /**************************************************************************
1094 * DSA_InsertItem [COMCTL32.325]
1097 * hdsa [I] pointer to the array control structure
1098 * nIndex [I] index for the new item
1099 * pSrc [I] pointer to the element
1102 * Success: position of the new item
1107 DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc)
1109 INT nNewItems, nSize, i;
1110 LPVOID lpTemp, lpDest;
1113 TRACE("(%p %d %p)\n", hdsa, nIndex, pSrc);
1115 if ((!hdsa) || nIndex < 0)
1118 for (i = 0; i < hdsa->nItemSize; i += 4) {
1119 p = *(DWORD**)((char *) pSrc + i);
1120 if (IsBadStringPtrA ((char*)p, 256))
1121 TRACE("-- %d=%p\n", i, (DWORD*)p);
1123 TRACE("-- %d=%p [%s]\n", i, p, debugstr_a((char*)p));
1126 /* when nIndex >= nItemCount then append */
1127 if (nIndex >= hdsa->nItemCount)
1128 nIndex = hdsa->nItemCount;
1130 /* do we need to resize ? */
1131 if (hdsa->nItemCount >= hdsa->nMaxCount) {
1132 nNewItems = hdsa->nMaxCount + hdsa->nGrow;
1133 nSize = hdsa->nItemSize * nNewItems;
1135 lpTemp = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1139 hdsa->nMaxCount = nNewItems;
1140 hdsa->pData = lpTemp;
1143 /* do we need to move elements ? */
1144 if (nIndex < hdsa->nItemCount) {
1145 lpTemp = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1146 lpDest = (char *) lpTemp + hdsa->nItemSize;
1147 nSize = (hdsa->nItemCount - nIndex) * hdsa->nItemSize;
1148 TRACE("-- move dest=%p src=%p size=%d\n",
1149 lpDest, lpTemp, nSize);
1150 memmove (lpDest, lpTemp, nSize);
1153 /* ok, we can put the new Item in */
1155 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1156 TRACE("-- move dest=%p src=%p size=%d\n",
1157 lpDest, pSrc, hdsa->nItemSize);
1158 memmove (lpDest, pSrc, hdsa->nItemSize);
1164 /**************************************************************************
1165 * DSA_DeleteItem [COMCTL32.326]
1168 * hdsa [I] pointer to the array control structure
1169 * nIndex [I] index for the element to delete
1172 * Success: number of the deleted element
1177 DSA_DeleteItem (const HDSA hdsa, INT nIndex)
1179 LPVOID lpDest,lpSrc;
1182 TRACE("(%p %d)\n", hdsa, nIndex);
1186 if (nIndex < 0 || nIndex >= hdsa->nItemCount)
1189 /* do we need to move ? */
1190 if (nIndex < hdsa->nItemCount - 1) {
1191 lpDest = (char *) hdsa->pData + (hdsa->nItemSize * nIndex);
1192 lpSrc = (char *) lpDest + hdsa->nItemSize;
1193 nSize = hdsa->nItemSize * (hdsa->nItemCount - nIndex - 1);
1194 TRACE("-- move dest=%p src=%p size=%d\n",
1195 lpDest, lpSrc, nSize);
1196 memmove (lpDest, lpSrc, nSize);
1202 if ((hdsa->nMaxCount - hdsa->nItemCount) >= hdsa->nGrow) {
1203 nSize = hdsa->nItemSize * hdsa->nItemCount;
1205 lpDest = (LPVOID)COMCTL32_ReAlloc (hdsa->pData, nSize);
1209 hdsa->nMaxCount = hdsa->nItemCount;
1210 hdsa->pData = lpDest;
1217 /**************************************************************************
1218 * DSA_DeleteAllItems [COMCTL32.326]
1220 * Removes all items and reinitializes the array.
1223 * hdsa [I] pointer to the array control structure
1231 DSA_DeleteAllItems (const HDSA hdsa)
1233 TRACE("(%p)\n", hdsa);
1237 if (hdsa->pData && (!COMCTL32_Free (hdsa->pData)))
1240 hdsa->nItemCount = 0;
1242 hdsa->nMaxCount = 0;
1248 /**************************************************************************
1249 * The DPA-API is a set of functions to create and manipulate arrays of
1253 /**************************************************************************
1254 * DPA_Create [COMCTL32.328] Creates a dynamic pointer array
1257 * nGrow [I] number of items by which the array grows when it is filled
1260 * Success: handle (pointer) to the pointer array.
1265 DPA_Create (INT nGrow)
1269 TRACE("(%d)\n", nGrow);
1271 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1273 hdpa->nGrow = max(8, nGrow);
1274 hdpa->hHeap = COMCTL32_hHeap;
1275 hdpa->nMaxCount = hdpa->nGrow * 2;
1277 (LPVOID*)COMCTL32_Alloc (hdpa->nMaxCount * sizeof(LPVOID));
1280 TRACE("-- %p\n", hdpa);
1286 /**************************************************************************
1287 * DPA_Destroy [COMCTL32.329] Destroys a dynamic pointer array
1290 * hdpa [I] handle (pointer) to the pointer array
1298 DPA_Destroy (const HDPA hdpa)
1300 TRACE("(%p)\n", hdpa);
1305 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1308 return HeapFree (hdpa->hHeap, 0, hdpa);
1312 /**************************************************************************
1313 * DPA_Grow [COMCTL32.330]
1315 * Sets the growth amount.
1318 * hdpa [I] handle (pointer) to the existing (source) pointer array
1319 * nGrow [I] number of items, the array grows, when it's too small
1327 DPA_Grow (const HDPA hdpa, INT nGrow)
1329 TRACE("(%p %d)\n", hdpa, nGrow);
1334 hdpa->nGrow = max(8, nGrow);
1340 /**************************************************************************
1341 * DPA_Clone [COMCTL32.331]
1343 * Copies a pointer array to an other one or creates a copy
1346 * hdpa [I] handle (pointer) to the existing (source) pointer array
1347 * hdpaNew [O] handle (pointer) to the destination pointer array
1350 * Success: pointer to the destination pointer array.
1354 * - If the 'hdpaNew' is a NULL-Pointer, a copy of the source pointer
1355 * array will be created and it's handle (pointer) is returned.
1356 * - If 'hdpa' is a NULL-Pointer, the original implementation crashes,
1357 * this implementation just returns NULL.
1361 DPA_Clone (const HDPA hdpa, const HDPA hdpaNew)
1363 INT nNewItems, nSize;
1369 TRACE("(%p %p)\n", hdpa, hdpaNew);
1372 /* create a new DPA */
1373 hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1375 hdpaTemp->hHeap = hdpa->hHeap;
1376 hdpaTemp->nGrow = hdpa->nGrow;
1381 if (hdpaTemp->ptrs) {
1382 /* remove old pointer array */
1383 HeapFree (hdpaTemp->hHeap, 0, hdpaTemp->ptrs);
1384 hdpaTemp->ptrs = NULL;
1385 hdpaTemp->nItemCount = 0;
1386 hdpaTemp->nMaxCount = 0;
1389 /* create a new pointer array */
1390 nNewItems = hdpaTemp->nGrow *
1391 ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1);
1392 nSize = nNewItems * sizeof(LPVOID);
1394 (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize);
1395 hdpaTemp->nMaxCount = nNewItems;
1397 /* clone the pointer array */
1398 hdpaTemp->nItemCount = hdpa->nItemCount;
1399 memmove (hdpaTemp->ptrs, hdpa->ptrs,
1400 hdpaTemp->nItemCount * sizeof(LPVOID));
1406 /**************************************************************************
1407 * DPA_GetPtr [COMCTL32.332]
1409 * Retrieves a pointer from a dynamic pointer array
1412 * hdpa [I] handle (pointer) to the pointer array
1413 * nIndex [I] array index of the desired pointer
1421 DPA_GetPtr (const HDPA hdpa, INT i)
1423 TRACE("(%p %d)\n", hdpa, i);
1428 WARN("no pointer array.\n");
1431 if ((i < 0) || (i >= hdpa->nItemCount)) {
1432 WARN("not enough pointers in array (%d vs %d).\n",i,hdpa->nItemCount);
1436 TRACE("-- %p\n", hdpa->ptrs[i]);
1438 return hdpa->ptrs[i];
1442 /**************************************************************************
1443 * DPA_GetPtrIndex [COMCTL32.333]
1445 * Retrieves the index of the specified pointer
1448 * hdpa [I] handle (pointer) to the pointer array
1452 * Success: index of the specified pointer
1457 DPA_GetPtrIndex (const HDPA hdpa, LPVOID p)
1464 for (i = 0; i < hdpa->nItemCount; i++) {
1465 if (hdpa->ptrs[i] == p)
1473 /**************************************************************************
1474 * DPA_InsertPtr [COMCTL32.334]
1476 * Inserts a pointer into a dynamic pointer array
1479 * hdpa [I] handle (pointer) to the array
1481 * p [I] pointer to insert
1484 * Success: index of the inserted pointer
1489 DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p)
1491 INT nNewItems, nSize, nIndex = 0;
1492 LPVOID *lpTemp, *lpDest;
1494 TRACE("(%p %d %p)\n", hdpa, i, p);
1496 if ((!hdpa) || (i < 0))
1501 (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1502 2 * hdpa->nGrow * sizeof(LPVOID));
1505 hdpa->nMaxCount = hdpa->nGrow * 2;
1509 if (hdpa->nItemCount >= hdpa->nMaxCount) {
1510 TRACE("-- resizing\n");
1511 nNewItems = hdpa->nMaxCount + hdpa->nGrow;
1512 nSize = nNewItems * sizeof(LPVOID);
1514 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1518 hdpa->nMaxCount = nNewItems;
1519 hdpa->ptrs = lpTemp;
1522 if (i >= hdpa->nItemCount) {
1523 nIndex = hdpa->nItemCount;
1524 TRACE("-- appending at %d\n", nIndex);
1527 TRACE("-- inserting at %d\n", i);
1528 lpTemp = hdpa->ptrs + i;
1529 lpDest = lpTemp + 1;
1530 nSize = (hdpa->nItemCount - i) * sizeof(LPVOID);
1531 TRACE("-- move dest=%p src=%p size=%x\n",
1532 lpDest, lpTemp, nSize);
1533 memmove (lpDest, lpTemp, nSize);
1540 hdpa->ptrs[nIndex] = p;
1546 /**************************************************************************
1547 * DPA_SetPtr [COMCTL32.335]
1549 * Sets a pointer in the pointer array
1552 * hdpa [I] handle (pointer) to the pointer array
1553 * i [I] index of the pointer that will be set
1554 * p [I] pointer to be set
1562 DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p)
1566 TRACE("(%p %d %p)\n", hdpa, i, p);
1568 if ((!hdpa) || i < 0)
1571 if (hdpa->nItemCount <= i) {
1572 /* within the old array */
1573 if (hdpa->nMaxCount > i) {
1574 /* within the allocated space, set a new boundary */
1575 hdpa->nItemCount = i+1;
1578 /* resize the block of memory */
1580 hdpa->nGrow * ((INT)(((i+1) - 1) / hdpa->nGrow) + 1);
1581 INT nSize = nNewItems * sizeof(LPVOID);
1583 lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1588 hdpa->nItemCount = nNewItems;
1589 hdpa->ptrs = lpTemp;
1593 /* put the new entry in */
1600 /**************************************************************************
1601 * DPA_DeletePtr [COMCTL32.336]
1603 * Removes a pointer from the pointer array.
1606 * hdpa [I] handle (pointer) to the pointer array
1607 * i [I] index of the pointer that will be deleted
1610 * Success: deleted pointer
1615 DPA_DeletePtr (const HDPA hdpa, INT i)
1617 LPVOID *lpDest, *lpSrc, lpTemp = NULL;
1620 TRACE("(%p %d)\n", hdpa, i);
1622 if ((!hdpa) || i < 0 || i >= hdpa->nItemCount)
1625 lpTemp = hdpa->ptrs[i];
1627 /* do we need to move ?*/
1628 if (i < hdpa->nItemCount - 1) {
1629 lpDest = hdpa->ptrs + i;
1631 nSize = (hdpa->nItemCount - i - 1) * sizeof(LPVOID);
1632 TRACE("-- move dest=%p src=%p size=%x\n",
1633 lpDest, lpSrc, nSize);
1634 memmove (lpDest, lpSrc, nSize);
1637 hdpa->nItemCount --;
1640 if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) {
1641 INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount);
1642 nSize = nNewItems * sizeof(LPVOID);
1643 lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1648 hdpa->nMaxCount = nNewItems;
1649 hdpa->ptrs = (LPVOID*)lpDest;
1656 /**************************************************************************
1657 * DPA_DeleteAllPtrs [COMCTL32.337]
1659 * Removes all pointers and reinitializes the array.
1662 * hdpa [I] handle (pointer) to the pointer array
1670 DPA_DeleteAllPtrs (const HDPA hdpa)
1672 TRACE("(%p)\n", hdpa);
1677 if (hdpa->ptrs && (!HeapFree (hdpa->hHeap, 0, hdpa->ptrs)))
1680 hdpa->nItemCount = 0;
1681 hdpa->nMaxCount = hdpa->nGrow * 2;
1682 hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY,
1683 hdpa->nMaxCount * sizeof(LPVOID));
1689 /**************************************************************************
1690 * DPA_QuickSort [Internal]
1692 * Ordinary quicksort (used by DPA_Sort).
1695 * lpPtrs [I] pointer to the pointer array
1696 * l [I] index of the "left border" of the partition
1697 * r [I] index of the "right border" of the partition
1698 * pfnCompare [I] pointer to the compare function
1699 * lParam [I] user defined value (3rd parameter in compare function)
1706 DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r,
1707 PFNDPACOMPARE pfnCompare, LPARAM lParam)
1712 TRACE("l=%i r=%i\n", l, r);
1714 if (l==r) /* one element is always sorted */
1716 if (r<l) /* oops, got it in the wrong order */
1718 DPA_QuickSort(lpPtrs, r, l, pfnCompare, lParam);
1721 m = (l+r)/2; /* divide by two */
1722 DPA_QuickSort(lpPtrs, l, m, pfnCompare, lParam);
1723 DPA_QuickSort(lpPtrs, m+1, r, pfnCompare, lParam);
1725 /* join the two sides */
1726 while( (l<=m) && (m<r) )
1728 if(pfnCompare(lpPtrs[l],lpPtrs[m+1],lParam)>0)
1731 memmove(&lpPtrs[l+1],&lpPtrs[l],(m-l+1)*sizeof lpPtrs[l]);
1741 /**************************************************************************
1742 * DPA_Sort [COMCTL32.338]
1744 * Sorts a pointer array using a user defined compare function
1747 * hdpa [I] handle (pointer) to the pointer array
1748 * pfnCompare [I] pointer to the compare function
1749 * lParam [I] user defined value (3rd parameter of compare function)
1757 DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam)
1759 if (!hdpa || !pfnCompare)
1762 TRACE("(%p %p 0x%lx)\n", hdpa, pfnCompare, lParam);
1764 if ((hdpa->nItemCount > 1) && (hdpa->ptrs))
1765 DPA_QuickSort (hdpa->ptrs, 0, hdpa->nItemCount - 1,
1766 pfnCompare, lParam);
1772 /**************************************************************************
1773 * DPA_Search [COMCTL32.339]
1775 * Searches a pointer array for a specified pointer
1778 * hdpa [I] handle (pointer) to the pointer array
1779 * pFind [I] pointer to search for
1780 * nStart [I] start index
1781 * pfnCompare [I] pointer to the compare function
1782 * lParam [I] user defined value (3rd parameter of compare function)
1783 * uOptions [I] search options
1786 * Success: index of the pointer in the array.
1790 * Binary search taken from R.Sedgewick "Algorithms in C"!
1791 * Function is NOT tested!
1792 * If something goes wrong, blame HIM not ME! (Eric Kohl)
1796 DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart,
1797 PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions)
1799 if (!hdpa || !pfnCompare || !pFind)
1802 TRACE("(%p %p %d %p 0x%08lx 0x%08x)\n",
1803 hdpa, pFind, nStart, pfnCompare, lParam, uOptions);
1805 if (uOptions & DPAS_SORTED) {
1806 /* array is sorted --> use binary search */
1810 TRACE("binary search\n");
1812 l = (nStart == -1) ? 0 : nStart;
1813 r = hdpa->nItemCount - 1;
1817 n = (pfnCompare)(pFind, lpPtr[x], lParam);
1823 TRACE("-- ret=%d\n", n);
1828 if (uOptions & DPAS_INSERTBEFORE) {
1829 TRACE("-- ret=%d\n", r);
1833 if (uOptions & DPAS_INSERTAFTER) {
1834 TRACE("-- ret=%d\n", l);
1839 /* array is not sorted --> use linear search */
1843 TRACE("linear search\n");
1845 nIndex = (nStart == -1)? 0 : nStart;
1847 for (; nIndex < hdpa->nItemCount; nIndex++) {
1848 if ((pfnCompare)(pFind, lpPtr[nIndex], lParam) == 0) {
1849 TRACE("-- ret=%d\n", nIndex);
1855 TRACE("-- not found: ret=-1\n");
1860 /**************************************************************************
1861 * DPA_CreateEx [COMCTL32.340]
1863 * Creates a dynamic pointer array using the specified size and heap.
1866 * nGrow [I] number of items by which the array grows when it is filled
1867 * hHeap [I] handle to the heap where the array is stored
1870 * Success: handle (pointer) to the pointer array.
1875 DPA_CreateEx (INT nGrow, HANDLE hHeap)
1879 TRACE("(%d 0x%x)\n", nGrow, hHeap);
1882 hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(DPA));
1884 hdpa = (HDPA)COMCTL32_Alloc (sizeof(DPA));
1887 hdpa->nGrow = min(8, nGrow);
1888 hdpa->hHeap = hHeap ? hHeap : COMCTL32_hHeap;
1889 hdpa->nMaxCount = hdpa->nGrow * 2;
1891 (LPVOID*)HeapAlloc (hHeap, HEAP_ZERO_MEMORY,
1892 hdpa->nMaxCount * sizeof(LPVOID));
1895 TRACE("-- %p\n", hdpa);
1901 /**************************************************************************
1902 * Notification functions
1905 typedef struct tagNOTIFYDATA
1913 } NOTIFYDATA, *LPNOTIFYDATA;
1916 /**************************************************************************
1917 * DoNotify [Internal]
1921 DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr)
1924 LPNMHDR lpNmh = NULL;
1927 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
1928 lpNotify->hwndFrom, lpNotify->hwndTo, uCode, lpHdr,
1929 lpNotify->dwParam5);
1931 if (!lpNotify->hwndTo)
1934 if (lpNotify->hwndFrom == -1) {
1936 idFrom = lpHdr->idFrom;
1939 if (lpNotify->hwndFrom) {
1940 HWND hwndParent = GetParent (lpNotify->hwndFrom);
1942 hwndParent = GetWindow (lpNotify->hwndFrom, GW_OWNER);
1944 idFrom = GetDlgCtrlID (lpNotify->hwndFrom);
1948 lpNmh = (lpHdr) ? lpHdr : &nmhdr;
1950 lpNmh->hwndFrom = lpNotify->hwndFrom;
1951 lpNmh->idFrom = idFrom;
1952 lpNmh->code = uCode;
1955 return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh);
1959 /**************************************************************************
1960 * SendNotify [COMCTL32.341]
1969 * Success: return value from notification
1974 COMCTL32_SendNotify (HWND hwndFrom, HWND hwndTo,
1975 UINT uCode, LPNMHDR lpHdr)
1979 TRACE("(0x%04x 0x%04x %d %p)\n",
1980 hwndFrom, hwndTo, uCode, lpHdr);
1982 notify.hwndFrom = hwndFrom;
1983 notify.hwndTo = hwndTo;
1984 notify.dwParam5 = 0;
1985 notify.dwParam6 = 0;
1987 return DoNotify (¬ify, uCode, lpHdr);
1991 /**************************************************************************
1992 * SendNotifyEx [COMCTL32.342]
2002 * Success: return value from notification
2007 COMCTL32_SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode,
2008 LPNMHDR lpHdr, DWORD dwParam5)
2013 TRACE("(0x%04x 0x%04x %d %p 0x%08lx)\n",
2014 hwndFrom, hwndTo, uCode, lpHdr, dwParam5);
2016 hwndNotify = hwndTo;
2018 if (IsWindow (hwndFrom)) {
2019 hwndNotify = GetParent (hwndFrom);
2025 notify.hwndFrom = hwndFrom;
2026 notify.hwndTo = hwndNotify;
2027 notify.dwParam5 = dwParam5;
2028 notify.dwParam6 = 0;
2030 return DoNotify (¬ify, uCode, lpHdr);
2034 /**************************************************************************
2035 * StrChrA [COMCTL32.350]
2040 COMCTL32_StrChrA (LPCSTR lpString, CHAR cChar)
2042 return strchr (lpString, cChar);
2046 /**************************************************************************
2047 * StrStrIA [COMCTL32.355]
2051 COMCTL32_StrStrIA (LPCSTR lpStr1, LPCSTR lpStr2)
2057 return ((LPSTR)lpStr1);
2059 while (lpStr1[len1] != 0) ++len1;
2061 while (lpStr2[len2] != 0) ++len2;
2063 return ((LPSTR)(lpStr1 + len1));
2064 first = tolower (*lpStr2);
2065 while (len1 >= len2) {
2066 if (tolower(*lpStr1) == first) {
2067 for (i = 1; i < len2; ++i)
2068 if (tolower (lpStr1[i]) != tolower(lpStr2[i]))
2071 return ((LPSTR)lpStr1);
2079 /**************************************************************************
2080 * StrToIntA [COMCTL32.357] Converts a string to a signed integer.
2084 COMCTL32_StrToIntA (LPSTR lpString)
2086 return atoi(lpString);
2090 /**************************************************************************
2091 * DPA_EnumCallback [COMCTL32.385]
2093 * Enumerates all items in a dynamic pointer array.
2096 * hdpa [I] handle to the dynamic pointer array
2105 DPA_EnumCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2109 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
2113 if (hdpa->nItemCount <= 0)
2116 for (i = 0; i < hdpa->nItemCount; i++) {
2117 if ((enumProc)(hdpa->ptrs[i], lParam) == 0)
2125 /**************************************************************************
2126 * DPA_DestroyCallback [COMCTL32.386]
2128 * Enumerates all items in a dynamic pointer array and destroys it.
2131 * hdpa [I] handle to the dynamic pointer array
2141 DPA_DestroyCallback (const HDPA hdpa, DPAENUMPROC enumProc, LPARAM lParam)
2143 TRACE("(%p %p %08lx)\n", hdpa, enumProc, lParam);
2145 DPA_EnumCallback (hdpa, enumProc, lParam);
2147 return DPA_Destroy (hdpa);
2151 /**************************************************************************
2152 * DSA_EnumCallback [COMCTL32.387]
2154 * Enumerates all items in a dynamic storage array.
2157 * hdsa [I] handle to the dynamic storage array
2166 DSA_EnumCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2170 TRACE("(%p %p %08lx)\n", hdsa, enumProc, lParam);
2174 if (hdsa->nItemCount <= 0)
2177 for (i = 0; i < hdsa->nItemCount; i++) {
2178 LPVOID lpItem = DSA_GetItemPtr (hdsa, i);
2179 if ((enumProc)(lpItem, lParam) == 0)
2187 /**************************************************************************
2188 * DSA_DestroyCallback [COMCTL32.388]
2190 * Enumerates all items in a dynamic storage array and destroys it.
2193 * hdsa [I] handle to the dynamic storage array
2203 DSA_DestroyCallback (const HDSA hdsa, DSAENUMPROC enumProc, LPARAM lParam)
2205 TRACE("(%p %p %08lx)\n", hdsa, enumProc, lParam);
2207 DSA_EnumCallback (hdsa, enumProc, lParam);
2209 return DSA_Destroy (hdsa);
2212 /**************************************************************************
2213 * StrCSpnA [COMCTL32.356]
2216 INT WINAPI COMCTL32_StrCSpnA( LPCSTR lpStr, LPCSTR lpSet) {
2217 return strcspn(lpStr, lpSet);
2220 /**************************************************************************
2221 * StrChrW [COMCTL32.358]
2224 LPWSTR WINAPI COMCTL32_StrChrW( LPCWSTR lpStart, WORD wMatch) {
2225 return strchrW(lpStart, wMatch);
2228 /**************************************************************************
2229 * StrCmpNA [COMCTL32.352]
2232 INT WINAPI COMCTL32_StrCmpNA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
2233 return strncmp(lpStr1, lpStr2, nChar);
2236 /**************************************************************************
2237 * StrCmpNIA [COMCTL32.353]
2240 INT WINAPI COMCTL32_StrCmpNIA( LPCSTR lpStr1, LPCSTR lpStr2, int nChar) {
2241 return strncasecmp(lpStr1, lpStr2, nChar);
2244 /**************************************************************************
2245 * StrCmpNW [COMCTL32.360]
2248 INT WINAPI COMCTL32_StrCmpNW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
2249 return strncmpW(lpStr1, lpStr2, nChar);
2252 /**************************************************************************
2253 * StrCmpNIW [COMCTL32.361]
2256 INT WINAPI COMCTL32_StrCmpNIW( LPCWSTR lpStr1, LPCWSTR lpStr2, int nChar) {
2257 FIXME("(%s, %s, %i): stub\n", debugstr_w(lpStr1), debugstr_w(lpStr2), nChar);
2261 /**************************************************************************
2262 * StrRChrA [COMCTL32.351]
2265 LPSTR WINAPI COMCTL32_StrRChrA( LPCSTR lpStart, LPCSTR lpEnd, WORD wMatch )
2267 LPCSTR lpGotIt = NULL;
2268 BOOL dbcs = IsDBCSLeadByte( LOBYTE(wMatch) );
2270 TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
2272 if (!lpEnd) lpEnd = lpStart + strlen(lpStart);
2274 for(; lpStart < lpEnd; lpStart = CharNextA(lpStart))
2276 if (*lpStart != LOBYTE(wMatch)) continue;
2277 if (dbcs && lpStart[1] != HIBYTE(wMatch)) continue;
2280 return (LPSTR)lpGotIt;
2284 /**************************************************************************
2285 * StrRChrW [COMCTL32.359]
2288 LPWSTR WINAPI COMCTL32_StrRChrW( LPCWSTR lpStart, LPCWSTR lpEnd, WORD wMatch)
2290 LPCWSTR lpGotIt = NULL;
2292 TRACE("(%p, %p, %x)\n", lpStart, lpEnd, wMatch);
2293 if (!lpEnd) lpEnd = lpStart + strlenW(lpStart);
2295 for(; lpStart < lpEnd; lpStart = CharNextW(lpStart))
2296 if (*lpStart == wMatch) lpGotIt = lpStart;
2298 return (LPWSTR)lpGotIt;
2302 /**************************************************************************
2303 * StrStrA [COMCTL32.354]
2306 LPSTR WINAPI COMCTL32_StrStrA( LPCSTR lpFirst, LPCSTR lpSrch) {
2307 return strstr(lpFirst, lpSrch);
2310 /**************************************************************************
2311 * StrStrW [COMCTL32.362]
2314 LPWSTR WINAPI COMCTL32_StrStrW( LPCWSTR lpFirst, LPCWSTR lpSrch) {
2315 return strstrW(lpFirst, lpSrch);
2318 /**************************************************************************
2319 * StrSpnW [COMCTL32.364]
2322 INT WINAPI COMCTL32_StrSpnW( LPWSTR lpStr, LPWSTR lpSet) {
2323 LPWSTR lpLoop = lpStr;
2326 if ((lpStr == 0) || (lpSet == 0)) return 0;
2328 /* while(*lpLoop) { if lpLoop++; } */
2330 for(; (*lpLoop != 0); lpLoop++)
2331 if( strchrW(lpSet, *(WORD*)lpLoop))
2332 return (INT)(lpLoop-lpStr);
2334 return (INT)(lpLoop-lpStr);
2337 /**************************************************************************
2338 * COMCTL32_410 [COMCTL32.410]
2340 * FIXME: What's this supposed to do?
2341 * Parameter 1 is an HWND, you're on your own for the rest.
2344 BOOL WINAPI COMCTL32_410( HWND hw, DWORD b, DWORD c, DWORD d) {
2346 FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
2351 /**************************************************************************
2352 * COMCTL32_411 [COMCTL32.411]
2354 * FIXME: What's this supposed to do?
2355 * Parameter 1 is an HWND, you're on your own for the rest.
2358 BOOL WINAPI COMCTL32_411( HWND hw, DWORD b, DWORD c) {
2360 FIXME("(%x, %lx, %lx): stub!\n", hw, b, c);
2365 /**************************************************************************
2366 * COMCTL32_412 [COMCTL32.412]
2368 * FIXME: What's this supposed to do?
2369 * Parameter 1 is an HWND, you're on your own for the rest.
2372 BOOL WINAPI COMCTL32_412( HWND hwnd, DWORD b, DWORD c)
2374 FIXME("(%x, %lx, %lx): stub!\n", hwnd, b, c);
2376 if (IsWindow (hwnd) == FALSE)
2386 /**************************************************************************
2387 * COMCTL32_413 [COMCTL32.413]
2389 * FIXME: What's this supposed to do?
2390 * Parameter 1 is an HWND, you're on your own for the rest.
2393 BOOL WINAPI COMCTL32_413( HWND hw, DWORD b, DWORD c, DWORD d) {
2395 FIXME("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
2401 /**************************************************************************
2402 * COMCTL32_415 [COMCTL32.415]
2404 * FIXME: What's this supposed to do?
2405 * Parameter 1 is an HWND, you're on your own for the rest.
2408 BOOL WINAPI COMCTL32_415( HWND hwnd, DWORD b, DWORD c, DWORD d, DWORD e)
2411 FIXME("(%x, %lx, %lx, %lx, %lx): stub!\n", hwnd, b, c, d, e);