source: trunk/src/user32/winicon.cpp@ 6666

Last change on this file since 6666 was 6595, checked in by sandervl, 24 years ago

several icon/cursor fixes

File size: 61.2 KB
Line 
1/* $Id: winicon.cpp,v 1.29 2001-08-26 14:23:35 sandervl Exp $ */
2/*
3 * Win32 Icon Code for OS/2
4 *
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl) (OS/2 Port)
7 *
8 * Based on Wine code (objects\bitmap.c, loader\resource.c, objects\cursoricon.c):
9 *
10 * Copyright 1993 Alexandre Julliard
11 * 1993 Robert J. Amstadt
12 * 1996 Martin Von Loewis
13 * 1997 Alex Korobka
14 * 1998 Turchanov Sergey
15 * 1998 Huw D M Davies
16 * Theory:
17 *
18 * http://www.microsoft.com/win32dev/ui/icons.htm
19 *
20 * Cursors and icons are stored in a global heap block, with the
21 * following layout:
22 *
23 * CURSORICONINFO info;
24 * BYTE[] ANDbits;
25 * BYTE[] XORbits;
26 *
27 * The bits structures are in the format of a device-dependent bitmap.
28 *
29 * This layout is very sub-optimal, as the bitmap bits are stored in
30 * the X client instead of in the server like other bitmaps; however,
31 * some programs (notably Paint Brush) expect to be able to manipulate
32 * the bits directly :-(
33 *
34 * FIXME: what are we going to do with animation and color (bpp > 1) cursors ?!
35 *
36 **************************************************************************************************
37 *
38 * TODO: Scaling of system cursors (store them as resources in user32 instead of using PM pointers)
39 * TODO: We use the hColorBmp member of the CURSORICONINFO structure to store the PM cursor handle
40 * Might mess up PaintBrush (see above)
41 *
42 * Project Odin Software License can be found in LICENSE.TXT
43 *
44 */
45#include <os2win.h>
46#include <stdio.h>
47#include <string.h>
48#include <winicon.h>
49#include <win\cursoricon.h>
50#include <objhandle.h>
51#include "dib.h"
52#include <heapstring.h>
53#include <win\virtual.h>
54#include "initterm.h"
55#include "oslibres.h"
56#include "oslibwin.h"
57#include "dc.h"
58
59#define DBG_LOCALLOG DBG_winicon
60#include "dbglocal.h"
61
62
63/**********************************************************************
64 * ICONCACHE for cursors/icons loaded with LR_SHARED.
65 *
66 * FIXME: This should not be allocated on the system heap, but on a
67 * subsystem-global heap (i.e. one for all Win16 processes,
68 * and one for each Win32 process).
69 */
70typedef struct tagICONCACHE
71{
72 struct tagICONCACHE *next;
73
74 HMODULE hModule;
75 HRSRC hRsrc;
76 HRSRC hGroupRsrc;
77 HANDLE handle;
78 INT count;
79} ICONCACHE;
80
81static ICONCACHE *IconAnchor = NULL;
82static CRITICAL_SECTION IconCrst = CRITICAL_SECTION_INIT;
83static WORD ICON_HOTSPOT = 0x4242;
84static HCURSOR hActiveCursor = 0;
85static HCURSOR hActiveCursorPM = 0;
86
87
88static HGLOBAL CURSORICON_CreateFromResource( HINSTANCE hInstance, DWORD dwResGroupId, HGLOBAL hObj, LPBYTE bits,
89 UINT cbSize, BOOL bIcon, DWORD dwVersion, INT width, INT height, UINT loadflags );
90static HGLOBAL CURSORICON_Copy( HGLOBAL handle );
91static CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width,
92 int height, int colors );
93static CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir,
94 int width, int height, int color);
95BOOL CURSORICON_SimulateLoadingFromResourceW( LPWSTR filename, BOOL fCursor,
96 CURSORICONDIR **res, LPBYTE **ptr);
97
98static INT CURSORICON_DelSharedIcon( HANDLE handle );
99static void CURSORICON_AddSharedIcon( HMODULE hModule, HRSRC hRsrc, HRSRC hGroupRsrc, HANDLE handle );
100static HANDLE CURSORICON_FindSharedIcon( HMODULE hModule, HRSRC hRsrc );
101static ICONCACHE* CURSORICON_FindCache(HANDLE handle);
102
103static HGLOBAL CreateCursorIconIndirect( HINSTANCE hInstance,
104 CURSORICONINFO *info,
105 LPCVOID lpANDbits,
106 LPCVOID lpXORbits, BOOL fIcon);
107
108/***********************************************************************
109 * CreateIcon (USER32.75)
110 */
111HICON WIN32API CreateIcon(HINSTANCE hInstance, INT nWidth,
112 INT nHeight, BYTE bPlanes, BYTE bBitsPixel,
113 LPCVOID lpANDbits, LPCVOID lpXORbits )
114{
115 CURSORICONINFO info;
116
117 dprintf(("USER32: CreateIcon (%d,%d), %d, %x, %x", nWidth, nHeight, bPlanes * bBitsPixel, lpXORbits, lpANDbits));
118
119 info.ptHotSpot.x = ICON_HOTSPOT;
120 info.ptHotSpot.y = ICON_HOTSPOT;
121 info.nWidth = nWidth;
122 info.nHeight = nHeight;
123 info.nWidthBytes = 0;
124 info.bPlanes = bPlanes;
125 info.bBitsPerPixel = bBitsPixel;
126 info.hInstance = hInstance;
127 info.dwResGroupId = -1;
128 info.hColorBmp = 0;
129 return CreateCursorIconIndirect(0, &info, lpANDbits, lpXORbits, TRUE);
130}
131/**********************************************************************
132 * CreateIconFromResource (USER32.76)
133 */
134HICON WIN32API CreateIconFromResource(LPBYTE bits, UINT cbSize,
135 BOOL bIcon, DWORD dwVersion)
136{
137 return CreateIconFromResourceEx( bits, cbSize, bIcon, dwVersion, 0,0,0);
138}
139//******************************************************************************
140//******************************************************************************
141HICON WIN32API CreateIconFromResourceEx(LPBYTE bits, UINT cbSize,
142 BOOL bIcon, DWORD dwVersion,
143 INT width, INT height,
144 UINT cFlag )
145{
146 dprintf(("USER32: CreateIconFromResourceEx %X %d %d %X %d %d %X,", bits, cbSize, bIcon, dwVersion, width, height, cFlag));
147 return CURSORICON_CreateFromResource(0, -1, 0, bits, cbSize, bIcon, dwVersion, width, height, cFlag );
148}
149/**********************************************************************
150 * CreateIconIndirect (USER32.78)
151 */
152HICON WINAPI CreateIconIndirect(ICONINFO *iconinfo)
153{
154 BITMAP bmpXor,bmpAnd;
155 HICON hObj;
156 int sizeXor,sizeAnd,colortablesize;
157
158 dprintf(("USER32: CreateIconIndirect %x", iconinfo));
159
160 GetObjectA( iconinfo->hbmColor, sizeof(bmpXor), &bmpXor );
161 GetObjectA( iconinfo->hbmMask, sizeof(bmpAnd), &bmpAnd );
162
163 colortablesize = 0;
164
165 if(bmpXor.bmBitsPixel <= 8) {
166 colortablesize = sizeof(RGBQUAD)*(1<<bmpXor.bmBitsPixel);
167 sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes + colortablesize;
168 }
169 else sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
170
171 sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
172
173 hObj = GlobalAlloc( GMEM_MOVEABLE, sizeof(CURSORICONINFO) + sizeXor + sizeAnd );
174 if (hObj)
175 {
176 CURSORICONINFO *info;
177
178 info = (CURSORICONINFO *)GlobalLock( hObj );
179
180 /* If we are creating an icon, the hotspot is unused */
181 if (iconinfo->fIcon)
182 {
183 info->ptHotSpot.x = ICON_HOTSPOT;
184 info->ptHotSpot.y = ICON_HOTSPOT;
185 }
186 else
187 {
188 info->ptHotSpot.x = iconinfo->xHotspot;
189 info->ptHotSpot.y = iconinfo->yHotspot;
190 }
191
192 info->nWidth = bmpXor.bmWidth;
193 info->nHeight = bmpXor.bmHeight;
194 info->nWidthBytes = bmpXor.bmWidthBytes;
195 info->bPlanes = bmpXor.bmPlanes;
196 info->bBitsPerPixel = bmpXor.bmBitsPixel;
197 info->hInstance = -1;
198 info->dwResGroupId = -1;
199 info->hColorBmp = 0;
200
201 /* Transfer the bitmap bits to the CURSORICONINFO structure */
202 GetBitmapBits( iconinfo->hbmMask ,sizeAnd,(char*)(info + 1) );
203 if(bmpXor.bmBitsPixel > 1)
204 {
205 BITMAPINFO* pInfo = (BITMAPINFO *)malloc(sizeof(BITMAPINFO)+colortablesize+3*sizeof(DWORD)); //+ extra space for > 8bpp images
206 HBITMAP oldbmp;
207 HDC hdc;
208
209 hdc = CreateCompatibleDC(0);
210
211 memset(pInfo, 0, sizeof(BITMAPINFO)+colortablesize+3*sizeof(DWORD));
212 pInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
213 pInfo->bmiHeader.biPlanes = info->bPlanes;
214 pInfo->bmiHeader.biBitCount = info->bBitsPerPixel;
215
216 GetDIBits(hdc, iconinfo->hbmColor, 0, bmpXor.bmHeight, (char *)(info + 1) + sizeAnd + colortablesize, pInfo, DIB_RGB_COLORS);
217 if(colortablesize) {
218 memcpy((char *)(info + 1) + sizeAnd, (char *)&pInfo->bmiHeader + pInfo->bmiHeader.biSize, colortablesize);
219 }
220
221 DeleteDC(hdc);
222 free(pInfo);
223 }
224 else {
225 GetBitmapBits( iconinfo->hbmColor,sizeXor,(char*)(info + 1) +sizeAnd);
226 }
227
228#ifdef __WIN32OS2__
229 info->hColorBmp = OSLibWinCreatePointer(info, (char*)(info + 1), (LPBITMAP_W)&bmpAnd, (char*)(info + 1) + sizeAnd, (LPBITMAP_W)&bmpXor, FALSE);
230#endif
231 GlobalUnlock(hObj);
232
233#ifdef __WIN32OS2__
234 HICON hIcon;
235 if(ObjAllocateHandle(&hIcon, (DWORD)hObj, USEROBJ_CURSORICON) == FALSE) {
236 GlobalFree(hObj);
237 dprintf(("ERROR: CreateIconIndirect ObjAllocateHandle failed!!"));
238 return 0;
239 }
240#endif
241 dprintf(("USER32: CreateIconIndirect %x returned %x", iconinfo, hIcon));
242 return hIcon;
243 }
244 else {
245 dprintf(("ERROR: CreateIconIndirect GlobalAlloc failed!!"));
246 return 0;
247 }
248}
249//******************************************************************************
250//******************************************************************************
251BOOL WIN32API DestroyIcon( HICON hIcon)
252{
253 dprintf(("USER32: DestroyIcon %x", hIcon));
254 return CURSORICON_Destroy( hIcon, 0 );
255}
256//******************************************************************************
257//******************************************************************************
258HICON WIN32API CopyIcon( HICON hIcon)
259{
260 dprintf(("USER32: CopyIcon %x", hIcon));
261 return CURSORICON_Copy( hIcon );
262}
263//******************************************************************************
264//******************************************************************************
265HICON WIN32API GetOS2Icon(HICON hIcon)
266{
267 CURSORICONINFO *ciconinfo;
268
269 hIcon = ObjGetHandleData(hIcon, USEROBJ_CURSORICON);
270 if(hIcon == -1) {
271 dprintf(("ERROR: Invalid cursor/icon!"));
272 return 0;
273 }
274 ciconinfo = (CURSORICONINFO *)GlobalLock((HGLOBAL)hIcon);
275 if (!ciconinfo)
276 return 0;
277 HICON hOS2Icon = ciconinfo->hColorBmp;
278 GlobalUnlock(hIcon);
279 return hOS2Icon;
280}
281/**********************************************************************
282 * GetIconInfo (USER32.242)
283 */
284BOOL WINAPI GetIconInfo(HICON hIcon, ICONINFO *iconinfo)
285{
286 CURSORICONINFO *ciconinfo;
287
288 dprintf(("GetIconInfo %x %x", hIcon, iconinfo));
289
290#ifdef __WIN32OS2__
291 hIcon = ObjGetHandleData(hIcon, USEROBJ_CURSORICON);
292 if(hIcon == -1) {
293 dprintf(("ERROR: Invalid cursor/icon!"));
294 return 0;
295 }
296#endif
297 ciconinfo = (CURSORICONINFO *)GlobalLock((HGLOBAL)hIcon);
298 if (!ciconinfo)
299 return FALSE;
300
301 if((ciconinfo->ptHotSpot.x == ICON_HOTSPOT) &&
302 (ciconinfo->ptHotSpot.y == ICON_HOTSPOT))
303 {
304 iconinfo->fIcon = TRUE;
305 iconinfo->xHotspot = ciconinfo->nWidth / 2;
306 iconinfo->yHotspot = ciconinfo->nHeight / 2;
307 }
308 else
309 {
310 iconinfo->fIcon = FALSE;
311 iconinfo->xHotspot = ciconinfo->ptHotSpot.x;
312 iconinfo->yHotspot = ciconinfo->ptHotSpot.y;
313 }
314
315 //Create new bitmaps for the color and mask data; application is responsible
316 //for deleteing them (according to docs & verified in NT4)
317 if(ciconinfo->bBitsPerPixel > 1)
318 {
319 BITMAPINFO* pInfo;
320 int colorsize = 0;
321 int coloroff;
322
323 HDC hdc = CreateCompatibleDC(0);
324
325 if(ciconinfo->bBitsPerPixel <= 8) {
326 colorsize = (1<<ciconinfo->bBitsPerPixel)*sizeof(RGBQUAD);
327 }
328 else {
329 colorsize = 3*sizeof(DWORD); //color masks
330 }
331 pInfo = (BITMAPINFO *)malloc(ciconinfo->nHeight * ciconinfo->nWidthBytes + colorsize + sizeof(BITMAPINFO));
332 memset(pInfo, 0, sizeof(BITMAPINFO)+colorsize);
333
334 pInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
335 pInfo->bmiHeader.biWidth = ciconinfo->nWidth;
336 pInfo->bmiHeader.biHeight = ciconinfo->nHeight,
337 pInfo->bmiHeader.biPlanes = ciconinfo->bPlanes;
338 pInfo->bmiHeader.biBitCount = ciconinfo->bBitsPerPixel;
339 pInfo->bmiHeader.biSizeImage= ciconinfo->nHeight * ciconinfo->nWidthBytes;
340
341 //offset in cursorinfo memory
342 coloroff = ciconinfo->nHeight * BITMAP_GetWidthBytes (ciconinfo->nWidth, 1);
343
344 char *src = (char *)(ciconinfo + 1) + coloroff;
345 if(ciconinfo->bBitsPerPixel <= 8) {
346 src += colorsize; //no color masks in cursorinfo data for bpp > 8
347 }
348 if(ciconinfo->bBitsPerPixel <= 8) {
349 memcpy(&pInfo->bmiColors[0], (char *)(ciconinfo + 1) + coloroff, colorsize);
350 }
351 //else TODO: color masks (currently unused in CreateDIBitmap)
352
353 iconinfo->hbmColor = CreateDIBitmap(hdc, &pInfo->bmiHeader, CBM_INIT, src, pInfo, DIB_RGB_COLORS);
354
355 free(pInfo);
356 DeleteDC(hdc);
357 }
358 else {
359 iconinfo->hbmColor = CreateBitmap ( ciconinfo->nWidth, ciconinfo->nHeight,
360 ciconinfo->bPlanes, ciconinfo->bBitsPerPixel,
361 (char *)(ciconinfo + 1)
362 + ciconinfo->nHeight *
363 BITMAP_GetWidthBytes (ciconinfo->nWidth, 1) );
364 }
365
366 iconinfo->hbmMask = CreateBitmap ( ciconinfo->nWidth, ciconinfo->nHeight,
367 1, 1, (char *)(ciconinfo + 1));
368
369 GlobalUnlock(hIcon);
370
371 return TRUE;
372}
373//******************************************************************************
374//******************************************************************************
375HCURSOR WIN32API CreateCursor(HINSTANCE hInst, int xHotSpot, int yHotSpot, int nWidth, int nHeight,
376 const VOID *lpANDbits, const VOID *lpXORbits)
377{
378 CURSORICONINFO info;
379
380 dprintf(("CreateCursor %dx%d spot=%d,%d xor=%p and=%p\n",
381 nWidth, nHeight, xHotSpot, yHotSpot, lpXORbits, lpANDbits));
382
383 info.ptHotSpot.x = xHotSpot;
384 info.ptHotSpot.y = yHotSpot;
385 info.nWidth = nWidth;
386 info.nHeight = nHeight;
387 info.nWidthBytes = 0;
388 info.bPlanes = 1;
389 info.bBitsPerPixel = 1;
390 info.hInstance = hInst;
391 info.dwResGroupId = -1;
392 info.hColorBmp = 0;
393
394 return CreateCursorIconIndirect( 0, &info, lpANDbits, lpXORbits, FALSE);
395}
396//******************************************************************************
397//******************************************************************************
398BOOL WIN32API DestroyCursor( HCURSOR hCursor)
399{
400 dprintf(("USER32: DestroyCursor %x", hCursor));
401 return CURSORICON_Destroy( hCursor, CID_WIN32 );
402}
403//******************************************************************************
404//******************************************************************************
405HCURSOR WIN32API GetCursor(void)
406{
407 dprintf2(("USER32: GetCursor"));
408 if(hActiveCursorPM && hActiveCursorPM != OSLibWinQueryPointer()) {
409 dprintf(("Another app changed mouse cursor"));
410 hActiveCursorPM = hActiveCursor = 0;
411 }
412 return hActiveCursor;
413}
414//******************************************************************************
415//******************************************************************************
416HCURSOR WIN32API SetCursor( HCURSOR hCursor)
417{
418 HCURSOR hOldCursor;
419
420 dprintf(("USER32: SetCursor %x (prev %x)", hCursor, hActiveCursor));
421 GetCursor();
422 if (hCursor == hActiveCursor) return hActiveCursor; /* No change */
423
424 hOldCursor = hActiveCursor;
425 hActiveCursor = hCursor;
426
427#ifdef __WIN32OS2__
428 hCursor = ObjGetHandleData(hCursor, USEROBJ_CURSORICON);
429 if(hCursor == -1) {
430 dprintf(("ERROR: Invalid cursor/icon!"));
431 return 0;
432 }
433#endif
434
435 CURSORICONINFO *iconinfo = (CURSORICONINFO *)GlobalLock((HGLOBAL)hCursor);
436 if (!iconinfo) {
437 dprintf(("ERROR: Invalid cursor!"));
438 return 0;
439 }
440 if(!iconinfo->hColorBmp) {
441 dprintf(("SetCursor: invalid os/2 pointer handle!!"));
442 }
443
444 if(OSLibWinSetPointer(iconinfo->hColorBmp) == FALSE) {
445 dprintf(("OSLibWinSetPointer %x returned FALSE!!", iconinfo->hColorBmp));
446 }
447 hActiveCursorPM = iconinfo->hColorBmp;
448 GlobalUnlock(hCursor);
449
450 return hOldCursor;
451}
452//******************************************************************************
453//******************************************************************************
454BOOL WIN32API GetCursorPos( PPOINT lpPoint)
455{
456 dprintf2(("USER32: GetCursorPos %x", lpPoint));
457
458 if (!lpPoint) return FALSE;
459
460 if (OSLibWinQueryPointerPos(lpPoint)) //POINT == POINTL
461 {
462 mapScreenPoint((OSLIBPOINT*)lpPoint);
463 return TRUE;
464 }
465 else return FALSE;
466}
467//******************************************************************************
468//******************************************************************************
469BOOL WIN32API SetCursorPos( int X, int Y)
470{
471 dprintf(("USER32: SetCursorPos %d %d", X,Y));
472 return OSLibWinSetPointerPos(X, mapScreenY(Y));
473}
474//******************************************************************************
475//******************************************************************************
476BOOL WIN32API ClipCursor(const RECT * lpRect)
477{
478 if(lpRect) {
479 dprintf(("USER32: ClipCursor (%d,%d)(%d,%d)", lpRect->left, lpRect->top, lpRect->right, lpRect->bottom));
480 }
481 else dprintf(("USER32: ClipCursor NULL"));
482 return OSLibWinClipCursor(lpRect);
483}
484//******************************************************************************
485//******************************************************************************
486BOOL WIN32API GetClipCursor( LPRECT lpRect)
487{
488 dprintf(("USER32: GetClipCursor %x", lpRect));
489 return OSLibWinGetClipCursor(lpRect);
490}
491//******************************************************************************
492//******************************************************************************
493/*****************************************************************************
494 * Name : BOOL WIN32API SetSystemCursor
495 * Purpose : The SetSystemCursor function replaces the contents of the system
496 * cursor specified by dwCursorId with the contents of the cursor
497 * specified by hCursor, and then destroys hCursor. This function
498 * lets an application customize the system cursors.
499 * Parameters: HCURSOR hCursor set specified system cursor to this cursor's
500 * contents, then destroy this
501 * DWORD dwCursorID system cursor specified by its identifier
502 * Variables :
503 * Result : If the function succeeds, the return value is TRUE.
504 * If the function fails, the return value is FALSE. To get extended
505 * error information, call GetLastError.
506 * Remark :
507 * Status : UNTESTED STUB
508 *
509 * Author : Patrick Haller [Thu, 1998/02/26 11:55]
510 *****************************************************************************/
511BOOL WIN32API SetSystemCursor(HCURSOR hCursor, DWORD dwCursorId)
512{
513 dprintf(("USER32:SetSystemCursor (%08xh,%08x) not supported.\n",
514 hCursor,
515 dwCursorId));
516
517 return DestroyCursor(hCursor);
518}
519//******************************************************************************
520//******************************************************************************
521INT OPEN32API __ShowCursor(BOOL bShow);
522
523inline INT _ShowCursor (BOOL bShow)
524{
525 INT yyrc;
526 USHORT sel = RestoreOS2FS();
527
528 yyrc = __ShowCursor(bShow);
529 SetFS(sel);
530
531 return yyrc;
532}
533//******************************************************************************
534static int cursorshowcnt = 0;
535//******************************************************************************
536void RestoreCursor()
537{
538 dprintf2(("USER32: RestoreCursor %d", cursorshowcnt));
539 while(cursorshowcnt != 0)
540 {
541 if(cursorshowcnt > 0 )
542 {
543 ShowCursor(FALSE);
544 }
545 else
546 {
547 ShowCursor(TRUE);
548 }
549 }
550}
551//******************************************************************************
552//******************************************************************************
553int WIN32API ShowCursor(BOOL bShow)
554{
555 dprintf2(("USER32: ShowCursor %d", bShow));
556 cursorshowcnt = cursorshowcnt + ((bShow) ? 1 : -1);
557 return _ShowCursor(bShow);
558}
559/***********************************************************************
560 * CreateCursorIconIndirect
561 */
562static HGLOBAL CreateCursorIconIndirect( HINSTANCE hInstance,
563 CURSORICONINFO *info,
564 LPCVOID lpANDbits,
565 LPCVOID lpXORbits, BOOL fIcon)
566{
567 HGLOBAL handle;
568 char *ptr;
569 int sizeAnd, sizeXor;
570#ifdef __WIN32OS2__
571 BITMAP bmpXor, bmpAnd;
572#endif
573
574 if (!lpXORbits || !lpANDbits || info->bPlanes != 1) return 0;
575 info->nWidthBytes = BITMAP_GetWidthBytes(info->nWidth,info->bBitsPerPixel);
576 sizeXor = info->nHeight * info->nWidthBytes;
577 sizeAnd = info->nHeight * BITMAP_GetWidthBytes( info->nWidth, 1 );
578 if (!(handle = GlobalAlloc( GMEM_MOVEABLE,
579 sizeof(CURSORICONINFO) + sizeXor + sizeAnd)))
580 return 0;
581 ptr = (char *)GlobalLock( handle );
582 memcpy( ptr, info, sizeof(*info) );
583 memcpy( ptr + sizeof(CURSORICONINFO), lpANDbits, sizeAnd );
584 memcpy( ptr + sizeof(CURSORICONINFO) + sizeAnd, lpXORbits, sizeXor );
585#ifdef __WIN32OS2__
586 bmpAnd.bmType = 0;
587 bmpAnd.bmWidth = info->nWidth;
588 bmpAnd.bmHeight = info->nHeight;
589 bmpAnd.bmWidthBytes = BITMAP_GetWidthBytes(info->nWidth, 1);
590 bmpAnd.bmPlanes = info->bPlanes;
591 bmpAnd.bmBitsPixel = 1;
592 bmpAnd.bmBits = NULL;
593
594 bmpXor.bmType = 0;
595 bmpXor.bmWidth = info->nWidth;
596 bmpXor.bmHeight = info->nHeight;
597 bmpXor.bmWidthBytes = info->nWidthBytes;
598 bmpXor.bmPlanes = info->bPlanes;
599 bmpXor.bmBitsPixel = info->bBitsPerPixel;
600 bmpXor.bmBits = NULL;
601 ((CURSORICONINFO *)ptr)->hColorBmp =
602 OSLibWinCreatePointer(info, (char *)lpANDbits, (LPBITMAP_W)&bmpAnd, (char *)lpXORbits, (LPBITMAP_W)&bmpXor, fIcon == FALSE);
603#endif
604 GlobalUnlock( handle );
605
606#ifdef __WIN32OS2__
607 HICON hIcon;
608 if(ObjAllocateHandle(&hIcon, (DWORD)handle, USEROBJ_CURSORICON) == FALSE) {
609 GlobalFree(handle);
610 dprintf(("ERROR: CreateCursorIconIndirect ObjAllocateHandle failed!!"));
611 return 0;
612 }
613 dprintf(("USER32: CreateCursorIconIndirect returned %x", hIcon));
614 return hIcon;
615#else
616 return handle;
617#endif
618}
619/**********************************************************************
620 * CURSORICON_Load
621 *
622 * Load a cursor or icon from resource or file.
623 */
624HGLOBAL CURSORICON_Load( HINSTANCE hInstance, LPCWSTR name,
625 INT width, INT height, INT colors,
626 BOOL fCursor, UINT loadflags )
627{
628 HANDLE handle = 0, h = 0;
629 HANDLE hRsrc;
630 CURSORICONDIR *dir;
631 CURSORICONDIRENTRY *dirEntry;
632 LPBYTE bits;
633
634#ifdef __WIN32OS2__
635 //TODO: Can system cursors be loaded by name??? (#xxx)
636 if (fCursor && hInstance == NULL && !HIWORD(name))
637 {
638 HCURSOR hCursor = OSLibWinQuerySysPointer((ULONG)name, width, height);
639 if(hCursor)
640 {
641 /* If shared icon, check whether it was already loaded */
642 if ((loadflags & LR_SHARED)
643 && (h = CURSORICON_FindSharedIcon( -1, hCursor ) ) != 0 )
644 {
645 dprintf(("Found icon/cursor in cache; returned old handle %x", h));
646 return h;
647 }
648
649 HANDLE hObj = GlobalAlloc( GMEM_MOVEABLE, sizeof(CURSORICONINFO));
650 if (!hObj)
651 {
652 DebugInt3();
653 return 0;
654 }
655 CURSORICONINFO *info;
656
657 info = (CURSORICONINFO *)GlobalLock( hObj );
658 info->ptHotSpot.x = 0;
659 info->ptHotSpot.y = 0;
660 info->nWidth = width;
661 info->nHeight = height;
662 info->nWidthBytes = width*height/8;
663 info->bPlanes = 1;
664 info->bBitsPerPixel = 1;
665 info->hColorBmp = hCursor;
666 info->hInstance = -1;
667 info->dwResGroupId = -1;
668
669 HICON hIcon;
670 if(ObjAllocateHandle(&hIcon, (DWORD)hObj, USEROBJ_CURSORICON) == FALSE) {
671 GlobalUnlock( hObj );
672 GlobalFree(hObj);
673 dprintf(("ERROR: CURSORICON_Load ObjAllocateHandle failed!!"));
674 return 0;
675 }
676
677 if (loadflags & LR_SHARED )
678 CURSORICON_AddSharedIcon( -1, hCursor, -1, hIcon );
679
680 GlobalUnlock( hObj );
681
682 return hIcon;
683 }
684 }
685#endif
686 if ( loadflags & LR_LOADFROMFILE ) /* Load from file */
687 {
688 LPBYTE *ptr;
689
690 if (!CURSORICON_SimulateLoadingFromResourceW((LPWSTR)name, fCursor, &dir, &ptr))
691 return 0;
692 if (fCursor)
693 dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestCursor(dir, width, height, 1);
694 else
695 dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestIcon(dir, width, height, colors);
696 bits = ptr[dirEntry->wResId-1];
697 h = CURSORICON_CreateFromResource( 0, -1, 0, bits, dirEntry->dwBytesInRes,
698 !fCursor, 0x00030000, width, height, loadflags);
699
700 HeapFree( GetProcessHeap(), 0, dir );
701 HeapFree( GetProcessHeap(), 0, ptr );
702 }
703 else /* Load from resource */
704 {
705 HANDLE hGroupRsrc;
706 WORD wResId;
707 DWORD dwBytesInRes;
708 BOOL bIsGroup = TRUE;
709
710 /* Get directory resource ID */
711 if (!hInstance)
712 {
713 hRsrc = FindResourceW(hInstanceUser32, name, fCursor ? RT_CURSORW : RT_ICONW);
714 if(!hRsrc) {
715 hRsrc = FindResourceW(hInstanceUser32, name, fCursor ? RT_GROUP_CURSORW : RT_GROUP_ICONW);
716 }
717 else bIsGroup = FALSE;
718
719 if(!hRsrc) return 0;
720
721 hInstance = hInstanceUser32;
722 }
723 else {
724 hRsrc = FindResourceW(hInstance, name, fCursor ? RT_GROUP_CURSORW : RT_GROUP_ICONW);
725 if(!hRsrc) return 0;
726 }
727 hGroupRsrc = hRsrc;
728
729 if(bIsGroup) {
730 /* Find the best entry in the directory */
731
732 if (!(handle = LoadResource( hInstance, hRsrc ))) return 0;
733 if (!(dir = (CURSORICONDIR*)LockResource( handle ))) return 0;
734
735 if (fCursor)
736 dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestCursor( dir,
737 width, height, 1);
738 else
739 dirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestIcon( dir,
740 width, height, colors );
741 if (!dirEntry) return 0;
742 wResId = dirEntry->wResId;
743 dwBytesInRes = dirEntry->dwBytesInRes;
744 FreeResource( handle );
745
746 /* Load the resource */
747 if (!(hRsrc = FindResourceW(hInstance,MAKEINTRESOURCEW(wResId),
748 fCursor ? RT_CURSORW : RT_ICONW ))) return 0;
749 }
750
751 /* If shared icon, check whether it was already loaded */
752 if ((loadflags & LR_SHARED)
753 && (h = CURSORICON_FindSharedIcon( hInstance, hRsrc ) ) != 0 )
754 {
755 dprintf(("Found icon/cursor in cache; returned old handle %x", h));
756 return h;
757 }
758
759 if (!(handle = LoadResource( hInstance, hRsrc ))) return 0;
760 bits = (LPBYTE)LockResource( handle );
761 h = CURSORICON_CreateFromResource( hInstance, (DWORD)name, 0, bits, dwBytesInRes,
762 !fCursor, 0x00030000, width, height, loadflags);
763 FreeResource( handle );
764
765 /* If shared icon, add to icon cache */
766
767 if ( h && (loadflags & LR_SHARED) )
768 CURSORICON_AddSharedIcon( hInstance, hRsrc, hGroupRsrc, h );
769
770 }
771
772 return h;
773}
774
775/*********************************************************************
776 * The main purpose of this function is to create fake resource directory
777 * and fake resource entries. There are several reasons for this:
778 * - CURSORICONDIR and CURSORICONFILEDIR differ in sizes and their
779 * fields
780 * There are some "bad" cursor files which do not have
781 * bColorCount initialized but instead one must read this info
782 * directly from corresponding DIB sections
783 * Note: wResId is index to array of pointer returned in ptrs (origin is 1)
784 */
785BOOL CURSORICON_SimulateLoadingFromResourceW( LPWSTR filename, BOOL fCursor,
786 CURSORICONDIR **res, LPBYTE **ptr)
787{
788 LPBYTE _free;
789 CURSORICONFILEDIR *bits;
790 int entries, size, i;
791 HANDLE hMapping = 0;
792
793 *res = NULL;
794 *ptr = NULL;
795
796 hMapping = VIRTUAL_MapFileW( filename, (LPVOID *)&bits, TRUE);
797 if(hMapping == INVALID_HANDLE_VALUE)
798 return FALSE;
799
800 /* FIXME: test for inimated icons
801 * hack to load the first icon from the *.ani file
802 */
803 if ( *(LPDWORD)bits==0x46464952 ) /* "RIFF" */
804 {
805 LPBYTE pos = (LPBYTE) bits;
806 dprintf(("Animated icons not correctly implemented! %p \n", bits));
807
808 for (;;)
809 {
810 if (*(LPDWORD)pos==0x6e6f6369) /* "icon" */
811 {
812 dprintf(("icon entry found! %p\n", bits));
813 pos+=4;
814 if ( !*(LPWORD) pos==0x2fe) /* iconsize */
815 {
816 goto fail;
817 }
818 bits=(CURSORICONFILEDIR*)(pos+4);
819 dprintf(("icon size ok. offset=%p \n", bits));
820 break;
821 }
822 pos+=2;
823 if (pos>=(LPBYTE)bits+766) goto fail;
824 }
825 }
826 if (!(entries = bits->idCount)) goto fail;
827 size = sizeof(CURSORICONDIR) + sizeof(CURSORICONDIRENTRY) * (entries - 1);
828 _free = (LPBYTE) size;
829
830 for (i=0; i < entries; i++)
831 size += bits->idEntries[i].dwDIBSize + (fCursor ? sizeof(POINT16): 0);
832
833 if (!(*ptr = (LPBYTE *)HeapAlloc( GetProcessHeap(), 0,
834 entries * sizeof (CURSORICONDIRENTRY*)))) goto fail;
835 if (!(*res = (CURSORICONDIR *)HeapAlloc( GetProcessHeap(), 0, size))) goto fail;
836
837 _free = (LPBYTE)(*res) + (int)_free;
838 memcpy((*res), bits, 6);
839 for (i=0; i<entries; i++)
840 {
841 ((LPBYTE*)(*ptr))[i] = _free;
842 if (fCursor) {
843 (*res)->idEntries[i].ResInfo.cursor.wWidth=bits->idEntries[i].bWidth;
844 (*res)->idEntries[i].ResInfo.cursor.wHeight=bits->idEntries[i].bHeight;
845 ((LPPOINT16)_free)->x=bits->idEntries[i].xHotspot;
846 ((LPPOINT16)_free)->y=bits->idEntries[i].yHotspot;
847 _free+=sizeof(POINT16);
848 }
849 else {
850 (*res)->idEntries[i].ResInfo.icon.bWidth=bits->idEntries[i].bWidth;
851 (*res)->idEntries[i].ResInfo.icon.bHeight=bits->idEntries[i].bHeight;
852 (*res)->idEntries[i].ResInfo.icon.bColorCount = bits->idEntries[i].bColorCount;
853 }
854 (*res)->idEntries[i].wPlanes=1;
855 (*res)->idEntries[i].wBitCount = ((LPBITMAPINFOHEADER)((LPBYTE)bits +
856 bits->idEntries[i].dwDIBOffset))->biBitCount;
857 (*res)->idEntries[i].dwBytesInRes = bits->idEntries[i].dwDIBSize;
858 (*res)->idEntries[i].wResId=i+1;
859
860 memcpy(_free,(LPBYTE)bits +bits->idEntries[i].dwDIBOffset,
861 (*res)->idEntries[i].dwBytesInRes);
862 _free += (*res)->idEntries[i].dwBytesInRes;
863 }
864 UnmapViewOfFile( bits );
865 CloseHandle(hMapping);
866 return TRUE;
867
868fail:
869 if (*res) HeapFree( GetProcessHeap(), 0, *res );
870 if (*ptr) HeapFree( GetProcessHeap(), 0, *ptr );
871
872 UnmapViewOfFile( bits );
873 CloseHandle(hMapping);
874 return FALSE;
875}
876
877/**********************************************************************
878 * CURSORICON_CreateFromResource
879 *
880 * Create a cursor or icon from in-memory resource template.
881 *
882 * FIXME: Convert to mono when cFlag is LR_MONOCHROME. Do something
883 * with cbSize parameter as well.
884 */
885static HGLOBAL CURSORICON_CreateFromResource( HINSTANCE hInstance, DWORD dwResGroupId, HGLOBAL hObj, LPBYTE bits,
886 UINT cbSize, BOOL bIcon, DWORD dwVersion,
887 INT width, INT height, UINT loadflags )
888{
889 int sizeAnd, sizeXor;
890 HBITMAP hAndBits = 0, hXorBits = 0; /* error condition for later */
891 BITMAP bmpXor, bmpAnd;
892 POINT16 hotspot;
893 BITMAPINFO *bmi;
894 HDC hdc = 0;
895 BOOL DoStretch;
896 INT size, colortablesize, bwsize, colorsize;
897
898 hotspot.x = ICON_HOTSPOT;
899 hotspot.y = ICON_HOTSPOT;
900
901 dprintf2(("CURSORICON_CreateFromResource %x %x %x %x %d", hInstance, dwResGroupId, hObj, bits, cbSize));
902
903 if (dwVersion == 0x00020000)
904 {
905 dprintf(("CURSORICON_CreateFromResource 2.xx resources are not supported"));
906 return 0;
907 }
908
909 if (bIcon) {
910 bmi = (BITMAPINFO *)bits;
911 }
912 else /* get the hotspot */
913 {
914 POINT16 *pt = (POINT16 *)bits;
915 hotspot = *pt;
916 bmi = (BITMAPINFO *)(pt + 1);
917 }
918 size = DIB_BitmapInfoSize(bmi, DIB_RGB_COLORS);
919
920 if (!width) width = bmi->bmiHeader.biWidth;
921 if (!height) height = bmi->bmiHeader.biHeight/2;
922
923 DoStretch = (bmi->bmiHeader.biHeight/2 != height) || (bmi->bmiHeader.biWidth != width);
924
925 colorsize = DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight/2, bmi->bmiHeader.biBitCount);
926 bwsize = (bmi->bmiHeader.biWidth * bmi->bmiHeader.biHeight/2)/8;
927
928 /* Check bitmap header */
929 if((bmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) &&
930 (bmi->bmiHeader.biSize != sizeof(BITMAPINFOHEADER) ||
931 bmi->bmiHeader.biCompression != BI_RGB) )
932 {
933 return 0;
934 }
935
936#ifdef __WIN32OS2__
937 if( (hdc = CreateCompatibleDC( 0 )) )
938#else
939 if( (hdc = GetDC( 0 )) )
940#endif
941 {
942 BITMAPINFO* pInfo;
943
944 /* Make sure we have room for the monochrome bitmap later on.
945 * Note that BITMAPINFOINFO and BITMAPCOREHEADER are the same
946 * up to and including the biBitCount. In-memory icon resource
947 * format is as follows:
948 *
949 * BITMAPINFOHEADER icHeader // DIB header
950 * RGBQUAD icColors[] // Color table
951 * BYTE icXOR[] // DIB bits for XOR mask
952 * BYTE icAND[] // DIB bits for AND mask
953 */
954
955 if ((pInfo = (BITMAPINFO *)HeapAlloc( GetProcessHeap(), 0,
956 max(size, sizeof(BITMAPINFOHEADER) + 2*sizeof(RGBQUAD)))))
957 {
958 memcpy( pInfo, bmi, size );
959 pInfo->bmiHeader.biHeight /= 2;
960
961 /* Create the XOR bitmap */
962 if (DoStretch)
963 {
964 if(bIcon)
965 {
966 hXorBits = CreateCompatibleBitmap(hdc, width, height);
967 }
968 else
969 {
970 hXorBits = CreateBitmap(width, height, 1, 1, NULL);
971 }
972 if(hXorBits)
973 {
974 HBITMAP hOld;
975 HDC hMem = CreateCompatibleDC(hdc);
976 BOOL res;
977
978 if (hMem) {
979 hOld = SelectObject(hMem, hXorBits);
980 res = StretchDIBits(hMem, 0, 0, width, height, 0, 0,
981 bmi->bmiHeader.biWidth, bmi->bmiHeader.biHeight/2,
982 (char*)bmi + size, pInfo, DIB_RGB_COLORS, SRCCOPY);
983 SelectObject(hMem, hOld);
984 DeleteDC(hMem);
985 }
986 else res = FALSE;
987 if (!res) {
988 DeleteObject(hXorBits);
989 hXorBits = 0;
990 }
991 }
992 }
993 else
994 {
995 hXorBits = CreateDIBitmap(hdc, &pInfo->bmiHeader,
996 CBM_INIT, (char*)bmi + size, pInfo, DIB_RGB_COLORS );
997 }
998 if( hXorBits )
999 {
1000 char* xbits = (char *)bmi + size + DIB_GetDIBImageBytes(bmi->bmiHeader.biWidth,
1001 bmi->bmiHeader.biHeight,
1002 bmi->bmiHeader.biBitCount) / 2;
1003
1004 pInfo->bmiHeader.biBitCount = 1;
1005 if (pInfo->bmiHeader.biSize == sizeof(BITMAPINFOHEADER))
1006 {
1007 RGBQUAD *rgb = pInfo->bmiColors;
1008
1009 pInfo->bmiHeader.biClrUsed = pInfo->bmiHeader.biClrImportant = 2;
1010 rgb[0].rgbBlue = rgb[0].rgbGreen = rgb[0].rgbRed = 0x00;
1011 rgb[1].rgbBlue = rgb[1].rgbGreen = rgb[1].rgbRed = 0xff;
1012 rgb[0].rgbReserved = rgb[1].rgbReserved = 0;
1013 }
1014 else
1015 {
1016 RGBTRIPLE *rgb = (RGBTRIPLE *)(((BITMAPCOREHEADER *)pInfo) + 1);
1017
1018 rgb[0].rgbtBlue = rgb[0].rgbtGreen = rgb[0].rgbtRed = 0x00;
1019 rgb[1].rgbtBlue = rgb[1].rgbtGreen = rgb[1].rgbtRed = 0xff;
1020 }
1021
1022 /* Create the AND bitmap */
1023 if (DoStretch)
1024 {
1025 if ((hAndBits = CreateBitmap(width, height, 1, 1, NULL)))
1026 {
1027 HBITMAP hOld;
1028 HDC hMem = CreateCompatibleDC(hdc);
1029 BOOL res;
1030
1031 if (hMem) {
1032 hOld = SelectObject(hMem, hAndBits);
1033//SvL: This also doesn't work as StretchDIBits doesn't handle 1bpp bitmaps correctly
1034//--------->>> hack alert!
1035#if 1
1036 HBITMAP hBmp, hOld1;
1037 HDC hMem1;
1038
1039 hMem1 = CreateCompatibleDC(hdc);
1040
1041 int linewidth = BITMAP_GetWidthBytes(pInfo->bmiHeader.biWidth, 1);
1042
1043 char *newpix = (char *)malloc(linewidth*pInfo->bmiHeader.biHeight);
1044
1045 newpix += ((pInfo->bmiHeader.biHeight-1)*linewidth);
1046
1047 if(cbSize - size - colorsize - bwsize == bwsize)
1048 {//this means an AND and XOR mask is present (interleaved; and/xor)
1049 for(int i=0;i<pInfo->bmiHeader.biHeight;i++) {
1050 memcpy(newpix, xbits, linewidth);
1051 newpix -= linewidth;
1052 xbits += linewidth*2;
1053 }
1054 }
1055 else {
1056 for(int i=0;i<pInfo->bmiHeader.biHeight;i++) {
1057 memcpy(newpix, xbits, linewidth);
1058 newpix -= linewidth;
1059 xbits += linewidth;
1060 }
1061 }
1062 newpix += linewidth;
1063 hBmp = CreateBitmap(pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight, 1, 1, newpix);
1064 free(newpix);
1065
1066 hOld1 = SelectObject(hMem1, hBmp);
1067
1068 res = StretchBlt(hMem, 0, 0, width, height, hMem1, 0, 0, pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight, SRCCOPY);
1069
1070 SelectObject(hMem1, hOld1);
1071 DeleteObject(hBmp);
1072 DeleteDC(hMem1);
1073
1074
1075#else
1076 res = StretchDIBits(hMem, 0, 0, width, height, 0, 0,
1077 pInfo->bmiHeader.biWidth, pInfo->bmiHeader.biHeight,
1078 xbits, pInfo, DIB_RGB_COLORS, SRCCOPY);
1079#endif
1080 SelectObject(hMem, hOld);
1081 DeleteDC(hMem);
1082 }
1083 else res = FALSE;
1084 if (!res) {
1085 DeleteObject(hAndBits);
1086 hAndBits = 0;
1087 }
1088 }
1089 }
1090 else {
1091//SvL: Must use CreateBitmap here as CreateDIBitmap converts data to 8bpp (GetObjectA info -> 8 bpp)
1092#if 1
1093 int linewidth = BITMAP_GetWidthBytes(width, 1);
1094
1095 char *newpix = (char *)malloc(linewidth*height);
1096
1097 newpix += ((height-1)*linewidth);
1098
1099 if(cbSize - size - colorsize - bwsize == bwsize)
1100 {//this means an AND and XOR mask is present (interleaved; and/xor)
1101 for(int i=0;i<height;i++) {
1102 memcpy(newpix, xbits, linewidth);
1103 newpix -= linewidth;
1104 xbits += linewidth*2;
1105 }
1106 }
1107 else {
1108 for(int i=0;i<height;i++) {
1109 memcpy(newpix, xbits, linewidth);
1110 newpix -= linewidth;
1111 xbits += linewidth;
1112 }
1113 }
1114 newpix += linewidth;
1115 hAndBits = CreateBitmap(width, height, 1, 1, newpix);
1116
1117 free(newpix);
1118
1119#else
1120 hAndBits = CreateDIBitmap(hdc, &pInfo->bmiHeader,
1121 CBM_INIT, xbits, pInfo, DIB_RGB_COLORS );
1122#endif
1123 }
1124 if( !hAndBits )
1125 DeleteObject( hXorBits );
1126 }
1127 HeapFree( GetProcessHeap(), 0, pInfo );
1128 }
1129#ifdef __WIN32OS2__
1130 DeleteDC(hdc );
1131#else
1132 ReleaseDC( 0, hdc );
1133#endif
1134 }
1135
1136 if( !hXorBits || !hAndBits )
1137 {
1138 dprintf(("\tunable to create an icon bitmap."));
1139 return 0;
1140 }
1141
1142 /* Now create the CURSORICONINFO structure */
1143 GetObjectA( hXorBits, sizeof(bmpXor), &bmpXor );
1144 GetObjectA( hAndBits, sizeof(bmpAnd), &bmpAnd );
1145 colortablesize = 0;
1146
1147 if(bmpXor.bmBitsPixel <= 8) {
1148 colortablesize = sizeof(RGBQUAD)*(1<<bmpXor.bmBitsPixel);
1149 sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes + colortablesize;
1150 }
1151 else sizeXor = bmpXor.bmHeight * bmpXor.bmWidthBytes;
1152
1153 sizeAnd = bmpAnd.bmHeight * bmpAnd.bmWidthBytes;
1154
1155 if (hObj) hObj = GlobalReAlloc( hObj,
1156 sizeof(CURSORICONINFO) + sizeXor + sizeAnd, GMEM_MOVEABLE );
1157 if (!hObj) hObj = GlobalAlloc( GMEM_MOVEABLE,
1158 sizeof(CURSORICONINFO) + sizeXor + sizeAnd );
1159 if (hObj)
1160 {
1161 CURSORICONINFO *info;
1162
1163 info = (CURSORICONINFO *)GlobalLock( hObj );
1164 info->ptHotSpot.x = hotspot.x;
1165 info->ptHotSpot.y = hotspot.y;
1166 info->nWidth = bmpXor.bmWidth;
1167 info->nHeight = bmpXor.bmHeight;
1168 info->nWidthBytes = bmpXor.bmWidthBytes;
1169 info->bPlanes = bmpXor.bmPlanes;
1170 info->bBitsPerPixel = bmpXor.bmBitsPixel;
1171 info->hInstance = hInstance;
1172 info->dwResGroupId = dwResGroupId;
1173 info->hColorBmp = 0;
1174
1175 /* Transfer the bitmap bits to the CURSORICONINFO structure */
1176 GetBitmapBits( hAndBits, sizeAnd, (char *)(info + 1));
1177
1178 if(bmpXor.bmBitsPixel > 1)
1179 {
1180 BITMAPINFO* pInfo = (BITMAPINFO *)malloc(sizeof(BITMAPINFO)+colortablesize+3*sizeof(DWORD)); //+ extra space for > 8bpp images
1181 HBITMAP oldbmp;
1182
1183 hdc = CreateCompatibleDC(0);
1184
1185 memset(pInfo, 0, sizeof(BITMAPINFO)+colortablesize+3*sizeof(DWORD));
1186 pInfo->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
1187 pInfo->bmiHeader.biPlanes = info->bPlanes;
1188 pInfo->bmiHeader.biBitCount = info->bBitsPerPixel;
1189
1190 GetDIBits(hdc, hXorBits, 0, bmpXor.bmHeight, (char *)(info + 1) + sizeAnd + colortablesize, pInfo, DIB_RGB_COLORS);
1191 if(colortablesize) {
1192 memcpy((char *)(info + 1) + sizeAnd, (char *)&pInfo->bmiHeader + pInfo->bmiHeader.biSize, colortablesize);
1193 }
1194
1195 DeleteDC(hdc);
1196 free(pInfo);
1197 }
1198 else {
1199 GetBitmapBits( hXorBits, sizeXor, (char *)(info + 1) + sizeAnd);
1200 }
1201 info->hColorBmp = OSLibWinCreatePointer(info, (char *)(info + 1), (LPBITMAP_W)&bmpAnd, (char *)(info + 1) + sizeAnd, (LPBITMAP_W)&bmpXor, bIcon == FALSE);
1202 dprintf(("Create cursor/icon %x with OS/2 pointer handle %x", hObj, info->hColorBmp));
1203 GlobalUnlock( hObj );
1204 }
1205
1206 DeleteObject( hAndBits );
1207 DeleteObject( hXorBits );
1208
1209#ifdef __WIN32OS2__
1210 if(hObj) {
1211 HICON hIcon;
1212 if(ObjAllocateHandle(&hIcon, (DWORD)hObj, USEROBJ_CURSORICON) == FALSE) {
1213 GlobalFree(hObj);
1214 dprintf(("ERROR: CURSORICON_Load ObjAllocateHandle failed!!"));
1215 return 0;
1216 }
1217 return hIcon;
1218 }
1219#endif
1220 return hObj;
1221}
1222
1223/**********************************************************************
1224 * CURSORICON_Destroy (USER.610)
1225 *
1226 * This routine is actually exported from Win95 USER under the name
1227 * DestroyIcon32 ... The behaviour implemented here should mimic
1228 * the Win95 one exactly, especially the return values, which
1229 * depend on the setting of various flags.
1230 */
1231WORD WIN32API CURSORICON_Destroy( HGLOBAL handle, UINT flags )
1232{
1233 WORD retv;
1234
1235 /* Check whether destroying active cursor */
1236
1237 if ( hActiveCursor == handle )
1238 {
1239 dprintf(("WARNING: Destroying active cursor!" ));
1240 SetCursor( 0 );
1241 }
1242
1243#ifdef __WIN32OS2__
1244 HICON hIcon = ObjGetHandleData(handle, USEROBJ_CURSORICON);
1245 if(hIcon == -1) {
1246 dprintf(("ERROR: Invalid cursor/icon!"));
1247 return 0;
1248 }
1249#endif
1250
1251 /* Try shared cursor/icon first */
1252 if ( !(flags & CID_NONSHARED) )
1253 {
1254 INT count = CURSORICON_DelSharedIcon( handle );
1255
1256 if ( count != -1 )
1257 return (flags & CID_WIN32)? TRUE : (count == 0);
1258
1259 /* FIXME: OEM cursors/icons should be recognized */
1260 }
1261 /* Now assume non-shared cursor/icon */
1262
1263#ifdef __WIN32OS2__
1264 CURSORICONINFO *iconinfo = (CURSORICONINFO *)GlobalLock((HGLOBAL)hIcon);
1265 if (!iconinfo) {
1266 dprintf(("ERROR: Invalid cursor!"));
1267 return 0;
1268 }
1269
1270 if(iconinfo->hColorBmp) {
1271 OSLibWinDestroyPointer(iconinfo->hColorBmp);
1272 }
1273 GlobalUnlock(hIcon);
1274 retv = GlobalFree( hIcon );
1275 ObjFreeHandle(handle);
1276
1277 return (flags & CID_RESOURCE)? retv : TRUE;
1278#else
1279 retv = GlobalFree( handle );
1280 return (flags & CID_RESOURCE)? retv : TRUE;
1281#endif
1282}
1283
1284/***********************************************************************
1285 * CURSORICON_Copy
1286 *
1287 * Make a copy of a cursor or icon.
1288 */
1289static HGLOBAL CURSORICON_Copy(HGLOBAL handle)
1290{
1291 char *ptrOld, *ptrNew;
1292 int size;
1293 HGLOBAL hNew;
1294
1295 handle = ObjGetHandleData(handle, USEROBJ_CURSORICON);
1296 if(handle == -1) {
1297 dprintf(("ERROR: Invalid cursor/icon!"));
1298 return 0;
1299 }
1300
1301 if (!(ptrOld = (char *)GlobalLock( handle ))) return 0;
1302
1303 size = GlobalSize( handle );
1304 hNew = GlobalAlloc( GMEM_MOVEABLE, size );
1305#ifdef __WIN32OS2__
1306 if(hNew == NULL) {
1307 dprintf(("ERROR: CURSORICON_Copy GlobalAlloc failed!!"));
1308 return NULL;
1309 }
1310#endif
1311 ptrNew = (char *)GlobalLock( hNew );
1312 memcpy( ptrNew, ptrOld, size );
1313 GlobalUnlock( handle );
1314 GlobalUnlock( hNew );
1315
1316#ifdef __WIN32OS2__
1317 HICON hIcon;
1318 if(ObjAllocateHandle(&hIcon, (DWORD)hNew, USEROBJ_CURSORICON) == FALSE) {
1319 GlobalFree(hNew);
1320 dprintf(("ERROR: CURSORICON_Copy ObjAllocateHandle failed!!"));
1321 return 0;
1322 }
1323 return hIcon;
1324#else
1325 return hNew;
1326#endif
1327}
1328
1329/*************************************************************************
1330 * CURSORICON_ExtCopy
1331 *
1332 * Copies an Image from the Cache if LR_COPYFROMRESOURCE is specified
1333 *
1334 * PARAMS
1335 * Handle [I] handle to an Image
1336 * nType [I] Type of Handle (IMAGE_CURSOR | IMAGE_ICON)
1337 * iDesiredCX [I] The Desired width of the Image
1338 * iDesiredCY [I] The desired height of the Image
1339 * nFlags [I] The flags from CopyImage
1340 *
1341 * RETURNS
1342 * Success: The new handle of the Image
1343 *
1344 * NOTES
1345 * LR_COPYDELETEORG and LR_MONOCHROME are currently not implemented.
1346 * LR_MONOCHROME should be implemented by CURSORICON_CreateFromResource.
1347 * LR_COPYFROMRESOURCE will only work if the Image is in the Cache.
1348 *
1349 *
1350 */
1351HGLOBAL CURSORICON_ExtCopy(HGLOBAL Handle, UINT nType,
1352 INT iDesiredCX, INT iDesiredCY,
1353 UINT nFlags)
1354{
1355 HGLOBAL hNew=0;
1356
1357#ifdef __WIN32OS2__
1358 HICON hIcon = ObjGetHandleData(Handle, USEROBJ_CURSORICON);
1359 if(hIcon == -1) {
1360 dprintf(("ERROR: Invalid cursor/icon!"));
1361 return 0;
1362 }
1363
1364#else
1365 if(Handle == 0)
1366 {
1367 return 0;
1368 }
1369#endif
1370 /* Best Fit or Monochrome */
1371 if( (nFlags & LR_COPYFROMRESOURCE
1372 && (iDesiredCX > 0 || iDesiredCY > 0))
1373 || nFlags & LR_MONOCHROME)
1374 {
1375#ifdef __WIN32OS2__
1376 ICONCACHE* pIconCache = CURSORICON_FindCache(hIcon);
1377#else
1378 ICONCACHE* pIconCache = CURSORICON_FindCache(Handle);
1379#endif
1380
1381 /* Not Found in Cache, then do a straight copy
1382 */
1383 if(pIconCache == NULL)
1384 {
1385#ifdef __WIN32OS2__
1386 hNew = CURSORICON_Copy(Handle);
1387#else
1388 hNew = CURSORICON_Copy(0, Handle);
1389#endif
1390 if(nFlags & LR_COPYFROMRESOURCE)
1391 {
1392 dprintf(("WARNING: LR_COPYFROMRESOURCE: Failed to load from cache\n"));
1393 }
1394 }
1395 else
1396 {
1397 int iTargetCY = iDesiredCY, iTargetCX = iDesiredCX;
1398 LPBYTE pBits;
1399 HANDLE hMem;
1400 HRSRC hRsrc;
1401 DWORD dwBytesInRes;
1402 WORD wResId;
1403 DWORD dwResGroupId;
1404 HINSTANCE hInstance;
1405 CURSORICONINFO *iconinfo;
1406 CURSORICONDIR *pDir;
1407 CURSORICONDIRENTRY *pDirEntry;
1408 BOOL bIsIcon = (nType == IMAGE_ICON);
1409
1410#ifdef __WIN32OS2__
1411 iconinfo = (CURSORICONINFO *)GlobalLock( hIcon );
1412#else
1413 iconinfo = (CURSORICONINFO *)GlobalLock( Handle );
1414#endif
1415 if(iconinfo == NULL) {
1416 dprintf(("ERROR: CURSORICON_ExtCopy invalid icon!"));
1417 }
1418 hInstance = iconinfo->hInstance;
1419 dwResGroupId = iconinfo->dwResGroupId;
1420 GlobalUnlock( Handle );
1421 if(dwResGroupId == -1) {
1422 //todo: if scaling is necessary..
1423 dprintf(("WARNING: no resource associated with icon/cursor -> copy without scaling!"));
1424 hNew = CURSORICON_Copy(Handle);
1425 return hNew;
1426 }
1427
1428 /* Completing iDesiredCX CY for Monochrome Bitmaps if needed
1429 */
1430 if(((nFlags & LR_MONOCHROME) && !(nFlags & LR_COPYFROMRESOURCE))
1431 || (iDesiredCX == 0 && iDesiredCY == 0))
1432 {
1433 iDesiredCY = GetSystemMetrics(bIsIcon ? SM_CYICON : SM_CYCURSOR);
1434 iDesiredCX = GetSystemMetrics(bIsIcon ? SM_CXICON : SM_CXCURSOR);
1435 }
1436
1437 /* Retreive the CURSORICONDIRENTRY
1438 */
1439 hRsrc = FindResourceW(hInstance, (LPWSTR)dwResGroupId, bIsIcon ? RT_GROUP_ICONW : RT_GROUP_CURSORW);
1440 if(!hRsrc) {
1441 goto notfound;
1442 }
1443
1444 if (!(hMem = LoadResource( hInstance, hRsrc)))
1445 {
1446 goto notfound;
1447 }
1448 if (!(pDir = (CURSORICONDIR*)LockResource( hMem )))
1449 {
1450 goto notfound;
1451 }
1452
1453 /* Find Best Fit
1454 */
1455 if(bIsIcon)
1456 {
1457 pDirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestIcon(
1458 pDir, iDesiredCX, iDesiredCY, 256);
1459 }
1460 else
1461 {
1462 pDirEntry = (CURSORICONDIRENTRY *)CURSORICON_FindBestCursor(
1463 pDir, iDesiredCX, iDesiredCY, 1);
1464 }
1465
1466 wResId = pDirEntry->wResId;
1467 dwBytesInRes = pDirEntry->dwBytesInRes;
1468 FreeResource(hMem);
1469
1470 /* Get the Best Fit
1471 */
1472 if (!(hRsrc = FindResourceW(hInstance ,
1473 MAKEINTRESOURCEW(wResId), bIsIcon ? RT_ICONW : RT_CURSORW)))
1474 {
1475 goto notfound;
1476 }
1477 if (!(hMem = LoadResource( hInstance, hRsrc )))
1478 {
1479 goto notfound;
1480 }
1481
1482 pBits = (LPBYTE)LockResource( hMem );
1483
1484 if(nFlags & LR_DEFAULTSIZE)
1485 {
1486 iTargetCY = GetSystemMetrics(SM_CYICON);
1487 iTargetCX = GetSystemMetrics(SM_CXICON);
1488 }
1489
1490 /* Create a New Icon with the proper dimension
1491 */
1492 hNew = CURSORICON_CreateFromResource( hInstance, dwResGroupId, 0, pBits, dwBytesInRes,
1493 bIsIcon, 0x00030000, iTargetCX, iTargetCY, nFlags);
1494 FreeResource(hMem);
1495 }
1496 }
1497 else
1498 {
1499 hNew = CURSORICON_Copy(Handle);
1500 }
1501 return hNew;
1502
1503notfound:
1504 dprintf(("WARNING: unable to find resource associated with icon/cursor -> copy without scaling!"));
1505 hNew = CURSORICON_Copy(Handle);
1506 return hNew;
1507}
1508
1509/**********************************************************************
1510 * CURSORICON_FindBestIcon
1511 *
1512 * Find the icon closest to the requested size and number of colors.
1513 */
1514static CURSORICONDIRENTRY *CURSORICON_FindBestIcon( CURSORICONDIR *dir, int width,
1515 int height, int colors )
1516{
1517 int i;
1518 CURSORICONDIRENTRY *entry, *bestEntry = NULL;
1519 UINT iTotalDiff, iXDiff=0, iYDiff=0, iColorDiff;
1520 UINT iTempXDiff, iTempYDiff, iTempColorDiff;
1521
1522 if (dir->idCount < 1)
1523 {
1524 dprintf(("Empty directory!\n" ));
1525 return NULL;
1526 }
1527 if (dir->idCount == 1) return &dir->idEntries[0]; /* No choice... */
1528
1529 /* Find Best Fit */
1530 iTotalDiff = 0xFFFFFFFF;
1531 iColorDiff = 0xFFFFFFFF;
1532 for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
1533 {
1534 iTempXDiff = abs(width - entry->ResInfo.icon.bWidth);
1535 iTempYDiff = abs(height - entry->ResInfo.icon.bHeight);
1536
1537 if(iTotalDiff > (iTempXDiff + iTempYDiff))
1538 {
1539 iXDiff = iTempXDiff;
1540 iYDiff = iTempYDiff;
1541 iTotalDiff = iXDiff + iYDiff;
1542 }
1543 }
1544
1545 /* Find Best Colors for Best Fit */
1546 for (i = 0, entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
1547 {
1548 if(abs(width - entry->ResInfo.icon.bWidth) == iXDiff &&
1549 abs(height - entry->ResInfo.icon.bHeight) == iYDiff)
1550 {
1551#ifdef __WIN32OS2__
1552 iTempColorDiff = abs(colors - (1 << entry->wBitCount));
1553#else
1554 iTempColorDiff = abs(colors - entry->ResInfo.icon.bColorCount);
1555#endif
1556 if(iColorDiff > iTempColorDiff)
1557 {
1558 bestEntry = entry;
1559 iColorDiff = iTempColorDiff;
1560 }
1561 }
1562 }
1563////testestest
1564 dprintf(("CURSORICON_FindBestIcon (%d,%d) %d -> %d", width, height, colors, (bestEntry) ? bestEntry->wResId : 0));
1565 return bestEntry;
1566}
1567
1568
1569/**********************************************************************
1570 * CURSORICON_FindBestCursor
1571 *
1572 * Find the cursor closest to the requested size.
1573 * FIXME: parameter 'color' ignored and entries with more than 1 bpp
1574 * ignored too
1575 */
1576static CURSORICONDIRENTRY *CURSORICON_FindBestCursor( CURSORICONDIR *dir,
1577 int width, int height, int color)
1578{
1579 int i, maxwidth, maxheight;
1580 CURSORICONDIRENTRY *entry, *bestEntry = NULL;
1581
1582 if (dir->idCount < 1)
1583 {
1584 dprintf(("Empty directory!\n" ));
1585 return NULL;
1586 }
1587 if (dir->idCount == 1) return &dir->idEntries[0]; /* No choice... */
1588
1589 /* Double height to account for AND and XOR masks */
1590
1591 height *= 2;
1592
1593 /* First find the largest one smaller than or equal to the requested size*/
1594
1595 maxwidth = maxheight = 0;
1596 for(i = 0,entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
1597 if ((entry->ResInfo.cursor.wWidth <= width) && (entry->ResInfo.cursor.wHeight <= height) &&
1598 (entry->ResInfo.cursor.wWidth > maxwidth) && (entry->ResInfo.cursor.wHeight > maxheight) &&
1599 (entry->wBitCount == 1))
1600 {
1601 bestEntry = entry;
1602 maxwidth = entry->ResInfo.cursor.wWidth;
1603 maxheight = entry->ResInfo.cursor.wHeight;
1604 }
1605 if (bestEntry) return bestEntry;
1606
1607 /* Now find the smallest one larger than the requested size */
1608
1609 maxwidth = maxheight = 255;
1610 for(i = 0,entry = &dir->idEntries[0]; i < dir->idCount; i++,entry++)
1611 if ((entry->ResInfo.cursor.wWidth < maxwidth) && (entry->ResInfo.cursor.wHeight < maxheight) &&
1612 (entry->wBitCount == 1))
1613 {
1614 bestEntry = entry;
1615 maxwidth = entry->ResInfo.cursor.wWidth;
1616 maxheight = entry->ResInfo.cursor.wHeight;
1617 }
1618
1619 return bestEntry;
1620}
1621/**********************************************************************
1622 * LookupIconIdFromDirectoryEx (USER.364)
1623 *
1624 * FIXME: exact parameter sizes
1625 */
1626INT WIN32API LookupIconIdFromDirectoryEx(LPBYTE xdir, BOOL bIcon,
1627 INT width, INT height, UINT cFlag )
1628{
1629 CURSORICONDIR *dir = (CURSORICONDIR*)xdir;
1630 UINT retVal = 0;
1631
1632 dprintf(("LookupIconIdFromDirectoryEx %x %d (%d,%d)", xdir, bIcon, width, height));
1633 if( dir && !dir->idReserved && (dir->idType & 3) )
1634 {
1635 CURSORICONDIRENTRY* entry;
1636 HDC hdc;
1637 UINT palEnts;
1638 int colors;
1639 hdc = GetDC(0);
1640 palEnts = GetSystemPaletteEntries(hdc, 0, 0, NULL);
1641 if (palEnts == 0)
1642 palEnts = 256;
1643 colors = (cFlag & LR_MONOCHROME) ? 2 : palEnts;
1644
1645 ReleaseDC(0, hdc);
1646
1647 if( bIcon )
1648 entry = CURSORICON_FindBestIcon( dir, width, height, colors );
1649 else
1650 entry = CURSORICON_FindBestCursor( dir, width, height, 1);
1651
1652 if( entry ) retVal = entry->wResId;
1653 }
1654 else dprintf(("invalid resource directory\n"));
1655 return retVal;
1656}
1657/**********************************************************************
1658 * LookupIconIdFromDirectory (USER32.379)
1659 */
1660INT WIN32API LookupIconIdFromDirectory( LPBYTE dir, BOOL bIcon )
1661{
1662 return LookupIconIdFromDirectoryEx( dir, bIcon,
1663 bIcon ? GetSystemMetrics(SM_CXICON) : GetSystemMetrics(SM_CXCURSOR),
1664 bIcon ? GetSystemMetrics(SM_CYICON) : GetSystemMetrics(SM_CYCURSOR), bIcon ? 0 : LR_MONOCHROME );
1665}
1666//******************************************************************************
1667//******************************************************************************
1668
1669//ICON cache implementation (Wine code)
1670
1671/**********************************************************************
1672 * CURSORICON_FindSharedIcon
1673 */
1674static HANDLE CURSORICON_FindSharedIcon( HMODULE hModule, HRSRC hRsrc )
1675{
1676 HANDLE handle = 0;
1677 ICONCACHE *ptr;
1678
1679 EnterCriticalSection( &IconCrst );
1680
1681 for ( ptr = IconAnchor; ptr; ptr = ptr->next )
1682 if ( ptr->hModule == hModule && ptr->hRsrc == hRsrc )
1683 {
1684 ptr->count++;
1685 handle = ptr->handle;
1686 break;
1687 }
1688
1689 LeaveCriticalSection( &IconCrst );
1690
1691 return handle;
1692}
1693
1694/*************************************************************************
1695 * CURSORICON_FindCache
1696 *
1697 * Given a handle, find the corresponding cache element
1698 *
1699 * PARAMS
1700 * Handle [I] handle to an Image
1701 *
1702 * RETURNS
1703 * Success: The cache entry
1704 * Failure: NULL
1705 *
1706 */
1707static ICONCACHE* CURSORICON_FindCache(HANDLE handle)
1708{
1709 ICONCACHE *ptr;
1710 ICONCACHE *pRet=NULL;
1711 BOOL IsFound = FALSE;
1712 int count;
1713
1714 EnterCriticalSection( &IconCrst );
1715
1716 for (count = 0, ptr = IconAnchor; ptr != NULL && !IsFound; ptr = ptr->next, count++ )
1717 {
1718 if ( handle == ptr->handle )
1719 {
1720 IsFound = TRUE;
1721 pRet = ptr;
1722 }
1723 }
1724
1725 LeaveCriticalSection( &IconCrst );
1726
1727 return pRet;
1728}
1729
1730/**********************************************************************
1731 * CURSORICON_AddSharedIcon
1732 */
1733static void CURSORICON_AddSharedIcon( HMODULE hModule, HRSRC hRsrc, HRSRC hGroupRsrc, HANDLE handle )
1734{
1735 ICONCACHE *ptr = (ICONCACHE *)HeapAlloc( GetProcessHeap(), 0, sizeof(ICONCACHE) );
1736 if ( !ptr ) return;
1737
1738 ptr->hModule = hModule;
1739 ptr->hRsrc = hRsrc;
1740 ptr->handle = handle;
1741 ptr->hGroupRsrc = hGroupRsrc;
1742 ptr->count = 1;
1743
1744 EnterCriticalSection( &IconCrst );
1745 ptr->next = IconAnchor;
1746 IconAnchor = ptr;
1747 LeaveCriticalSection( &IconCrst );
1748}
1749
1750/**********************************************************************
1751 * CURSORICON_DelSharedIcon
1752 */
1753static INT CURSORICON_DelSharedIcon( HANDLE handle )
1754{
1755 INT count = -1;
1756 ICONCACHE *ptr;
1757
1758 EnterCriticalSection( &IconCrst );
1759
1760 for ( ptr = IconAnchor; ptr; ptr = ptr->next )
1761 if ( ptr->handle == handle )
1762 {
1763 if ( ptr->count > 0 ) ptr->count--;
1764 count = ptr->count;
1765 break;
1766 }
1767
1768 LeaveCriticalSection( &IconCrst );
1769
1770 return count;
1771}
1772
1773/**********************************************************************
1774 * CURSORICON_FreeModuleIcons
1775 */
1776void CURSORICON_FreeModuleIcons( HMODULE hModule )
1777{
1778 ICONCACHE **ptr = &IconAnchor;
1779
1780 EnterCriticalSection( &IconCrst );
1781
1782 while ( *ptr )
1783 {
1784 if ( (*ptr)->hModule == hModule )
1785 {
1786 ICONCACHE *freePtr = *ptr;
1787 *ptr = freePtr->next;
1788
1789#ifdef __WIN32OS2__
1790 CURSORICON_Destroy(freePtr->handle, CID_NONSHARED);
1791#else
1792 GlobalFree( freePtr->handle );
1793#endif
1794 HeapFree( GetProcessHeap(), 0, freePtr );
1795 continue;
1796 }
1797 ptr = &(*ptr)->next;
1798 }
1799
1800 LeaveCriticalSection( &IconCrst );
1801}
1802
Note: See TracBrowser for help on using the repository browser.