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