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