2 * ImageList implementation
4 * Copyright 1998 Eric Kohl
5 * Copyright 2000 Jason Mawdsley
6 * Copyright 2001, 2004 Michael Stefaniuc
7 * Copyright 2001 Charles Loep for CodeWeavers
8 * Copyright 2002 Dimitrie O. Paun
9 * Copyright 2009 Owen Rudge for CodeWeavers
11 * This library is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU Lesser General Public
13 * License as published by the Free Software Foundation; either
14 * version 2.1 of the License, or (at your option) any later version.
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * Lesser General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with this library; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 * This code was audited for completeness against the documented features
28 * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun.
30 * Unless otherwise noted, we believe this code to be complete, as per
31 * the specification mentioned above.
32 * If you discover missing features, or bugs, please note them below.
35 * - Add support for ILD_PRESERVEALPHA, ILD_SCALE, ILD_DPISCALE
36 * - Add support for ILS_GLOW, ILS_SHADOW, ILS_SATURATE
37 * - Thread-safe locking
41 #define COM_NO_WINDOWS_H
49 //#include "winerror.h"
55 //#include "winuser.h"
56 //#include "commctrl.h"
58 #include <commoncontrols.h>
59 #include <wine/debug.h>
60 #include <wine/exception.h>
62 WINE_DEFAULT_DEBUG_CHANNEL(imagelist
);
64 #define MAX_OVERLAYIMAGE 15
68 const struct IImageListVtbl
*lpVtbl
; /* 00: IImageList vtable */
70 INT cCurImage
; /* 04: ImageCount */
71 INT cMaxImage
; /* 08: maximages */
72 INT cGrow
; /* 0C: cGrow */
76 UINT flags
; /* 1C: flags */
77 COLORREF clrFg
; /* 20: foreground color */
78 COLORREF clrBk
; /* 24: background color */
81 HBITMAP hbmImage
; /* 28: images Bitmap */
82 HBITMAP hbmMask
; /* 2C: masks Bitmap */
83 HDC hdcImage
; /* 30: images MemDC */
84 HDC hdcMask
; /* 34: masks MemDC */
85 INT nOvlIdx
[MAX_OVERLAYIMAGE
]; /* 38: overlay images index */
87 /* not yet found out */
94 LONG ref
; /* reference count */
97 #define IMAGELIST_MAGIC 0x53414D58
99 /* Header used by ImageList_Read() and ImageList_Write() */
100 #include "pshpack2.h"
101 typedef struct _ILHEAD
116 /* internal image list data used for Drag & Drop operations */
121 HIMAGELIST himlNoCursor
;
122 /* position of the drag image relative to the window */
125 /* offset of the hotspot relative to the origin of the image */
128 /* is the drag image visible */
130 /* saved background */
134 static INTERNALDRAG InternalDrag
= { 0, 0, 0, 0, 0, 0, 0, FALSE
, 0 };
136 static HBITMAP
ImageList_CreateImage(HDC hdc
, HIMAGELIST himl
, UINT count
);
137 static HRESULT
ImageListImpl_CreateInstance(const IUnknown
*pUnkOuter
, REFIID iid
, void** ppv
);
138 static inline BOOL
is_valid(HIMAGELIST himl
);
141 * An imagelist with N images is tiled like this:
153 static inline UINT
imagelist_height( UINT count
)
155 return ((count
+ TILE_COUNT
- 1)/TILE_COUNT
);
158 static inline void imagelist_point_from_index( HIMAGELIST himl
, UINT index
, LPPOINT pt
)
160 pt
->x
= (index
%TILE_COUNT
) * himl
->cx
;
161 pt
->y
= (index
/TILE_COUNT
) * himl
->cy
;
164 static inline void imagelist_get_bitmap_size( HIMAGELIST himl
, UINT count
, SIZE
*sz
)
166 sz
->cx
= himl
->cx
* TILE_COUNT
;
167 sz
->cy
= imagelist_height( count
) * himl
->cy
;
170 static inline int get_dib_stride( int width
, int bpp
)
172 return ((width
* bpp
+ 31) >> 3) & ~3;
175 static inline int get_dib_image_size( const BITMAPINFO
*info
)
177 return get_dib_stride( info
->bmiHeader
.biWidth
, info
->bmiHeader
.biBitCount
)
178 * abs( info
->bmiHeader
.biHeight
);
182 * imagelist_copy_images()
184 * Copies a block of count images from offset src in the list to offset dest.
185 * Images are copied a row at at time. Assumes hdcSrc and hdcDest are different.
187 static inline void imagelist_copy_images( HIMAGELIST himl
, HDC hdcSrc
, HDC hdcDest
,
188 UINT src
, UINT count
, UINT dest
)
194 for ( i
=0; i
<TILE_COUNT
; i
++ )
196 imagelist_point_from_index( himl
, src
+i
, &ptSrc
);
197 imagelist_point_from_index( himl
, dest
+i
, &ptDest
);
199 sz
.cy
= himl
->cy
* imagelist_height( count
- i
);
201 BitBlt( hdcDest
, ptDest
.x
, ptDest
.y
, sz
.cx
, sz
.cy
,
202 hdcSrc
, ptSrc
.x
, ptSrc
.y
, SRCCOPY
);
206 static void add_dib_bits( HIMAGELIST himl
, int pos
, int count
, int width
, int height
,
207 BITMAPINFO
*info
, BITMAPINFO
*mask_info
, DWORD
*bits
, BYTE
*mask_bits
)
211 int stride
= info
->bmiHeader
.biWidth
;
212 int mask_stride
= (info
->bmiHeader
.biWidth
+ 31) / 32 * 4;
214 for (n
= 0; n
< count
; n
++)
218 imagelist_point_from_index( himl
, pos
+ n
, &pt
);
220 /* check if bitmap has an alpha channel */
221 for (i
= 0; i
< height
&& !has_alpha
; i
++)
222 for (j
= n
* width
; j
< (n
+ 1) * width
; j
++)
223 if ((has_alpha
= ((bits
[i
* stride
+ j
] & 0xff000000) != 0))) break;
225 if (!has_alpha
) /* generate alpha channel from the mask */
227 for (i
= 0; i
< height
; i
++)
228 for (j
= n
* width
; j
< (n
+ 1) * width
; j
++)
229 if (!mask_info
|| !((mask_bits
[i
* mask_stride
+ j
/ 8] << (j
% 8)) & 0x80))
230 bits
[i
* stride
+ j
] |= 0xff000000;
232 bits
[i
* stride
+ j
] = 0;
236 himl
->has_alpha
[pos
+ n
] = 1;
238 if (mask_info
&& himl
->hbmMask
) /* generate the mask from the alpha channel */
240 for (i
= 0; i
< height
; i
++)
241 for (j
= n
* width
; j
< (n
+ 1) * width
; j
++)
242 if ((bits
[i
* stride
+ j
] >> 24) > 25) /* more than 10% alpha */
243 mask_bits
[i
* mask_stride
+ j
/ 8] &= ~(0x80 >> (j
% 8));
245 mask_bits
[i
* mask_stride
+ j
/ 8] |= 0x80 >> (j
% 8);
248 StretchDIBits( himl
->hdcImage
, pt
.x
, pt
.y
, himl
->cx
, himl
->cy
,
249 n
* width
, 0, width
, height
, bits
, info
, DIB_RGB_COLORS
, SRCCOPY
);
251 StretchDIBits( himl
->hdcMask
, pt
.x
, pt
.y
, himl
->cx
, himl
->cy
,
252 n
* width
, 0, width
, height
, mask_bits
, mask_info
, DIB_RGB_COLORS
, SRCCOPY
);
256 /* add images with an alpha channel when the image list is 32 bpp */
257 static BOOL
add_with_alpha( HIMAGELIST himl
, HDC hdc
, int pos
, int count
,
258 int width
, int height
, HBITMAP hbmImage
, HBITMAP hbmMask
)
262 BITMAPINFO
*info
, *mask_info
= NULL
;
264 BYTE
*mask_bits
= NULL
;
267 if (!GetObjectW( hbmImage
, sizeof(bm
), &bm
)) return FALSE
;
269 /* if either the imagelist or the source bitmap don't have an alpha channel, bail out now */
270 if (!himl
->has_alpha
) return FALSE
;
271 if (bm
.bmBitsPixel
!= 32) return FALSE
;
273 SelectObject( hdc
, hbmImage
);
274 mask_width
= (bm
.bmWidth
+ 31) / 32 * 4;
276 if (!(info
= HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO
, bmiColors
[256] )))) goto done
;
277 info
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
278 info
->bmiHeader
.biWidth
= bm
.bmWidth
;
279 info
->bmiHeader
.biHeight
= -height
;
280 info
->bmiHeader
.biPlanes
= 1;
281 info
->bmiHeader
.biBitCount
= 32;
282 info
->bmiHeader
.biCompression
= BI_RGB
;
283 info
->bmiHeader
.biSizeImage
= bm
.bmWidth
* height
* 4;
284 info
->bmiHeader
.biXPelsPerMeter
= 0;
285 info
->bmiHeader
.biYPelsPerMeter
= 0;
286 info
->bmiHeader
.biClrUsed
= 0;
287 info
->bmiHeader
.biClrImportant
= 0;
288 if (!(bits
= HeapAlloc( GetProcessHeap(), 0, info
->bmiHeader
.biSizeImage
))) goto done
;
289 if (!GetDIBits( hdc
, hbmImage
, 0, height
, bits
, info
, DIB_RGB_COLORS
)) goto done
;
293 if (!(mask_info
= HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO
, bmiColors
[2] ))))
295 mask_info
->bmiHeader
= info
->bmiHeader
;
296 mask_info
->bmiHeader
.biBitCount
= 1;
297 mask_info
->bmiHeader
.biSizeImage
= mask_width
* height
;
298 if (!(mask_bits
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, info
->bmiHeader
.biSizeImage
)))
300 if (!GetDIBits( hdc
, hbmMask
, 0, height
, mask_bits
, mask_info
, DIB_RGB_COLORS
)) goto done
;
303 add_dib_bits( himl
, pos
, count
, width
, height
, info
, mask_info
, bits
, mask_bits
);
307 HeapFree( GetProcessHeap(), 0, info
);
308 HeapFree( GetProcessHeap(), 0, mask_info
);
309 HeapFree( GetProcessHeap(), 0, bits
);
310 HeapFree( GetProcessHeap(), 0, mask_bits
);
314 /*************************************************************************
315 * IMAGELIST_InternalExpandBitmaps [Internal]
317 * Expands the bitmaps of an image list by the given number of images.
320 * himl [I] handle to image list
321 * nImageCount [I] number of images to add
327 * This function CANNOT be used to reduce the number of images.
330 IMAGELIST_InternalExpandBitmaps(HIMAGELIST himl
, INT nImageCount
)
333 HBITMAP hbmNewBitmap
, hbmNull
;
337 TRACE("%p has allocated %d, max %d, grow %d images\n", himl
, himl
->cCurImage
, himl
->cMaxImage
, himl
->cGrow
);
339 if (himl
->cCurImage
+ nImageCount
< himl
->cMaxImage
)
342 nNewCount
= himl
->cMaxImage
+ max(nImageCount
, himl
->cGrow
) + 1;
344 imagelist_get_bitmap_size(himl
, nNewCount
, &sz
);
346 TRACE("Create expanded bitmaps : himl=%p x=%d y=%d count=%d\n", himl
, sz
.cx
, sz
.cy
, nNewCount
);
347 hdcBitmap
= CreateCompatibleDC (0);
349 hbmNewBitmap
= ImageList_CreateImage(hdcBitmap
, himl
, nNewCount
);
351 if (hbmNewBitmap
== 0)
352 ERR("creating new image bitmap (x=%d y=%d)!\n", sz
.cx
, sz
.cy
);
356 hbmNull
= SelectObject (hdcBitmap
, hbmNewBitmap
);
357 BitBlt (hdcBitmap
, 0, 0, sz
.cx
, sz
.cy
,
358 himl
->hdcImage
, 0, 0, SRCCOPY
);
359 SelectObject (hdcBitmap
, hbmNull
);
361 SelectObject (himl
->hdcImage
, hbmNewBitmap
);
362 DeleteObject (himl
->hbmImage
);
363 himl
->hbmImage
= hbmNewBitmap
;
365 if (himl
->flags
& ILC_MASK
)
367 hbmNewBitmap
= CreateBitmap (sz
.cx
, sz
.cy
, 1, 1, NULL
);
369 if (hbmNewBitmap
== 0)
370 ERR("creating new mask bitmap!\n");
374 hbmNull
= SelectObject (hdcBitmap
, hbmNewBitmap
);
375 BitBlt (hdcBitmap
, 0, 0, sz
.cx
, sz
.cy
,
376 himl
->hdcMask
, 0, 0, SRCCOPY
);
377 SelectObject (hdcBitmap
, hbmNull
);
379 SelectObject (himl
->hdcMask
, hbmNewBitmap
);
380 DeleteObject (himl
->hbmMask
);
381 himl
->hbmMask
= hbmNewBitmap
;
386 char *new_alpha
= HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, himl
->has_alpha
, nNewCount
);
387 if (new_alpha
) himl
->has_alpha
= new_alpha
;
390 HeapFree( GetProcessHeap(), 0, himl
->has_alpha
);
391 himl
->has_alpha
= NULL
;
395 himl
->cMaxImage
= nNewCount
;
397 DeleteDC (hdcBitmap
);
401 /*************************************************************************
402 * ImageList_Add [COMCTL32.@]
404 * Add an image or images to an image list.
407 * himl [I] handle to image list
408 * hbmImage [I] handle to image bitmap
409 * hbmMask [I] handle to mask bitmap
412 * Success: Index of the first new image.
417 ImageList_Add (HIMAGELIST himl
, HBITMAP hbmImage
, HBITMAP hbmMask
)
419 HDC hdcBitmap
, hdcTemp
= 0;
420 INT nFirstIndex
, nImageCount
, i
;
424 TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl
, hbmImage
, hbmMask
);
428 if (!GetObjectW(hbmImage
, sizeof(BITMAP
), &bmp
))
431 TRACE("himl %p, cCurImage %d, cMaxImage %d, cGrow %d, cx %d, cy %d\n",
432 himl
, himl
->cCurImage
, himl
->cMaxImage
, himl
->cGrow
, himl
->cx
, himl
->cy
);
434 nImageCount
= bmp
.bmWidth
/ himl
->cx
;
436 TRACE("%p has %d images (%d x %d)\n", hbmImage
, nImageCount
, bmp
.bmWidth
, bmp
.bmHeight
);
438 IMAGELIST_InternalExpandBitmaps(himl
, nImageCount
);
440 hdcBitmap
= CreateCompatibleDC(0);
442 SelectObject(hdcBitmap
, hbmImage
);
444 if (add_with_alpha( himl
, hdcBitmap
, himl
->cCurImage
, nImageCount
,
445 himl
->cx
, min( himl
->cy
, bmp
.bmHeight
), hbmImage
, hbmMask
))
450 hdcTemp
= CreateCompatibleDC(0);
451 SelectObject(hdcTemp
, hbmMask
);
454 for (i
=0; i
<nImageCount
; i
++)
456 imagelist_point_from_index( himl
, himl
->cCurImage
+ i
, &pt
);
458 /* Copy result to the imagelist
460 BitBlt( himl
->hdcImage
, pt
.x
, pt
.y
, himl
->cx
, bmp
.bmHeight
,
461 hdcBitmap
, i
*himl
->cx
, 0, SRCCOPY
);
466 BitBlt( himl
->hdcMask
, pt
.x
, pt
.y
, himl
->cx
, bmp
.bmHeight
,
467 hdcTemp
, i
*himl
->cx
, 0, SRCCOPY
);
469 /* Remove the background from the image
471 BitBlt( himl
->hdcImage
, pt
.x
, pt
.y
, himl
->cx
, bmp
.bmHeight
,
472 himl
->hdcMask
, pt
.x
, pt
.y
, 0x220326 ); /* NOTSRCAND */
474 if (hdcTemp
) DeleteDC(hdcTemp
);
479 nFirstIndex
= himl
->cCurImage
;
480 himl
->cCurImage
+= nImageCount
;
486 /*************************************************************************
487 * ImageList_AddIcon [COMCTL32.@]
489 * Adds an icon to an image list.
492 * himl [I] handle to image list
493 * hIcon [I] handle to icon
496 * Success: index of the new image
499 #undef ImageList_AddIcon
500 INT WINAPI
ImageList_AddIcon (HIMAGELIST himl
, HICON hIcon
)
502 return ImageList_ReplaceIcon (himl
, -1, hIcon
);
506 /*************************************************************************
507 * ImageList_AddMasked [COMCTL32.@]
509 * Adds an image or images to an image list and creates a mask from the
510 * specified bitmap using the mask color.
513 * himl [I] handle to image list.
514 * hBitmap [I] handle to bitmap
515 * clrMask [I] mask color.
518 * Success: Index of the first new image.
523 ImageList_AddMasked (HIMAGELIST himl
, HBITMAP hBitmap
, COLORREF clrMask
)
525 HDC hdcMask
, hdcBitmap
;
531 TRACE("himl=%p hbitmap=%p clrmask=%x\n", himl
, hBitmap
, clrMask
);
535 if (!GetObjectW(hBitmap
, sizeof(BITMAP
), &bmp
))
538 hdcBitmap
= CreateCompatibleDC(0);
539 SelectObject(hdcBitmap
, hBitmap
);
541 /* Create a temp Mask so we can remove the background of the Image */
542 hdcMask
= CreateCompatibleDC(0);
543 hMaskBitmap
= CreateBitmap(bmp
.bmWidth
, bmp
.bmHeight
, 1, 1, NULL
);
544 SelectObject(hdcMask
, hMaskBitmap
);
546 /* create monochrome image to the mask bitmap */
547 bkColor
= (clrMask
!= CLR_DEFAULT
) ? clrMask
: GetPixel (hdcBitmap
, 0, 0);
548 SetBkColor (hdcBitmap
, bkColor
);
549 BitBlt (hdcMask
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
, hdcBitmap
, 0, 0, SRCCOPY
);
552 * Remove the background from the image
554 * WINDOWS BUG ALERT!!!!!!
555 * The statement below should not be done in common practice
556 * but this is how ImageList_AddMasked works in Windows.
557 * It overwrites the original bitmap passed, this was discovered
558 * by using the same bitmap to iterate the different styles
559 * on windows where it failed (BUT ImageList_Add is OK)
560 * This is here in case some apps rely on this bug
562 * Blt mode 0x220326 is NOTSRCAND
564 if (bmp
.bmBitsPixel
> 8) /* NOTSRCAND can't work with palettes */
566 SetBkColor(hdcBitmap
, RGB(255,255,255));
567 BitBlt(hdcBitmap
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
, hdcMask
, 0, 0, 0x220326);
573 ret
= ImageList_Add( himl
, hBitmap
, hMaskBitmap
);
575 DeleteObject(hMaskBitmap
);
580 /*************************************************************************
581 * ImageList_BeginDrag [COMCTL32.@]
583 * Creates a temporary image list that contains one image. It will be used
587 * himlTrack [I] handle to the source image list
588 * iTrack [I] index of the drag image in the source image list
589 * dxHotspot [I] X position of the hot spot of the drag image
590 * dyHotspot [I] Y position of the hot spot of the drag image
598 ImageList_BeginDrag (HIMAGELIST himlTrack
, INT iTrack
,
599 INT dxHotspot
, INT dyHotspot
)
603 TRACE("(himlTrack=%p iTrack=%d dx=%d dy=%d)\n", himlTrack
, iTrack
,
604 dxHotspot
, dyHotspot
);
606 if (!is_valid(himlTrack
))
609 if (InternalDrag
.himl
)
610 ImageList_EndDrag ();
615 InternalDrag
.himlNoCursor
= InternalDrag
.himl
= ImageList_Create (cx
, cy
, himlTrack
->flags
, 1, 1);
616 if (InternalDrag
.himl
== NULL
) {
617 WARN("Error creating drag image list!\n");
621 InternalDrag
.dxHotspot
= dxHotspot
;
622 InternalDrag
.dyHotspot
= dyHotspot
;
625 BitBlt (InternalDrag
.himl
->hdcImage
, 0, 0, cx
, cy
, himlTrack
->hdcImage
, iTrack
* cx
, 0, SRCCOPY
);
628 BitBlt (InternalDrag
.himl
->hdcMask
, 0, 0, cx
, cy
, himlTrack
->hdcMask
, iTrack
* cx
, 0, SRCCOPY
);
630 InternalDrag
.himl
->cCurImage
= 1;
636 /*************************************************************************
637 * ImageList_Copy [COMCTL32.@]
639 * Copies an image of the source image list to an image of the
640 * destination image list. Images can be copied or swapped.
643 * himlDst [I] handle to the destination image list
644 * iDst [I] destination image index.
645 * himlSrc [I] handle to the source image list
646 * iSrc [I] source image index
647 * uFlags [I] flags for the copy operation
654 * Copying from one image list to another is possible. The original
655 * implementation just copies or swaps within one image list.
656 * Could this feature become a bug??? ;-)
660 ImageList_Copy (HIMAGELIST himlDst
, INT iDst
, HIMAGELIST himlSrc
,
661 INT iSrc
, UINT uFlags
)
665 TRACE("himlDst=%p iDst=%d himlSrc=%p iSrc=%d\n", himlDst
, iDst
, himlSrc
, iSrc
);
667 if (!is_valid(himlSrc
) || !is_valid(himlDst
))
669 if ((iDst
< 0) || (iDst
>= himlDst
->cCurImage
))
671 if ((iSrc
< 0) || (iSrc
>= himlSrc
->cCurImage
))
674 imagelist_point_from_index( himlDst
, iDst
, &ptDst
);
675 imagelist_point_from_index( himlSrc
, iSrc
, &ptSrc
);
677 if (uFlags
& ILCF_SWAP
) {
680 HBITMAP hbmTempImage
, hbmTempMask
;
682 hdcBmp
= CreateCompatibleDC (0);
684 /* create temporary bitmaps */
685 hbmTempImage
= CreateBitmap (himlSrc
->cx
, himlSrc
->cy
, 1,
686 himlSrc
->uBitsPixel
, NULL
);
687 hbmTempMask
= CreateBitmap (himlSrc
->cx
, himlSrc
->cy
, 1,
690 /* copy (and stretch) destination to temporary bitmaps.(save) */
692 SelectObject (hdcBmp
, hbmTempImage
);
693 StretchBlt (hdcBmp
, 0, 0, himlSrc
->cx
, himlSrc
->cy
,
694 himlDst
->hdcImage
, ptDst
.x
, ptDst
.y
, himlDst
->cx
, himlDst
->cy
,
697 SelectObject (hdcBmp
, hbmTempMask
);
698 StretchBlt (hdcBmp
, 0, 0, himlSrc
->cx
, himlSrc
->cy
,
699 himlDst
->hdcMask
, ptDst
.x
, ptDst
.y
, himlDst
->cx
, himlDst
->cy
,
702 /* copy (and stretch) source to destination */
704 StretchBlt (himlDst
->hdcImage
, ptDst
.x
, ptDst
.y
, himlDst
->cx
, himlDst
->cy
,
705 himlSrc
->hdcImage
, ptSrc
.x
, ptSrc
.y
, himlSrc
->cx
, himlSrc
->cy
,
708 StretchBlt (himlDst
->hdcMask
, ptDst
.x
, ptDst
.y
, himlDst
->cx
, himlDst
->cy
,
709 himlSrc
->hdcMask
, ptSrc
.x
, ptSrc
.y
, himlSrc
->cx
, himlSrc
->cy
,
712 /* copy (without stretching) temporary bitmaps to source (restore) */
714 BitBlt (himlSrc
->hdcMask
, ptSrc
.x
, ptSrc
.y
, himlSrc
->cx
, himlSrc
->cy
,
715 hdcBmp
, 0, 0, SRCCOPY
);
718 BitBlt (himlSrc
->hdcImage
, ptSrc
.x
, ptSrc
.y
, himlSrc
->cx
, himlSrc
->cy
,
719 hdcBmp
, 0, 0, SRCCOPY
);
720 /* delete temporary bitmaps */
721 DeleteObject (hbmTempMask
);
722 DeleteObject (hbmTempImage
);
727 StretchBlt (himlDst
->hdcImage
, ptDst
.x
, ptDst
.y
, himlDst
->cx
, himlDst
->cy
,
728 himlSrc
->hdcImage
, ptSrc
.x
, ptSrc
.y
, himlSrc
->cx
, himlSrc
->cy
,
732 StretchBlt (himlDst
->hdcMask
, ptDst
.x
, ptDst
.y
, himlDst
->cx
, himlDst
->cy
,
733 himlSrc
->hdcMask
, ptSrc
.x
, ptSrc
.y
, himlSrc
->cx
, himlSrc
->cy
,
741 /*************************************************************************
742 * ImageList_Create [COMCTL32.@]
744 * Creates a new image list.
747 * cx [I] image height
749 * flags [I] creation flags
750 * cInitial [I] initial number of images in the image list
751 * cGrow [I] number of images by which image list grows
754 * Success: Handle to the created image list
758 ImageList_Create (INT cx
, INT cy
, UINT flags
,
759 INT cInitial
, INT cGrow
)
764 UINT ilc
= (flags
& 0xFE);
765 static const WORD aBitBlend25
[] =
766 {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00};
768 static const WORD aBitBlend50
[] =
769 {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA};
771 TRACE("(%d %d 0x%x %d %d)\n", cx
, cy
, flags
, cInitial
, cGrow
);
773 if (cx
<= 0 || cy
<= 0) return NULL
;
775 /* Create the IImageList interface for the image list */
776 if (FAILED(ImageListImpl_CreateInstance(NULL
, &IID_IImageList
, (void **)&himl
)))
779 cGrow
= (WORD
)((max( cGrow
, 1 ) + 3) & ~3);
783 /* Windows doesn't limit the size here, but X11 doesn't let us allocate such huge bitmaps */
784 WARN( "grow %d too large, limiting to 256\n", cGrow
);
791 himl
->cMaxImage
= cInitial
+ 1;
792 himl
->cInitial
= cInitial
;
794 himl
->clrFg
= CLR_DEFAULT
;
795 himl
->clrBk
= CLR_NONE
;
797 /* initialize overlay mask indices */
798 for (nCount
= 0; nCount
< MAX_OVERLAYIMAGE
; nCount
++)
799 himl
->nOvlIdx
[nCount
] = -1;
801 /* Create Image & Mask DCs */
802 himl
->hdcImage
= CreateCompatibleDC (0);
805 if (himl
->flags
& ILC_MASK
){
806 himl
->hdcMask
= CreateCompatibleDC(0);
811 /* Default to ILC_COLOR4 if none of the ILC_COLOR* flags are specified */
812 if (ilc
== ILC_COLOR
)
815 himl
->flags
|= ILC_COLOR4
;
818 if (ilc
>= ILC_COLOR4
&& ilc
<= ILC_COLOR32
)
819 himl
->uBitsPixel
= ilc
;
821 himl
->uBitsPixel
= (UINT
)GetDeviceCaps (himl
->hdcImage
, BITSPIXEL
);
823 if (himl
->cMaxImage
> 0) {
824 himl
->hbmImage
= ImageList_CreateImage(himl
->hdcImage
, himl
, himl
->cMaxImage
);
825 SelectObject(himl
->hdcImage
, himl
->hbmImage
);
829 if ((himl
->cMaxImage
> 0) && (himl
->flags
& ILC_MASK
)) {
832 imagelist_get_bitmap_size(himl
, himl
->cMaxImage
, &sz
);
833 himl
->hbmMask
= CreateBitmap (sz
.cx
, sz
.cy
, 1, 1, NULL
);
834 if (himl
->hbmMask
== 0) {
835 ERR("Error creating mask bitmap!\n");
838 SelectObject(himl
->hdcMask
, himl
->hbmMask
);
843 if (ilc
== ILC_COLOR32
)
844 himl
->has_alpha
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, himl
->cMaxImage
);
846 himl
->has_alpha
= NULL
;
848 /* create blending brushes */
849 hbmTemp
= CreateBitmap (8, 8, 1, 1, aBitBlend25
);
850 himl
->hbrBlend25
= CreatePatternBrush (hbmTemp
);
851 DeleteObject (hbmTemp
);
853 hbmTemp
= CreateBitmap (8, 8, 1, 1, aBitBlend50
);
854 himl
->hbrBlend50
= CreatePatternBrush (hbmTemp
);
855 DeleteObject (hbmTemp
);
857 TRACE("created imagelist %p\n", himl
);
861 ImageList_Destroy(himl
);
866 /*************************************************************************
867 * ImageList_Destroy [COMCTL32.@]
869 * Destroys an image list.
872 * himl [I] handle to image list
880 ImageList_Destroy (HIMAGELIST himl
)
885 IImageList_Release((IImageList
*) himl
);
890 /*************************************************************************
891 * ImageList_DragEnter [COMCTL32.@]
893 * Locks window update and displays the drag image at the given position.
896 * hwndLock [I] handle of the window that owns the drag image.
897 * x [I] X position of the drag image.
898 * y [I] Y position of the drag image.
905 * The position of the drag image is relative to the window, not
910 ImageList_DragEnter (HWND hwndLock
, INT x
, INT y
)
912 TRACE("(hwnd=%p x=%d y=%d)\n", hwndLock
, x
, y
);
914 if (!is_valid(InternalDrag
.himl
))
918 InternalDrag
.hwnd
= hwndLock
;
920 InternalDrag
.hwnd
= GetDesktopWindow ();
925 /* draw the drag image and save the background */
926 if (!ImageList_DragShowNolock(TRUE
)) {
934 /*************************************************************************
935 * ImageList_DragLeave [COMCTL32.@]
937 * Unlocks window update and hides the drag image.
940 * hwndLock [I] handle of the window that owns the drag image.
948 ImageList_DragLeave (HWND hwndLock
)
950 /* As we don't save drag info in the window this can lead to problems if
951 an app does not supply the same window as DragEnter */
953 InternalDrag.hwnd = hwndLock;
955 InternalDrag.hwnd = GetDesktopWindow (); */
957 hwndLock
= GetDesktopWindow();
958 if(InternalDrag
.hwnd
!= hwndLock
)
959 FIXME("DragLeave hWnd != DragEnter hWnd\n");
961 ImageList_DragShowNolock (FALSE
);
967 /*************************************************************************
968 * ImageList_InternalDragDraw [Internal]
970 * Draws the drag image.
973 * hdc [I] device context to draw into.
974 * x [I] X position of the drag image.
975 * y [I] Y position of the drag image.
982 * The position of the drag image is relative to the window, not
988 ImageList_InternalDragDraw (HDC hdc
, INT x
, INT y
)
990 IMAGELISTDRAWPARAMS imldp
;
992 ZeroMemory (&imldp
, sizeof(imldp
));
993 imldp
.cbSize
= sizeof(imldp
);
994 imldp
.himl
= InternalDrag
.himl
;
999 imldp
.rgbBk
= CLR_DEFAULT
;
1000 imldp
.rgbFg
= CLR_DEFAULT
;
1001 imldp
.fStyle
= ILD_NORMAL
;
1002 imldp
.fState
= ILS_ALPHA
;
1004 ImageList_DrawIndirect (&imldp
);
1007 /*************************************************************************
1008 * ImageList_DragMove [COMCTL32.@]
1010 * Moves the drag image.
1013 * x [I] X position of the drag image.
1014 * y [I] Y position of the drag image.
1021 * The position of the drag image is relative to the window, not
1026 ImageList_DragMove (INT x
, INT y
)
1028 TRACE("(x=%d y=%d)\n", x
, y
);
1030 if (!is_valid(InternalDrag
.himl
))
1033 /* draw/update the drag image */
1034 if (InternalDrag
.bShow
) {
1038 HBITMAP hbmOffScreen
;
1039 INT origNewX
, origNewY
;
1040 INT origOldX
, origOldY
;
1041 INT origRegX
, origRegY
;
1042 INT sizeRegX
, sizeRegY
;
1045 /* calculate the update region */
1046 origNewX
= x
- InternalDrag
.dxHotspot
;
1047 origNewY
= y
- InternalDrag
.dyHotspot
;
1048 origOldX
= InternalDrag
.x
- InternalDrag
.dxHotspot
;
1049 origOldY
= InternalDrag
.y
- InternalDrag
.dyHotspot
;
1050 origRegX
= min(origNewX
, origOldX
);
1051 origRegY
= min(origNewY
, origOldY
);
1052 sizeRegX
= InternalDrag
.himl
->cx
+ abs(x
- InternalDrag
.x
);
1053 sizeRegY
= InternalDrag
.himl
->cy
+ abs(y
- InternalDrag
.y
);
1055 hdcDrag
= GetDCEx(InternalDrag
.hwnd
, 0,
1056 DCX_WINDOW
| DCX_CACHE
| DCX_LOCKWINDOWUPDATE
);
1057 hdcOffScreen
= CreateCompatibleDC(hdcDrag
);
1058 hdcBg
= CreateCompatibleDC(hdcDrag
);
1060 hbmOffScreen
= CreateCompatibleBitmap(hdcDrag
, sizeRegX
, sizeRegY
);
1061 SelectObject(hdcOffScreen
, hbmOffScreen
);
1062 SelectObject(hdcBg
, InternalDrag
.hbmBg
);
1064 /* get the actual background of the update region */
1065 BitBlt(hdcOffScreen
, 0, 0, sizeRegX
, sizeRegY
, hdcDrag
,
1066 origRegX
, origRegY
, SRCCOPY
);
1067 /* erase the old image */
1068 BitBlt(hdcOffScreen
, origOldX
- origRegX
, origOldY
- origRegY
,
1069 InternalDrag
.himl
->cx
, InternalDrag
.himl
->cy
, hdcBg
, 0, 0,
1071 /* save the background */
1072 BitBlt(hdcBg
, 0, 0, InternalDrag
.himl
->cx
, InternalDrag
.himl
->cy
,
1073 hdcOffScreen
, origNewX
- origRegX
, origNewY
- origRegY
, SRCCOPY
);
1074 /* draw the image */
1075 ImageList_InternalDragDraw(hdcOffScreen
, origNewX
- origRegX
,
1076 origNewY
- origRegY
);
1077 /* draw the update region to the screen */
1078 BitBlt(hdcDrag
, origRegX
, origRegY
, sizeRegX
, sizeRegY
,
1079 hdcOffScreen
, 0, 0, SRCCOPY
);
1082 DeleteDC(hdcOffScreen
);
1083 DeleteObject(hbmOffScreen
);
1084 ReleaseDC(InternalDrag
.hwnd
, hdcDrag
);
1087 /* update the image position */
1095 /*************************************************************************
1096 * ImageList_DragShowNolock [COMCTL32.@]
1098 * Shows or hides the drag image.
1101 * bShow [I] TRUE shows the drag image, FALSE hides it.
1109 ImageList_DragShowNolock (BOOL bShow
)
1115 if (!is_valid(InternalDrag
.himl
))
1118 TRACE("bShow=0x%X!\n", bShow
);
1120 /* DragImage is already visible/hidden */
1121 if ((InternalDrag
.bShow
&& bShow
) || (!InternalDrag
.bShow
&& !bShow
)) {
1125 /* position of the origin of the DragImage */
1126 x
= InternalDrag
.x
- InternalDrag
.dxHotspot
;
1127 y
= InternalDrag
.y
- InternalDrag
.dyHotspot
;
1129 hdcDrag
= GetDCEx (InternalDrag
.hwnd
, 0,
1130 DCX_WINDOW
| DCX_CACHE
| DCX_LOCKWINDOWUPDATE
);
1135 hdcBg
= CreateCompatibleDC(hdcDrag
);
1136 if (!InternalDrag
.hbmBg
) {
1137 InternalDrag
.hbmBg
= CreateCompatibleBitmap(hdcDrag
,
1138 InternalDrag
.himl
->cx
, InternalDrag
.himl
->cy
);
1140 SelectObject(hdcBg
, InternalDrag
.hbmBg
);
1143 /* save the background */
1144 BitBlt(hdcBg
, 0, 0, InternalDrag
.himl
->cx
, InternalDrag
.himl
->cy
,
1145 hdcDrag
, x
, y
, SRCCOPY
);
1146 /* show the image */
1147 ImageList_InternalDragDraw(hdcDrag
, x
, y
);
1149 /* hide the image */
1150 BitBlt(hdcDrag
, x
, y
, InternalDrag
.himl
->cx
, InternalDrag
.himl
->cy
,
1151 hdcBg
, 0, 0, SRCCOPY
);
1154 InternalDrag
.bShow
= !InternalDrag
.bShow
;
1157 ReleaseDC (InternalDrag
.hwnd
, hdcDrag
);
1162 /*************************************************************************
1163 * ImageList_Draw [COMCTL32.@]
1168 * himl [I] handle to image list
1170 * hdc [I] handle to device context
1173 * fStyle [I] drawing flags
1184 ImageList_Draw (HIMAGELIST himl
, INT i
, HDC hdc
, INT x
, INT y
, UINT fStyle
)
1186 return ImageList_DrawEx (himl
, i
, hdc
, x
, y
, 0, 0,
1187 CLR_DEFAULT
, CLR_DEFAULT
, fStyle
);
1191 /*************************************************************************
1192 * ImageList_DrawEx [COMCTL32.@]
1194 * Draws an image and allows using extended drawing features.
1197 * himl [I] handle to image list
1199 * hdc [I] handle to device context
1204 * rgbBk [I] background color
1205 * rgbFg [I] foreground color
1206 * fStyle [I] drawing flags
1213 * Calls ImageList_DrawIndirect.
1216 * ImageList_DrawIndirect.
1220 ImageList_DrawEx (HIMAGELIST himl
, INT i
, HDC hdc
, INT x
, INT y
,
1221 INT dx
, INT dy
, COLORREF rgbBk
, COLORREF rgbFg
,
1224 IMAGELISTDRAWPARAMS imldp
;
1226 ZeroMemory (&imldp
, sizeof(imldp
));
1227 imldp
.cbSize
= sizeof(imldp
);
1235 imldp
.rgbBk
= rgbBk
;
1236 imldp
.rgbFg
= rgbFg
;
1237 imldp
.fStyle
= fStyle
;
1239 return ImageList_DrawIndirect (&imldp
);
1243 static BOOL
alpha_blend_image( HIMAGELIST himl
, HDC dest_dc
, int dest_x
, int dest_y
,
1244 int src_x
, int src_y
, int cx
, int cy
, BLENDFUNCTION func
,
1245 UINT style
, COLORREF blend_col
)
1249 HBITMAP bmp
= 0, mask
= 0;
1251 void *bits
, *mask_bits
;
1255 if (!(hdc
= CreateCompatibleDC( 0 ))) return FALSE
;
1256 if (!(info
= HeapAlloc( GetProcessHeap(), 0, FIELD_OFFSET( BITMAPINFO
, bmiColors
[256] )))) goto done
;
1257 info
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
1258 info
->bmiHeader
.biWidth
= cx
;
1259 info
->bmiHeader
.biHeight
= cy
;
1260 info
->bmiHeader
.biPlanes
= 1;
1261 info
->bmiHeader
.biBitCount
= 32;
1262 info
->bmiHeader
.biCompression
= BI_RGB
;
1263 info
->bmiHeader
.biSizeImage
= cx
* cy
* 4;
1264 info
->bmiHeader
.biXPelsPerMeter
= 0;
1265 info
->bmiHeader
.biYPelsPerMeter
= 0;
1266 info
->bmiHeader
.biClrUsed
= 0;
1267 info
->bmiHeader
.biClrImportant
= 0;
1268 if (!(bmp
= CreateDIBSection( himl
->hdcImage
, info
, DIB_RGB_COLORS
, &bits
, 0, 0 ))) goto done
;
1269 SelectObject( hdc
, bmp
);
1270 BitBlt( hdc
, 0, 0, cx
, cy
, himl
->hdcImage
, src_x
, src_y
, SRCCOPY
);
1272 if (blend_col
!= CLR_NONE
)
1274 BYTE r
= GetRValue( blend_col
);
1275 BYTE g
= GetGValue( blend_col
);
1276 BYTE b
= GetBValue( blend_col
);
1278 if (style
& ILD_BLEND25
)
1280 for (i
= 0, ptr
= bits
; i
< cx
* cy
; i
++, ptr
++)
1281 *ptr
= ((*ptr
& 0xff000000) |
1282 ((((*ptr
& 0x00ff0000) * 3 + (r
<< 16)) / 4) & 0x00ff0000) |
1283 ((((*ptr
& 0x0000ff00) * 3 + (g
<< 8)) / 4) & 0x0000ff00) |
1284 ((((*ptr
& 0x000000ff) * 3 + (b
<< 0)) / 4) & 0x000000ff));
1286 else if (style
& ILD_BLEND50
)
1288 for (i
= 0, ptr
= bits
; i
< cx
* cy
; i
++, ptr
++)
1289 *ptr
= ((*ptr
& 0xff000000) |
1290 ((((*ptr
& 0x00ff0000) + (r
<< 16)) / 2) & 0x00ff0000) |
1291 ((((*ptr
& 0x0000ff00) + (g
<< 8)) / 2) & 0x0000ff00) |
1292 ((((*ptr
& 0x000000ff) + (b
<< 0)) / 2) & 0x000000ff));
1296 if (himl
->has_alpha
) /* we already have an alpha channel in this case */
1298 /* pre-multiply by the alpha channel */
1299 for (i
= 0, ptr
= bits
; i
< cx
* cy
; i
++, ptr
++)
1301 DWORD alpha
= *ptr
>> 24;
1302 *ptr
= ((*ptr
& 0xff000000) |
1303 (((*ptr
& 0x00ff0000) * alpha
/ 255) & 0x00ff0000) |
1304 (((*ptr
& 0x0000ff00) * alpha
/ 255) & 0x0000ff00) |
1305 (((*ptr
& 0x000000ff) * alpha
/ 255)));
1308 else if (himl
->hbmMask
)
1310 unsigned int width_bytes
= (cx
+ 31) / 32 * 4;
1311 /* generate alpha channel from the mask */
1312 info
->bmiHeader
.biBitCount
= 1;
1313 info
->bmiHeader
.biSizeImage
= width_bytes
* cy
;
1314 info
->bmiColors
[0].rgbRed
= 0;
1315 info
->bmiColors
[0].rgbGreen
= 0;
1316 info
->bmiColors
[0].rgbBlue
= 0;
1317 info
->bmiColors
[0].rgbReserved
= 0;
1318 info
->bmiColors
[1].rgbRed
= 0xff;
1319 info
->bmiColors
[1].rgbGreen
= 0xff;
1320 info
->bmiColors
[1].rgbBlue
= 0xff;
1321 info
->bmiColors
[1].rgbReserved
= 0;
1322 if (!(mask
= CreateDIBSection( himl
->hdcMask
, info
, DIB_RGB_COLORS
, &mask_bits
, 0, 0 )))
1324 SelectObject( hdc
, mask
);
1325 BitBlt( hdc
, 0, 0, cx
, cy
, himl
->hdcMask
, src_x
, src_y
, SRCCOPY
);
1326 SelectObject( hdc
, bmp
);
1327 for (i
= 0, ptr
= bits
; i
< cy
; i
++)
1328 for (j
= 0; j
< cx
; j
++, ptr
++)
1329 if ((((BYTE
*)mask_bits
)[i
* width_bytes
+ j
/ 8] << (j
% 8)) & 0x80) *ptr
= 0;
1330 else *ptr
|= 0xff000000;
1333 ret
= GdiAlphaBlend( dest_dc
, dest_x
, dest_y
, cx
, cy
, hdc
, 0, 0, cx
, cy
, func
);
1337 if (bmp
) DeleteObject( bmp
);
1338 if (mask
) DeleteObject( mask
);
1339 HeapFree( GetProcessHeap(), 0, info
);
1343 /*************************************************************************
1344 * ImageList_DrawIndirect [COMCTL32.@]
1346 * Draws an image using various parameters specified in pimldp.
1349 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure.
1357 ImageList_DrawIndirect (IMAGELISTDRAWPARAMS
*pimldp
)
1359 INT cx
, cy
, nOvlIdx
;
1360 DWORD fState
, dwRop
;
1362 COLORREF oldImageBk
, oldImageFg
;
1363 HDC hImageDC
, hImageListDC
, hMaskListDC
;
1364 HBITMAP hImageBmp
, hOldImageBmp
, hBlendMaskBmp
;
1365 BOOL bIsTransparent
, bBlend
, bResult
= FALSE
, bMask
;
1371 if (!pimldp
|| !(himl
= pimldp
->himl
)) return FALSE
;
1372 if (!is_valid(himl
)) return FALSE
;
1373 if ((pimldp
->i
< 0) || (pimldp
->i
>= himl
->cCurImage
)) return FALSE
;
1375 imagelist_point_from_index( himl
, pimldp
->i
, &pt
);
1376 pt
.x
+= pimldp
->xBitmap
;
1377 pt
.y
+= pimldp
->yBitmap
;
1379 fState
= pimldp
->cbSize
< sizeof(IMAGELISTDRAWPARAMS
) ? ILS_NORMAL
: pimldp
->fState
;
1380 fStyle
= pimldp
->fStyle
& ~ILD_OVERLAYMASK
;
1381 cx
= (pimldp
->cx
== 0) ? himl
->cx
: pimldp
->cx
;
1382 cy
= (pimldp
->cy
== 0) ? himl
->cy
: pimldp
->cy
;
1384 bIsTransparent
= (fStyle
& ILD_TRANSPARENT
);
1385 if( pimldp
->rgbBk
== CLR_NONE
)
1386 bIsTransparent
= TRUE
;
1387 if( ( pimldp
->rgbBk
== CLR_DEFAULT
) && ( himl
->clrBk
== CLR_NONE
) )
1388 bIsTransparent
= TRUE
;
1389 bMask
= (himl
->flags
& ILC_MASK
) && (fStyle
& ILD_MASK
) ;
1390 bBlend
= (fStyle
& (ILD_BLEND25
| ILD_BLEND50
) ) && !bMask
;
1392 TRACE("himl(%p) hbmMask(%p) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n",
1393 himl
, himl
->hbmMask
, pimldp
->i
, pimldp
->x
, pimldp
->y
, cx
, cy
);
1395 /* we will use these DCs to access the images and masks in the ImageList */
1396 hImageListDC
= himl
->hdcImage
;
1397 hMaskListDC
= himl
->hdcMask
;
1399 /* these will accumulate the image and mask for the image we're drawing */
1400 hImageDC
= CreateCompatibleDC( pimldp
->hdcDst
);
1401 hImageBmp
= CreateCompatibleBitmap( pimldp
->hdcDst
, cx
, cy
);
1402 hBlendMaskBmp
= bBlend
? CreateBitmap(cx
, cy
, 1, 1, NULL
) : 0;
1404 /* Create a compatible DC. */
1405 if (!hImageListDC
|| !hImageDC
|| !hImageBmp
||
1406 (bBlend
&& !hBlendMaskBmp
) || (himl
->hbmMask
&& !hMaskListDC
))
1409 hOldImageBmp
= SelectObject(hImageDC
, hImageBmp
);
1412 * To obtain a transparent look, background color should be set
1413 * to white and foreground color to black when blitting the
1416 oldImageFg
= SetTextColor( hImageDC
, RGB( 0, 0, 0 ) );
1417 oldImageBk
= SetBkColor( hImageDC
, RGB( 0xff, 0xff, 0xff ) );
1419 has_alpha
= (himl
->has_alpha
&& himl
->has_alpha
[pimldp
->i
]);
1420 if (!bMask
&& (has_alpha
|| (fState
& ILS_ALPHA
)))
1422 COLORREF colour
, blend_col
= CLR_NONE
;
1427 blend_col
= pimldp
->rgbFg
;
1428 if (blend_col
== CLR_DEFAULT
) blend_col
= GetSysColor( COLOR_HIGHLIGHT
);
1429 else if (blend_col
== CLR_NONE
) blend_col
= GetTextColor( pimldp
->hdcDst
);
1432 func
.BlendOp
= AC_SRC_OVER
;
1433 func
.BlendFlags
= 0;
1434 func
.SourceConstantAlpha
= (fState
& ILS_ALPHA
) ? pimldp
->Frame
: 255;
1435 func
.AlphaFormat
= AC_SRC_ALPHA
;
1439 bResult
= alpha_blend_image( himl
, pimldp
->hdcDst
, pimldp
->x
, pimldp
->y
,
1440 pt
.x
, pt
.y
, cx
, cy
, func
, fStyle
, blend_col
);
1443 colour
= pimldp
->rgbBk
;
1444 if (colour
== CLR_DEFAULT
) colour
= himl
->clrBk
;
1445 if (colour
== CLR_NONE
) colour
= GetBkColor( pimldp
->hdcDst
);
1447 hOldBrush
= SelectObject (hImageDC
, CreateSolidBrush (colour
));
1448 PatBlt( hImageDC
, 0, 0, cx
, cy
, PATCOPY
);
1449 alpha_blend_image( himl
, hImageDC
, 0, 0, pt
.x
, pt
.y
, cx
, cy
, func
, fStyle
, blend_col
);
1450 DeleteObject (SelectObject (hImageDC
, hOldBrush
));
1451 bResult
= BitBlt( pimldp
->hdcDst
, pimldp
->x
, pimldp
->y
, cx
, cy
, hImageDC
, 0, 0, SRCCOPY
);
1456 * Draw the initial image
1459 if (himl
->hbmMask
) {
1460 hOldBrush
= SelectObject (hImageDC
, CreateSolidBrush (GetTextColor(pimldp
->hdcDst
)));
1461 PatBlt( hImageDC
, 0, 0, cx
, cy
, PATCOPY
);
1462 BitBlt(hImageDC
, 0, 0, cx
, cy
, hMaskListDC
, pt
.x
, pt
.y
, SRCPAINT
);
1463 DeleteObject (SelectObject (hImageDC
, hOldBrush
));
1464 if( bIsTransparent
)
1466 BitBlt ( pimldp
->hdcDst
, pimldp
->x
, pimldp
->y
, cx
, cy
, hImageDC
, 0, 0, SRCAND
);
1471 hOldBrush
= SelectObject (hImageDC
, GetStockObject(BLACK_BRUSH
));
1472 PatBlt( hImageDC
, 0, 0, cx
, cy
, PATCOPY
);
1473 SelectObject(hImageDC
, hOldBrush
);
1476 /* blend the image with the needed solid background */
1477 COLORREF colour
= RGB(0,0,0);
1479 if( !bIsTransparent
)
1481 colour
= pimldp
->rgbBk
;
1482 if( colour
== CLR_DEFAULT
)
1483 colour
= himl
->clrBk
;
1484 if( colour
== CLR_NONE
)
1485 colour
= GetBkColor(pimldp
->hdcDst
);
1488 hOldBrush
= SelectObject (hImageDC
, CreateSolidBrush (colour
));
1489 PatBlt( hImageDC
, 0, 0, cx
, cy
, PATCOPY
);
1492 BitBlt( hImageDC
, 0, 0, cx
, cy
, hMaskListDC
, pt
.x
, pt
.y
, SRCAND
);
1493 BitBlt( hImageDC
, 0, 0, cx
, cy
, hImageListDC
, pt
.x
, pt
.y
, SRCPAINT
);
1496 BitBlt( hImageDC
, 0, 0, cx
, cy
, hImageListDC
, pt
.x
, pt
.y
, SRCCOPY
);
1497 DeleteObject (SelectObject (hImageDC
, hOldBrush
));
1500 /* Time for blending, if required */
1503 COLORREF clrBlend
= pimldp
->rgbFg
;
1504 HDC hBlendMaskDC
= hImageListDC
;
1507 /* Create the blend Mask */
1508 hOldBitmap
= SelectObject(hBlendMaskDC
, hBlendMaskBmp
);
1509 hBlendBrush
= fStyle
& ILD_BLEND50
? himl
->hbrBlend50
: himl
->hbrBlend25
;
1510 hOldBrush
= SelectObject(hBlendMaskDC
, hBlendBrush
);
1511 PatBlt(hBlendMaskDC
, 0, 0, cx
, cy
, PATCOPY
);
1512 SelectObject(hBlendMaskDC
, hOldBrush
);
1514 /* Modify the blend mask if an Image Mask exist */
1516 BitBlt(hBlendMaskDC
, 0, 0, cx
, cy
, hMaskListDC
, pt
.x
, pt
.y
, 0x220326); /* NOTSRCAND */
1517 BitBlt(hBlendMaskDC
, 0, 0, cx
, cy
, hBlendMaskDC
, 0, 0, NOTSRCCOPY
);
1520 /* now apply blend to the current image given the BlendMask */
1521 if (clrBlend
== CLR_DEFAULT
) clrBlend
= GetSysColor (COLOR_HIGHLIGHT
);
1522 else if (clrBlend
== CLR_NONE
) clrBlend
= GetTextColor (pimldp
->hdcDst
);
1523 hOldBrush
= SelectObject (hImageDC
, CreateSolidBrush(clrBlend
));
1524 BitBlt (hImageDC
, 0, 0, cx
, cy
, hBlendMaskDC
, 0, 0, 0xB8074A); /* PSDPxax */
1525 DeleteObject(SelectObject(hImageDC
, hOldBrush
));
1526 SelectObject(hBlendMaskDC
, hOldBitmap
);
1529 /* Now do the overlay image, if any */
1530 nOvlIdx
= (pimldp
->fStyle
& ILD_OVERLAYMASK
) >> 8;
1531 if ( (nOvlIdx
>= 1) && (nOvlIdx
<= MAX_OVERLAYIMAGE
)) {
1532 nOvlIdx
= himl
->nOvlIdx
[nOvlIdx
- 1];
1533 if ((nOvlIdx
>= 0) && (nOvlIdx
< himl
->cCurImage
)) {
1535 imagelist_point_from_index( himl
, nOvlIdx
, &ptOvl
);
1536 ptOvl
.x
+= pimldp
->xBitmap
;
1537 if (himl
->hbmMask
&& !(fStyle
& ILD_IMAGE
))
1538 BitBlt (hImageDC
, 0, 0, cx
, cy
, hMaskListDC
, ptOvl
.x
, ptOvl
.y
, SRCAND
);
1539 BitBlt (hImageDC
, 0, 0, cx
, cy
, hImageListDC
, ptOvl
.x
, ptOvl
.y
, SRCPAINT
);
1543 if (fState
& ILS_SATURATE
) FIXME("ILS_SATURATE: unimplemented!\n");
1544 if (fState
& ILS_GLOW
) FIXME("ILS_GLOW: unimplemented!\n");
1545 if (fState
& ILS_SHADOW
) FIXME("ILS_SHADOW: unimplemented!\n");
1547 if (fStyle
& ILD_PRESERVEALPHA
) FIXME("ILD_PRESERVEALPHA: unimplemented!\n");
1548 if (fStyle
& ILD_SCALE
) FIXME("ILD_SCALE: unimplemented!\n");
1549 if (fStyle
& ILD_DPISCALE
) FIXME("ILD_DPISCALE: unimplemented!\n");
1551 /* now copy the image to the screen */
1553 if (himl
->hbmMask
&& bIsTransparent
) {
1554 COLORREF oldDstFg
= SetTextColor(pimldp
->hdcDst
, RGB( 0, 0, 0 ) );
1555 COLORREF oldDstBk
= SetBkColor(pimldp
->hdcDst
, RGB( 0xff, 0xff, 0xff ));
1556 BitBlt (pimldp
->hdcDst
, pimldp
->x
, pimldp
->y
, cx
, cy
, hMaskListDC
, pt
.x
, pt
.y
, SRCAND
);
1557 SetBkColor(pimldp
->hdcDst
, oldDstBk
);
1558 SetTextColor(pimldp
->hdcDst
, oldDstFg
);
1561 if (fStyle
& ILD_ROP
) dwRop
= pimldp
->dwRop
;
1562 BitBlt (pimldp
->hdcDst
, pimldp
->x
, pimldp
->y
, cx
, cy
, hImageDC
, 0, 0, dwRop
);
1566 /* cleanup the mess */
1567 SetBkColor(hImageDC
, oldImageBk
);
1568 SetTextColor(hImageDC
, oldImageFg
);
1569 SelectObject(hImageDC
, hOldImageBmp
);
1571 DeleteObject(hBlendMaskBmp
);
1572 DeleteObject(hImageBmp
);
1579 /*************************************************************************
1580 * ImageList_Duplicate [COMCTL32.@]
1582 * Duplicates an image list.
1585 * himlSrc [I] source image list handle
1588 * Success: Handle of duplicated image list.
1593 ImageList_Duplicate (HIMAGELIST himlSrc
)
1597 if (!is_valid(himlSrc
)) {
1598 ERR("Invalid image list handle!\n");
1602 himlDst
= ImageList_Create (himlSrc
->cx
, himlSrc
->cy
, himlSrc
->flags
,
1603 himlSrc
->cCurImage
, himlSrc
->cGrow
);
1609 imagelist_get_bitmap_size(himlSrc
, himlSrc
->cCurImage
, &sz
);
1610 BitBlt (himlDst
->hdcImage
, 0, 0, sz
.cx
, sz
.cy
,
1611 himlSrc
->hdcImage
, 0, 0, SRCCOPY
);
1613 if (himlDst
->hbmMask
)
1614 BitBlt (himlDst
->hdcMask
, 0, 0, sz
.cx
, sz
.cy
,
1615 himlSrc
->hdcMask
, 0, 0, SRCCOPY
);
1617 himlDst
->cCurImage
= himlSrc
->cCurImage
;
1618 if (himlSrc
->has_alpha
&& himlDst
->has_alpha
)
1619 memcpy( himlDst
->has_alpha
, himlSrc
->has_alpha
, himlDst
->cCurImage
);
1625 /*************************************************************************
1626 * ImageList_EndDrag [COMCTL32.@]
1628 * Finishes a drag operation.
1639 ImageList_EndDrag (void)
1641 /* cleanup the InternalDrag struct */
1642 InternalDrag
.hwnd
= 0;
1643 if (InternalDrag
.himl
!= InternalDrag
.himlNoCursor
)
1644 ImageList_Destroy (InternalDrag
.himlNoCursor
);
1645 ImageList_Destroy (InternalDrag
.himl
);
1646 InternalDrag
.himlNoCursor
= InternalDrag
.himl
= 0;
1649 InternalDrag
.dxHotspot
= 0;
1650 InternalDrag
.dyHotspot
= 0;
1651 InternalDrag
.bShow
= FALSE
;
1652 DeleteObject(InternalDrag
.hbmBg
);
1653 InternalDrag
.hbmBg
= 0;
1657 /*************************************************************************
1658 * ImageList_GetBkColor [COMCTL32.@]
1660 * Returns the background color of an image list.
1663 * himl [I] Image list handle.
1666 * Success: background color
1671 ImageList_GetBkColor (HIMAGELIST himl
)
1673 return himl
? himl
->clrBk
: CLR_NONE
;
1677 /*************************************************************************
1678 * ImageList_GetDragImage [COMCTL32.@]
1680 * Returns the handle to the internal drag image list.
1683 * ppt [O] Pointer to the drag position. Can be NULL.
1684 * pptHotspot [O] Pointer to the position of the hot spot. Can be NULL.
1687 * Success: Handle of the drag image list.
1692 ImageList_GetDragImage (POINT
*ppt
, POINT
*pptHotspot
)
1694 if (is_valid(InternalDrag
.himl
)) {
1696 ppt
->x
= InternalDrag
.x
;
1697 ppt
->y
= InternalDrag
.y
;
1700 pptHotspot
->x
= InternalDrag
.dxHotspot
;
1701 pptHotspot
->y
= InternalDrag
.dyHotspot
;
1703 return (InternalDrag
.himl
);
1710 /*************************************************************************
1711 * ImageList_GetFlags [COMCTL32.@]
1713 * Gets the flags of the specified image list.
1716 * himl [I] Handle to image list
1726 ImageList_GetFlags(HIMAGELIST himl
)
1728 TRACE("%p\n", himl
);
1730 return is_valid(himl
) ? himl
->flags
: 0;
1734 /*************************************************************************
1735 * ImageList_GetIcon [COMCTL32.@]
1737 * Creates an icon from a masked image of an image list.
1740 * himl [I] handle to image list
1742 * flags [I] drawing style flags
1745 * Success: icon handle
1750 ImageList_GetIcon (HIMAGELIST himl
, INT i
, UINT fStyle
)
1754 HBITMAP hOldDstBitmap
;
1758 TRACE("%p %d %d\n", himl
, i
, fStyle
);
1759 if (!is_valid(himl
) || (i
< 0) || (i
>= himl
->cCurImage
)) return NULL
;
1765 /* create colour bitmap */
1767 ii
.hbmColor
= CreateCompatibleBitmap(hdcDst
, himl
->cx
, himl
->cy
);
1768 ReleaseDC(0, hdcDst
);
1770 hdcDst
= CreateCompatibleDC(0);
1772 imagelist_point_from_index( himl
, i
, &pt
);
1775 ii
.hbmMask
= CreateBitmap (himl
->cx
, himl
->cy
, 1, 1, NULL
);
1776 hOldDstBitmap
= SelectObject (hdcDst
, ii
.hbmMask
);
1777 if (himl
->hbmMask
) {
1778 BitBlt (hdcDst
, 0, 0, himl
->cx
, himl
->cy
,
1779 himl
->hdcMask
, pt
.x
, pt
.y
, SRCCOPY
);
1782 PatBlt (hdcDst
, 0, 0, himl
->cx
, himl
->cy
, BLACKNESS
);
1785 SelectObject (hdcDst
, ii
.hbmColor
);
1786 BitBlt (hdcDst
, 0, 0, himl
->cx
, himl
->cy
,
1787 himl
->hdcImage
, pt
.x
, pt
.y
, SRCCOPY
);
1790 * CreateIconIndirect requires us to deselect the bitmaps from
1791 * the DCs before calling
1793 SelectObject(hdcDst
, hOldDstBitmap
);
1795 hIcon
= CreateIconIndirect (&ii
);
1797 DeleteObject (ii
.hbmMask
);
1798 DeleteObject (ii
.hbmColor
);
1805 /*************************************************************************
1806 * ImageList_GetIconSize [COMCTL32.@]
1808 * Retrieves the size of an image in an image list.
1811 * himl [I] handle to image list
1812 * cx [O] pointer to the image width.
1813 * cy [O] pointer to the image height.
1820 * All images in an image list have the same size.
1824 ImageList_GetIconSize (HIMAGELIST himl
, INT
*cx
, INT
*cy
)
1826 if (!is_valid(himl
) || !cx
|| !cy
)
1828 if ((himl
->cx
<= 0) || (himl
->cy
<= 0))
1838 /*************************************************************************
1839 * ImageList_GetImageCount [COMCTL32.@]
1841 * Returns the number of images in an image list.
1844 * himl [I] handle to image list
1847 * Success: Number of images.
1852 ImageList_GetImageCount (HIMAGELIST himl
)
1854 if (!is_valid(himl
))
1857 return himl
->cCurImage
;
1861 /*************************************************************************
1862 * ImageList_GetImageInfo [COMCTL32.@]
1864 * Returns information about an image in an image list.
1867 * himl [I] handle to image list
1869 * pImageInfo [O] pointer to the image information
1877 ImageList_GetImageInfo (HIMAGELIST himl
, INT i
, IMAGEINFO
*pImageInfo
)
1881 if (!is_valid(himl
) || (pImageInfo
== NULL
))
1883 if ((i
< 0) || (i
>= himl
->cCurImage
))
1886 pImageInfo
->hbmImage
= himl
->hbmImage
;
1887 pImageInfo
->hbmMask
= himl
->hbmMask
;
1889 imagelist_point_from_index( himl
, i
, &pt
);
1890 pImageInfo
->rcImage
.top
= pt
.y
;
1891 pImageInfo
->rcImage
.bottom
= pt
.y
+ himl
->cy
;
1892 pImageInfo
->rcImage
.left
= pt
.x
;
1893 pImageInfo
->rcImage
.right
= pt
.x
+ himl
->cx
;
1899 /*************************************************************************
1900 * ImageList_GetImageRect [COMCTL32.@]
1902 * Retrieves the rectangle of the specified image in an image list.
1905 * himl [I] handle to image list
1907 * lpRect [O] pointer to the image rectangle
1914 * This is an UNDOCUMENTED function!!!
1918 ImageList_GetImageRect (HIMAGELIST himl
, INT i
, LPRECT lpRect
)
1922 if (!is_valid(himl
) || (lpRect
== NULL
))
1924 if ((i
< 0) || (i
>= himl
->cCurImage
))
1927 imagelist_point_from_index( himl
, i
, &pt
);
1928 lpRect
->left
= pt
.x
;
1930 lpRect
->right
= pt
.x
+ himl
->cx
;
1931 lpRect
->bottom
= pt
.y
+ himl
->cy
;
1937 /*************************************************************************
1938 * ImageList_LoadImage [COMCTL32.@]
1939 * ImageList_LoadImageA [COMCTL32.@]
1941 * Creates an image list from a bitmap, icon or cursor.
1943 * See ImageList_LoadImageW.
1947 ImageList_LoadImageA (HINSTANCE hi
, LPCSTR lpbmp
, INT cx
, INT cGrow
,
1948 COLORREF clrMask
, UINT uType
, UINT uFlags
)
1954 if (IS_INTRESOURCE(lpbmp
))
1955 return ImageList_LoadImageW(hi
, (LPCWSTR
)lpbmp
, cx
, cGrow
, clrMask
,
1958 len
= MultiByteToWideChar(CP_ACP
, 0, lpbmp
, -1, NULL
, 0);
1959 lpbmpW
= Alloc(len
* sizeof(WCHAR
));
1960 MultiByteToWideChar(CP_ACP
, 0, lpbmp
, -1, lpbmpW
, len
);
1962 himl
= ImageList_LoadImageW(hi
, lpbmpW
, cx
, cGrow
, clrMask
, uType
, uFlags
);
1968 /*************************************************************************
1969 * ImageList_LoadImageW [COMCTL32.@]
1971 * Creates an image list from a bitmap, icon or cursor.
1974 * hi [I] instance handle
1975 * lpbmp [I] name or id of the image
1976 * cx [I] width of each image
1977 * cGrow [I] number of images to expand
1978 * clrMask [I] mask color
1979 * uType [I] type of image to load
1980 * uFlags [I] loading flags
1983 * Success: handle to the loaded image list
1991 ImageList_LoadImageW (HINSTANCE hi
, LPCWSTR lpbmp
, INT cx
, INT cGrow
,
1992 COLORREF clrMask
, UINT uType
, UINT uFlags
)
1994 HIMAGELIST himl
= NULL
;
1998 handle
= LoadImageW (hi
, lpbmp
, uType
, 0, 0, uFlags
);
2000 WARN("Couldn't load image\n");
2004 if (uType
== IMAGE_BITMAP
) {
2008 if (GetObjectW (handle
, sizeof(dib
), &dib
) == sizeof(BITMAP
)) color
= ILC_COLOR
;
2009 else color
= dib
.dsBm
.bmBitsPixel
;
2011 /* To match windows behavior, if cx is set to zero and
2012 the flag DI_DEFAULTSIZE is specified, cx becomes the
2013 system metric value for icons. If the flag is not specified
2014 the function sets the size to the height of the bitmap */
2017 if (uFlags
& DI_DEFAULTSIZE
)
2018 cx
= GetSystemMetrics (SM_CXICON
);
2020 cx
= dib
.dsBm
.bmHeight
;
2023 nImageCount
= dib
.dsBm
.bmWidth
/ cx
;
2025 himl
= ImageList_Create (cx
, dib
.dsBm
.bmHeight
, ILC_MASK
| color
, nImageCount
, cGrow
);
2027 DeleteObject (handle
);
2030 ImageList_AddMasked (himl
, handle
, clrMask
);
2032 else if ((uType
== IMAGE_ICON
) || (uType
== IMAGE_CURSOR
)) {
2036 GetIconInfo (handle
, &ii
);
2037 GetObjectW (ii
.hbmColor
, sizeof(BITMAP
), &bmp
);
2038 himl
= ImageList_Create (bmp
.bmWidth
, bmp
.bmHeight
,
2039 ILC_MASK
| ILC_COLOR
, 1, cGrow
);
2041 DeleteObject (ii
.hbmColor
);
2042 DeleteObject (ii
.hbmMask
);
2043 DeleteObject (handle
);
2046 ImageList_Add (himl
, ii
.hbmColor
, ii
.hbmMask
);
2047 DeleteObject (ii
.hbmColor
);
2048 DeleteObject (ii
.hbmMask
);
2051 DeleteObject (handle
);
2057 /*************************************************************************
2058 * ImageList_Merge [COMCTL32.@]
2060 * Create an image list containing a merged image from two image lists.
2063 * himl1 [I] handle to first image list
2064 * i1 [I] first image index
2065 * himl2 [I] handle to second image list
2066 * i2 [I] second image index
2067 * dx [I] X offset of the second image relative to the first.
2068 * dy [I] Y offset of the second image relative to the first.
2071 * Success: The newly created image list. It contains a single image
2072 * consisting of the second image merged with the first.
2073 * Failure: NULL, if either himl1 or himl2 are invalid.
2076 * - The returned image list should be deleted by the caller using
2077 * ImageList_Destroy() when it is no longer required.
2078 * - If either i1 or i2 are not valid image indices they will be treated
2082 ImageList_Merge (HIMAGELIST himl1
, INT i1
, HIMAGELIST himl2
, INT i2
,
2085 HIMAGELIST himlDst
= NULL
;
2087 INT xOff1
, yOff1
, xOff2
, yOff2
;
2091 TRACE("(himl1=%p i1=%d himl2=%p i2=%d dx=%d dy=%d)\n", himl1
, i1
, himl2
,
2094 if (!is_valid(himl1
) || !is_valid(himl2
))
2098 cxDst
= max (himl1
->cx
, dx
+ himl2
->cx
);
2103 cxDst
= max (himl2
->cx
, himl1
->cx
- dx
);
2108 cxDst
= max (himl1
->cx
, himl2
->cx
);
2114 cyDst
= max (himl1
->cy
, dy
+ himl2
->cy
);
2119 cyDst
= max (himl2
->cy
, himl1
->cy
- dy
);
2124 cyDst
= max (himl1
->cy
, himl2
->cy
);
2129 newFlags
= (himl1
->flags
> himl2
->flags
? himl1
->flags
: himl2
->flags
) & ILC_COLORDDB
;
2130 if (newFlags
== ILC_COLORDDB
&& (himl1
->flags
& ILC_COLORDDB
) == ILC_COLOR16
)
2131 newFlags
= ILC_COLOR16
; /* this is what native (at least v5) does, don't know why */
2132 himlDst
= ImageList_Create (cxDst
, cyDst
, ILC_MASK
| newFlags
, 1, 1);
2136 imagelist_point_from_index( himl1
, i1
, &pt1
);
2137 imagelist_point_from_index( himl2
, i2
, &pt2
);
2140 BitBlt (himlDst
->hdcImage
, 0, 0, cxDst
, cyDst
, himl1
->hdcImage
, 0, 0, BLACKNESS
);
2141 if (i1
>= 0 && i1
< himl1
->cCurImage
)
2142 BitBlt (himlDst
->hdcImage
, xOff1
, yOff1
, himl1
->cx
, himl1
->cy
, himl1
->hdcImage
, pt1
.x
, pt1
.y
, SRCCOPY
);
2143 if (i2
>= 0 && i2
< himl2
->cCurImage
)
2145 if (himl2
->flags
& ILC_MASK
)
2147 BitBlt (himlDst
->hdcImage
, xOff2
, yOff2
, himl2
->cx
, himl2
->cy
, himl2
->hdcMask
, pt2
.x
, pt2
.y
, SRCAND
);
2148 BitBlt (himlDst
->hdcImage
, xOff2
, yOff2
, himl2
->cx
, himl2
->cy
, himl2
->hdcImage
, pt2
.x
, pt2
.y
, SRCPAINT
);
2151 BitBlt (himlDst
->hdcImage
, xOff2
, yOff2
, himl2
->cx
, himl2
->cy
, himl2
->hdcImage
, pt2
.x
, pt2
.y
, SRCCOPY
);
2155 BitBlt (himlDst
->hdcMask
, 0, 0, cxDst
, cyDst
, himl1
->hdcMask
, 0, 0, WHITENESS
);
2156 if (i1
>= 0 && i1
< himl1
->cCurImage
)
2157 BitBlt (himlDst
->hdcMask
, xOff1
, yOff1
, himl1
->cx
, himl1
->cy
, himl1
->hdcMask
, pt1
.x
, pt1
.y
, SRCCOPY
);
2158 if (i2
>= 0 && i2
< himl2
->cCurImage
)
2159 BitBlt (himlDst
->hdcMask
, xOff2
, yOff2
, himl2
->cx
, himl2
->cy
, himl2
->hdcMask
, pt2
.x
, pt2
.y
, SRCAND
);
2161 himlDst
->cCurImage
= 1;
2168 /* helper for ImageList_Read, see comments below */
2169 static void *read_bitmap(LPSTREAM pstm
, BITMAPINFO
*bmi
)
2171 BITMAPFILEHEADER bmfh
;
2172 int bitsperpixel
, palspace
;
2175 if (FAILED(IStream_Read ( pstm
, &bmfh
, sizeof(bmfh
), NULL
)))
2178 if (bmfh
.bfType
!= (('M'<<8)|'B'))
2181 if (FAILED(IStream_Read ( pstm
, &bmi
->bmiHeader
, sizeof(bmi
->bmiHeader
), NULL
)))
2184 if ((bmi
->bmiHeader
.biSize
!= sizeof(bmi
->bmiHeader
)))
2187 TRACE("width %u, height %u, planes %u, bpp %u\n",
2188 bmi
->bmiHeader
.biWidth
, bmi
->bmiHeader
.biHeight
,
2189 bmi
->bmiHeader
.biPlanes
, bmi
->bmiHeader
.biBitCount
);
2191 bitsperpixel
= bmi
->bmiHeader
.biPlanes
* bmi
->bmiHeader
.biBitCount
;
2192 if (bitsperpixel
<=8)
2193 palspace
= (1<<bitsperpixel
)*sizeof(RGBQUAD
);
2197 bmi
->bmiHeader
.biSizeImage
= get_dib_image_size( bmi
);
2199 /* read the palette right after the end of the bitmapinfoheader */
2200 if (palspace
&& FAILED(IStream_Read(pstm
, bmi
->bmiColors
, palspace
, NULL
)))
2203 bits
= Alloc(bmi
->bmiHeader
.biSizeImage
);
2204 if (!bits
) return NULL
;
2206 if (FAILED(IStream_Read(pstm
, bits
, bmi
->bmiHeader
.biSizeImage
, NULL
)))
2214 /*************************************************************************
2215 * ImageList_Read [COMCTL32.@]
2217 * Reads an image list from a stream.
2220 * pstm [I] pointer to a stream
2223 * Success: handle to image list
2226 * The format is like this:
2227 * ILHEAD ilheadstruct;
2229 * for the color image part:
2230 * BITMAPFILEHEADER bmfh;
2231 * BITMAPINFOHEADER bmih;
2232 * only if it has a palette:
2233 * RGBQUAD rgbs[nr_of_paletted_colors];
2235 * BYTE colorbits[imagesize];
2237 * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags:
2238 * BITMAPFILEHEADER bmfh_mask;
2239 * BITMAPINFOHEADER bmih_mask;
2240 * only if it has a palette (it usually does not):
2241 * RGBQUAD rgbs[nr_of_paletted_colors];
2243 * BYTE maskbits[imagesize];
2245 HIMAGELIST WINAPI
ImageList_Read (LPSTREAM pstm
)
2247 char image_buf
[sizeof(BITMAPINFOHEADER
) + sizeof(RGBQUAD
) * 256];
2248 char mask_buf
[sizeof(BITMAPINFOHEADER
) + sizeof(RGBQUAD
) * 256];
2249 BITMAPINFO
*image_info
= (BITMAPINFO
*)image_buf
;
2250 BITMAPINFO
*mask_info
= (BITMAPINFO
*)mask_buf
;
2251 void *image_bits
, *mask_bits
= NULL
;
2256 TRACE("%p\n", pstm
);
2258 if (FAILED(IStream_Read (pstm
, &ilHead
, sizeof(ILHEAD
), NULL
)))
2260 if (ilHead
.usMagic
!= (('L' << 8) | 'I'))
2262 if (ilHead
.usVersion
!= 0x101) /* probably version? */
2265 TRACE("cx %u, cy %u, flags 0x%04x, cCurImage %u, cMaxImage %u\n",
2266 ilHead
.cx
, ilHead
.cy
, ilHead
.flags
, ilHead
.cCurImage
, ilHead
.cMaxImage
);
2268 himl
= ImageList_Create(ilHead
.cx
, ilHead
.cy
, ilHead
.flags
, ilHead
.cCurImage
, ilHead
.cMaxImage
);
2272 if (!(image_bits
= read_bitmap(pstm
, image_info
)))
2274 WARN("failed to read bitmap from stream\n");
2277 if (ilHead
.flags
& ILC_MASK
)
2279 if (!(mask_bits
= read_bitmap(pstm
, mask_info
)))
2281 WARN("failed to read mask bitmap from stream\n");
2285 else mask_info
= NULL
;
2287 if (himl
->has_alpha
&& image_info
->bmiHeader
.biBitCount
== 32)
2289 DWORD
*ptr
= image_bits
;
2290 BYTE
*mask_ptr
= mask_bits
;
2291 int stride
= himl
->cy
* image_info
->bmiHeader
.biWidth
;
2293 if (image_info
->bmiHeader
.biHeight
> 0) /* bottom-up */
2295 ptr
+= image_info
->bmiHeader
.biHeight
* image_info
->bmiHeader
.biWidth
- stride
;
2296 mask_ptr
+= (image_info
->bmiHeader
.biHeight
* image_info
->bmiHeader
.biWidth
- stride
) / 8;
2298 image_info
->bmiHeader
.biHeight
= himl
->cy
;
2300 else image_info
->bmiHeader
.biHeight
= -himl
->cy
;
2302 for (i
= 0; i
< ilHead
.cCurImage
; i
+= TILE_COUNT
)
2304 add_dib_bits( himl
, i
, min( ilHead
.cCurImage
- i
, TILE_COUNT
),
2305 himl
->cx
, himl
->cy
, image_info
, mask_info
, ptr
, mask_ptr
);
2307 mask_ptr
+= stride
/ 8;
2312 StretchDIBits( himl
->hdcImage
, 0, 0, image_info
->bmiHeader
.biWidth
, image_info
->bmiHeader
.biHeight
,
2313 0, 0, image_info
->bmiHeader
.biWidth
, image_info
->bmiHeader
.biHeight
,
2314 image_bits
, image_info
, DIB_RGB_COLORS
, SRCCOPY
);
2316 StretchDIBits( himl
->hdcMask
, 0, 0, mask_info
->bmiHeader
.biWidth
, mask_info
->bmiHeader
.biHeight
,
2317 0, 0, mask_info
->bmiHeader
.biWidth
, mask_info
->bmiHeader
.biHeight
,
2318 mask_bits
, mask_info
, DIB_RGB_COLORS
, SRCCOPY
);
2323 himl
->cCurImage
= ilHead
.cCurImage
;
2324 himl
->cMaxImage
= ilHead
.cMaxImage
;
2326 ImageList_SetBkColor(himl
,ilHead
.bkcolor
);
2328 ImageList_SetOverlayImage(himl
,ilHead
.ovls
[i
],i
+1);
2333 /*************************************************************************
2334 * ImageList_Remove [COMCTL32.@]
2336 * Removes an image from an image list
2339 * himl [I] image list handle
2346 * FIXME: as the image list storage test shows, native comctl32 simply shifts
2347 * images without creating a new bitmap.
2350 ImageList_Remove (HIMAGELIST himl
, INT i
)
2352 HBITMAP hbmNewImage
, hbmNewMask
;
2356 TRACE("(himl=%p i=%d)\n", himl
, i
);
2358 if (!is_valid(himl
)) {
2359 ERR("Invalid image list handle!\n");
2363 if ((i
< -1) || (i
>= himl
->cCurImage
)) {
2364 TRACE("index out of range! %d\n", i
);
2372 if (himl
->cCurImage
== 0) {
2373 /* remove all on empty ImageList is allowed */
2374 TRACE("remove all on empty ImageList!\n");
2378 himl
->cMaxImage
= himl
->cGrow
;
2379 himl
->cCurImage
= 0;
2380 for (nCount
= 0; nCount
< MAX_OVERLAYIMAGE
; nCount
++)
2381 himl
->nOvlIdx
[nCount
] = -1;
2383 hbmNewImage
= ImageList_CreateImage(himl
->hdcImage
, himl
, himl
->cMaxImage
);
2384 SelectObject (himl
->hdcImage
, hbmNewImage
);
2385 DeleteObject (himl
->hbmImage
);
2386 himl
->hbmImage
= hbmNewImage
;
2388 if (himl
->hbmMask
) {
2390 imagelist_get_bitmap_size(himl
, himl
->cMaxImage
, &sz
);
2391 hbmNewMask
= CreateBitmap (sz
.cx
, sz
.cy
, 1, 1, NULL
);
2392 SelectObject (himl
->hdcMask
, hbmNewMask
);
2393 DeleteObject (himl
->hbmMask
);
2394 himl
->hbmMask
= hbmNewMask
;
2398 /* delete one image */
2399 TRACE("Remove single image! %d\n", i
);
2401 /* create new bitmap(s) */
2402 TRACE(" - Number of images: %d / %d (Old/New)\n",
2403 himl
->cCurImage
, himl
->cCurImage
- 1);
2405 hbmNewImage
= ImageList_CreateImage(himl
->hdcImage
, himl
, himl
->cMaxImage
);
2407 imagelist_get_bitmap_size(himl
, himl
->cMaxImage
, &sz
);
2409 hbmNewMask
= CreateBitmap (sz
.cx
, sz
.cy
, 1, 1, NULL
);
2411 hbmNewMask
= 0; /* Just to keep compiler happy! */
2413 hdcBmp
= CreateCompatibleDC (0);
2415 /* copy all images and masks prior to the "removed" image */
2417 TRACE("Pre image copy: Copy %d images\n", i
);
2419 SelectObject (hdcBmp
, hbmNewImage
);
2420 imagelist_copy_images( himl
, himl
->hdcImage
, hdcBmp
, 0, i
, 0 );
2422 if (himl
->hbmMask
) {
2423 SelectObject (hdcBmp
, hbmNewMask
);
2424 imagelist_copy_images( himl
, himl
->hdcMask
, hdcBmp
, 0, i
, 0 );
2428 /* copy all images and masks behind the removed image */
2429 if (i
< himl
->cCurImage
- 1) {
2430 TRACE("Post image copy!\n");
2432 SelectObject (hdcBmp
, hbmNewImage
);
2433 imagelist_copy_images( himl
, himl
->hdcImage
, hdcBmp
, i
+ 1,
2434 (himl
->cCurImage
- i
), i
);
2436 if (himl
->hbmMask
) {
2437 SelectObject (hdcBmp
, hbmNewMask
);
2438 imagelist_copy_images( himl
, himl
->hdcMask
, hdcBmp
, i
+ 1,
2439 (himl
->cCurImage
- i
), i
);
2445 /* delete old images and insert new ones */
2446 SelectObject (himl
->hdcImage
, hbmNewImage
);
2447 DeleteObject (himl
->hbmImage
);
2448 himl
->hbmImage
= hbmNewImage
;
2449 if (himl
->hbmMask
) {
2450 SelectObject (himl
->hdcMask
, hbmNewMask
);
2451 DeleteObject (himl
->hbmMask
);
2452 himl
->hbmMask
= hbmNewMask
;
2462 /*************************************************************************
2463 * ImageList_Replace [COMCTL32.@]
2465 * Replaces an image in an image list with a new image.
2468 * himl [I] handle to image list
2470 * hbmImage [I] handle to image bitmap
2471 * hbmMask [I] handle to mask bitmap. Can be NULL.
2479 ImageList_Replace (HIMAGELIST himl
, INT i
, HBITMAP hbmImage
,
2486 TRACE("%p %d %p %p\n", himl
, i
, hbmImage
, hbmMask
);
2488 if (!is_valid(himl
)) {
2489 ERR("Invalid image list handle!\n");
2493 if ((i
>= himl
->cMaxImage
) || (i
< 0)) {
2494 ERR("Invalid image index!\n");
2498 if (!GetObjectW(hbmImage
, sizeof(BITMAP
), &bmp
))
2501 hdcImage
= CreateCompatibleDC (0);
2504 SelectObject (hdcImage
, hbmImage
);
2506 if (add_with_alpha( himl
, hdcImage
, i
, 1, bmp
.bmWidth
, bmp
.bmHeight
, hbmImage
, hbmMask
))
2509 imagelist_point_from_index(himl
, i
, &pt
);
2510 StretchBlt (himl
->hdcImage
, pt
.x
, pt
.y
, himl
->cx
, himl
->cy
,
2511 hdcImage
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
, SRCCOPY
);
2516 HBITMAP hOldBitmapTemp
;
2518 hdcTemp
= CreateCompatibleDC(0);
2519 hOldBitmapTemp
= SelectObject(hdcTemp
, hbmMask
);
2521 StretchBlt (himl
->hdcMask
, pt
.x
, pt
.y
, himl
->cx
, himl
->cy
,
2522 hdcTemp
, 0, 0, bmp
.bmWidth
, bmp
.bmHeight
, SRCCOPY
);
2523 SelectObject(hdcTemp
, hOldBitmapTemp
);
2526 /* Remove the background from the image
2528 BitBlt (himl
->hdcImage
, pt
.x
, pt
.y
, bmp
.bmWidth
, bmp
.bmHeight
,
2529 himl
->hdcMask
, pt
.x
, pt
.y
, 0x220326); /* NOTSRCAND */
2533 DeleteDC (hdcImage
);
2539 /*************************************************************************
2540 * ImageList_ReplaceIcon [COMCTL32.@]
2542 * Replaces an image in an image list using an icon.
2545 * himl [I] handle to image list
2547 * hIcon [I] handle to icon
2550 * Success: index of the replaced image
2555 ImageList_ReplaceIcon (HIMAGELIST himl
, INT nIndex
, HICON hIcon
)
2563 TRACE("(%p %d %p)\n", himl
, nIndex
, hIcon
);
2565 if (!is_valid(himl
)) {
2566 ERR("invalid image list\n");
2569 if ((nIndex
>= himl
->cMaxImage
) || (nIndex
< -1)) {
2570 ERR("invalid image index %d / %d\n", nIndex
, himl
->cMaxImage
);
2574 hBestFitIcon
= CopyImage(
2577 LR_COPYFROMRESOURCE
);
2578 /* the above will fail if the icon wasn't loaded from a resource, so try
2579 * again without LR_COPYFROMRESOURCE flag */
2581 hBestFitIcon
= CopyImage(
2589 if (himl
->cCurImage
+ 1 >= himl
->cMaxImage
)
2590 IMAGELIST_InternalExpandBitmaps(himl
, 1);
2592 nIndex
= himl
->cCurImage
;
2596 if (himl
->has_alpha
&& GetIconInfo (hBestFitIcon
, &ii
))
2598 HDC hdcImage
= CreateCompatibleDC( 0 );
2599 GetObjectW (ii
.hbmMask
, sizeof(BITMAP
), &bmp
);
2603 UINT height
= bmp
.bmHeight
/ 2;
2604 HDC hdcMask
= CreateCompatibleDC( 0 );
2605 HBITMAP color
= CreateBitmap( bmp
.bmWidth
, height
, 1, 1, NULL
);
2606 SelectObject( hdcImage
, color
);
2607 SelectObject( hdcMask
, ii
.hbmMask
);
2608 BitBlt( hdcImage
, 0, 0, bmp
.bmWidth
, height
, hdcMask
, 0, height
, SRCCOPY
);
2609 ret
= add_with_alpha( himl
, hdcImage
, nIndex
, 1, bmp
.bmWidth
, height
, color
, ii
.hbmMask
);
2610 DeleteDC( hdcMask
);
2611 DeleteObject( color
);
2613 else ret
= add_with_alpha( himl
, hdcImage
, nIndex
, 1, bmp
.bmWidth
, bmp
.bmHeight
,
2614 ii
.hbmColor
, ii
.hbmMask
);
2616 DeleteDC( hdcImage
);
2617 DeleteObject (ii
.hbmMask
);
2618 if (ii
.hbmColor
) DeleteObject (ii
.hbmColor
);
2622 imagelist_point_from_index(himl
, nIndex
, &pt
);
2626 DrawIconEx( himl
->hdcImage
, pt
.x
, pt
.y
, hBestFitIcon
, himl
->cx
, himl
->cy
, 0, 0, DI_IMAGE
);
2627 PatBlt( himl
->hdcMask
, pt
.x
, pt
.y
, himl
->cx
, himl
->cy
, WHITENESS
);
2628 DrawIconEx( himl
->hdcMask
, pt
.x
, pt
.y
, hBestFitIcon
, himl
->cx
, himl
->cy
, 0, 0, DI_MASK
);
2632 COLORREF color
= himl
->clrBk
!= CLR_NONE
? himl
->clrBk
: comctl32_color
.clrWindow
;
2633 HBRUSH brush
= CreateSolidBrush( GetNearestColor( himl
->hdcImage
, color
));
2635 SelectObject( himl
->hdcImage
, brush
);
2636 PatBlt( himl
->hdcImage
, pt
.x
, pt
.y
, himl
->cx
, himl
->cy
, PATCOPY
);
2637 SelectObject( himl
->hdcImage
, GetStockObject(BLACK_BRUSH
) );
2638 DeleteObject( brush
);
2639 DrawIconEx( himl
->hdcImage
, pt
.x
, pt
.y
, hBestFitIcon
, himl
->cx
, himl
->cy
, 0, 0, DI_NORMAL
);
2643 DestroyIcon(hBestFitIcon
);
2645 TRACE("Insert index = %d, himl->cCurImage = %d\n", nIndex
, himl
->cCurImage
);
2650 /*************************************************************************
2651 * ImageList_SetBkColor [COMCTL32.@]
2653 * Sets the background color of an image list.
2656 * himl [I] handle to image list
2657 * clrBk [I] background color
2660 * Success: previous background color
2665 ImageList_SetBkColor (HIMAGELIST himl
, COLORREF clrBk
)
2669 if (!is_valid(himl
))
2672 clrOldBk
= himl
->clrBk
;
2673 himl
->clrBk
= clrBk
;
2678 /*************************************************************************
2679 * ImageList_SetDragCursorImage [COMCTL32.@]
2681 * Combines the specified image with the current drag image
2684 * himlDrag [I] handle to drag image list
2685 * iDrag [I] drag image index
2686 * dxHotspot [I] X position of the hot spot
2687 * dyHotspot [I] Y position of the hot spot
2694 * - The names dxHotspot, dyHotspot are misleading because they have nothing
2695 * to do with a hotspot but are only the offset of the origin of the new
2696 * image relative to the origin of the old image.
2698 * - When this function is called and the drag image is visible, a
2699 * short flickering occurs but this matches the Win9x behavior. It is
2700 * possible to fix the flickering using code like in ImageList_DragMove.
2704 ImageList_SetDragCursorImage (HIMAGELIST himlDrag
, INT iDrag
,
2705 INT dxHotspot
, INT dyHotspot
)
2707 HIMAGELIST himlTemp
;
2710 if (!is_valid(InternalDrag
.himl
) || !is_valid(himlDrag
))
2713 TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n",
2714 dxHotspot
, dyHotspot
, InternalDrag
.dxHotspot
, InternalDrag
.dyHotspot
);
2716 visible
= InternalDrag
.bShow
;
2718 himlTemp
= ImageList_Merge (InternalDrag
.himlNoCursor
, 0, himlDrag
, iDrag
,
2719 dxHotspot
, dyHotspot
);
2722 /* hide the drag image */
2723 ImageList_DragShowNolock(FALSE
);
2725 if ((InternalDrag
.himl
->cx
!= himlTemp
->cx
) ||
2726 (InternalDrag
.himl
->cy
!= himlTemp
->cy
)) {
2727 /* the size of the drag image changed, invalidate the buffer */
2728 DeleteObject(InternalDrag
.hbmBg
);
2729 InternalDrag
.hbmBg
= 0;
2732 if (InternalDrag
.himl
!= InternalDrag
.himlNoCursor
)
2733 ImageList_Destroy (InternalDrag
.himl
);
2734 InternalDrag
.himl
= himlTemp
;
2737 /* show the drag image */
2738 ImageList_DragShowNolock(TRUE
);
2745 /*************************************************************************
2746 * ImageList_SetFilter [COMCTL32.@]
2748 * Sets a filter (or does something completely different)!!???
2749 * It removes 12 Bytes from the stack (3 Parameters).
2752 * himl [I] SHOULD be a handle to image list
2753 * i [I] COULD be an index?
2758 * Failure: FALSE ???
2761 * This is an UNDOCUMENTED function!!!!
2766 ImageList_SetFilter (HIMAGELIST himl
, INT i
, DWORD dwFilter
)
2768 FIXME("(%p 0x%x 0x%x):empty stub!\n", himl
, i
, dwFilter
);
2774 /*************************************************************************
2775 * ImageList_SetFlags [COMCTL32.@]
2777 * Sets the image list flags.
2780 * himl [I] Handle to image list
2781 * flags [I] Flags to set
2791 ImageList_SetFlags(HIMAGELIST himl
, DWORD flags
)
2793 FIXME("(%p %08x):empty stub\n", himl
, flags
);
2798 /*************************************************************************
2799 * ImageList_SetIconSize [COMCTL32.@]
2801 * Sets the image size of the bitmap and deletes all images.
2804 * himl [I] handle to image list
2805 * cx [I] image width
2806 * cy [I] image height
2814 ImageList_SetIconSize (HIMAGELIST himl
, INT cx
, INT cy
)
2819 if (!is_valid(himl
))
2822 /* remove all images */
2823 himl
->cMaxImage
= himl
->cInitial
+ 1;
2824 himl
->cCurImage
= 0;
2828 /* initialize overlay mask indices */
2829 for (nCount
= 0; nCount
< MAX_OVERLAYIMAGE
; nCount
++)
2830 himl
->nOvlIdx
[nCount
] = -1;
2832 hbmNew
= ImageList_CreateImage(himl
->hdcImage
, himl
, himl
->cMaxImage
);
2833 SelectObject (himl
->hdcImage
, hbmNew
);
2834 DeleteObject (himl
->hbmImage
);
2835 himl
->hbmImage
= hbmNew
;
2837 if (himl
->hbmMask
) {
2839 imagelist_get_bitmap_size(himl
, himl
->cMaxImage
, &sz
);
2840 hbmNew
= CreateBitmap (sz
.cx
, sz
.cy
, 1, 1, NULL
);
2841 SelectObject (himl
->hdcMask
, hbmNew
);
2842 DeleteObject (himl
->hbmMask
);
2843 himl
->hbmMask
= hbmNew
;
2850 /*************************************************************************
2851 * ImageList_SetImageCount [COMCTL32.@]
2853 * Resizes an image list to the specified number of images.
2856 * himl [I] handle to image list
2857 * iImageCount [I] number of images in the image list
2865 ImageList_SetImageCount (HIMAGELIST himl
, UINT iImageCount
)
2868 HBITMAP hbmNewBitmap
, hbmOld
;
2869 INT nNewCount
, nCopyCount
;
2871 TRACE("%p %d\n",himl
,iImageCount
);
2873 if (!is_valid(himl
))
2876 nNewCount
= iImageCount
+ 1;
2877 nCopyCount
= min(himl
->cCurImage
, iImageCount
);
2879 hdcBitmap
= CreateCompatibleDC (0);
2881 hbmNewBitmap
= ImageList_CreateImage(hdcBitmap
, himl
, nNewCount
);
2883 if (hbmNewBitmap
!= 0)
2885 hbmOld
= SelectObject (hdcBitmap
, hbmNewBitmap
);
2886 imagelist_copy_images( himl
, himl
->hdcImage
, hdcBitmap
, 0, nCopyCount
, 0 );
2887 SelectObject (hdcBitmap
, hbmOld
);
2889 /* FIXME: delete 'empty' image space? */
2891 SelectObject (himl
->hdcImage
, hbmNewBitmap
);
2892 DeleteObject (himl
->hbmImage
);
2893 himl
->hbmImage
= hbmNewBitmap
;
2896 ERR("Could not create new image bitmap !\n");
2901 imagelist_get_bitmap_size( himl
, nNewCount
, &sz
);
2902 hbmNewBitmap
= CreateBitmap (sz
.cx
, sz
.cy
, 1, 1, NULL
);
2903 if (hbmNewBitmap
!= 0)
2905 hbmOld
= SelectObject (hdcBitmap
, hbmNewBitmap
);
2906 imagelist_copy_images( himl
, himl
->hdcMask
, hdcBitmap
, 0, nCopyCount
, 0 );
2907 SelectObject (hdcBitmap
, hbmOld
);
2909 /* FIXME: delete 'empty' image space? */
2911 SelectObject (himl
->hdcMask
, hbmNewBitmap
);
2912 DeleteObject (himl
->hbmMask
);
2913 himl
->hbmMask
= hbmNewBitmap
;
2916 ERR("Could not create new mask bitmap!\n");
2919 DeleteDC (hdcBitmap
);
2921 if (himl
->has_alpha
)
2923 char *new_alpha
= HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
, himl
->has_alpha
, nNewCount
);
2924 if (new_alpha
) himl
->has_alpha
= new_alpha
;
2927 HeapFree( GetProcessHeap(), 0, himl
->has_alpha
);
2928 himl
->has_alpha
= NULL
;
2932 /* Update max image count and current image count */
2933 himl
->cMaxImage
= nNewCount
;
2934 himl
->cCurImage
= iImageCount
;
2940 /*************************************************************************
2941 * ImageList_SetOverlayImage [COMCTL32.@]
2943 * Assigns an overlay mask index to an existing image in an image list.
2946 * himl [I] handle to image list
2947 * iImage [I] image index
2948 * iOverlay [I] overlay mask index
2956 ImageList_SetOverlayImage (HIMAGELIST himl
, INT iImage
, INT iOverlay
)
2958 if (!is_valid(himl
))
2960 if ((iOverlay
< 1) || (iOverlay
> MAX_OVERLAYIMAGE
))
2962 if ((iImage
!=-1) && ((iImage
< 0) || (iImage
> himl
->cCurImage
)))
2964 himl
->nOvlIdx
[iOverlay
- 1] = iImage
;
2970 /* helper for ImageList_Write - write bitmap to pstm
2971 * currently everything is written as 24 bit RGB, except masks
2974 _write_bitmap(HBITMAP hBitmap
, LPSTREAM pstm
)
2976 LPBITMAPFILEHEADER bmfh
;
2977 LPBITMAPINFOHEADER bmih
;
2978 LPBYTE data
= NULL
, lpBits
;
2980 INT bitCount
, sizeImage
, offBits
, totalSize
;
2982 BOOL result
= FALSE
;
2984 if (!GetObjectW(hBitmap
, sizeof(BITMAP
), &bm
))
2987 bitCount
= bm
.bmBitsPixel
;
2988 sizeImage
= get_dib_stride(bm
.bmWidth
, bitCount
) * bm
.bmHeight
;
2990 totalSize
= sizeof(BITMAPFILEHEADER
) + sizeof(BITMAPINFOHEADER
);
2992 totalSize
+= (1 << bitCount
) * sizeof(RGBQUAD
);
2993 offBits
= totalSize
;
2994 totalSize
+= sizeImage
;
2996 data
= Alloc(totalSize
);
2997 bmfh
= (LPBITMAPFILEHEADER
)data
;
2998 bmih
= (LPBITMAPINFOHEADER
)(data
+ sizeof(BITMAPFILEHEADER
));
2999 lpBits
= data
+ offBits
;
3001 /* setup BITMAPFILEHEADER */
3002 bmfh
->bfType
= (('M' << 8) | 'B');
3003 bmfh
->bfSize
= offBits
;
3004 bmfh
->bfReserved1
= 0;
3005 bmfh
->bfReserved2
= 0;
3006 bmfh
->bfOffBits
= offBits
;
3008 /* setup BITMAPINFOHEADER */
3009 bmih
->biSize
= sizeof(BITMAPINFOHEADER
);
3010 bmih
->biWidth
= bm
.bmWidth
;
3011 bmih
->biHeight
= bm
.bmHeight
;
3013 bmih
->biBitCount
= bitCount
;
3014 bmih
->biCompression
= BI_RGB
;
3015 bmih
->biSizeImage
= sizeImage
;
3016 bmih
->biXPelsPerMeter
= 0;
3017 bmih
->biYPelsPerMeter
= 0;
3018 bmih
->biClrUsed
= 0;
3019 bmih
->biClrImportant
= 0;
3022 result
= GetDIBits(xdc
, hBitmap
, 0, bm
.bmHeight
, lpBits
, (BITMAPINFO
*)bmih
, DIB_RGB_COLORS
) == bm
.bmHeight
;
3027 TRACE("width %u, height %u, planes %u, bpp %u\n",
3028 bmih
->biWidth
, bmih
->biHeight
,
3029 bmih
->biPlanes
, bmih
->biBitCount
);
3031 if(FAILED(IStream_Write(pstm
, data
, totalSize
, NULL
)))
3043 /*************************************************************************
3044 * ImageList_Write [COMCTL32.@]
3046 * Writes an image list to a stream.
3049 * himl [I] handle to image list
3050 * pstm [O] Pointer to a stream.
3061 ImageList_Write (HIMAGELIST himl
, LPSTREAM pstm
)
3066 TRACE("%p %p\n", himl
, pstm
);
3068 if (!is_valid(himl
))
3071 ilHead
.usMagic
= (('L' << 8) | 'I');
3072 ilHead
.usVersion
= 0x101;
3073 ilHead
.cCurImage
= himl
->cCurImage
;
3074 ilHead
.cMaxImage
= himl
->cMaxImage
;
3075 ilHead
.cGrow
= himl
->cGrow
;
3076 ilHead
.cx
= himl
->cx
;
3077 ilHead
.cy
= himl
->cy
;
3078 ilHead
.bkcolor
= himl
->clrBk
;
3079 ilHead
.flags
= himl
->flags
;
3080 for(i
= 0; i
< 4; i
++) {
3081 ilHead
.ovls
[i
] = himl
->nOvlIdx
[i
];
3084 TRACE("cx %u, cy %u, flags 0x04%x, cCurImage %u, cMaxImage %u\n",
3085 ilHead
.cx
, ilHead
.cy
, ilHead
.flags
, ilHead
.cCurImage
, ilHead
.cMaxImage
);
3087 if(FAILED(IStream_Write(pstm
, &ilHead
, sizeof(ILHEAD
), NULL
)))
3090 /* write the bitmap */
3091 if(!_write_bitmap(himl
->hbmImage
, pstm
))
3094 /* write the mask if we have one */
3095 if(himl
->flags
& ILC_MASK
) {
3096 if(!_write_bitmap(himl
->hbmMask
, pstm
))
3104 static HBITMAP
ImageList_CreateImage(HDC hdc
, HIMAGELIST himl
, UINT count
)
3106 HBITMAP hbmNewBitmap
;
3107 UINT ilc
= (himl
->flags
& 0xFE);
3110 imagelist_get_bitmap_size( himl
, count
, &sz
);
3112 if ((ilc
>= ILC_COLOR4
&& ilc
<= ILC_COLOR32
) || ilc
== ILC_COLOR
)
3114 char buffer
[sizeof(BITMAPINFOHEADER
) + 256 * sizeof(RGBQUAD
)];
3115 BITMAPINFO
*bmi
= (BITMAPINFO
*)buffer
;
3117 TRACE("Creating DIBSection %d x %d, %d Bits per Pixel\n",
3118 sz
.cx
, sz
.cy
, himl
->uBitsPixel
);
3120 memset( buffer
, 0, sizeof(buffer
) );
3121 bmi
->bmiHeader
.biSize
= sizeof(BITMAPINFOHEADER
);
3122 bmi
->bmiHeader
.biWidth
= sz
.cx
;
3123 bmi
->bmiHeader
.biHeight
= sz
.cy
;
3124 bmi
->bmiHeader
.biPlanes
= 1;
3125 bmi
->bmiHeader
.biBitCount
= himl
->uBitsPixel
;
3126 bmi
->bmiHeader
.biCompression
= BI_RGB
;
3128 if (himl
->uBitsPixel
<= ILC_COLOR8
)
3130 /* retrieve the default color map */
3131 HBITMAP tmp
= CreateBitmap( 1, 1, 1, 1, NULL
);
3132 GetDIBits( hdc
, tmp
, 0, 0, NULL
, bmi
, DIB_RGB_COLORS
);
3133 DeleteObject( tmp
);
3135 hbmNewBitmap
= CreateDIBSection(hdc
, bmi
, DIB_RGB_COLORS
, NULL
, 0, 0);
3137 else /*if (ilc == ILC_COLORDDB)*/
3139 TRACE("Creating Bitmap: %d Bits per Pixel\n", himl
->uBitsPixel
);
3141 hbmNewBitmap
= CreateBitmap (sz
.cx
, sz
.cy
, 1, himl
->uBitsPixel
, NULL
);
3143 TRACE("returning %p\n", hbmNewBitmap
);
3144 return hbmNewBitmap
;
3147 /*************************************************************************
3148 * ImageList_SetColorTable [COMCTL32.@]
3150 * Sets the color table of an image list.
3153 * himl [I] Handle to the image list.
3154 * uStartIndex [I] The first index to set.
3155 * cEntries [I] Number of entries to set.
3156 * prgb [I] New color information for color table for the image list.
3159 * Success: Number of entries in the table that were set.
3163 * ImageList_Create(), SetDIBColorTable()
3167 ImageList_SetColorTable (HIMAGELIST himl
, UINT uStartIndex
, UINT cEntries
, CONST RGBQUAD
* prgb
)
3169 return SetDIBColorTable(himl
->hdcImage
, uStartIndex
, cEntries
, prgb
);
3172 /*************************************************************************
3173 * ImageList_CoCreateInstance [COMCTL32.@]
3175 * Creates a new imagelist instance and returns an interface pointer to it.
3178 * rclsid [I] A reference to the CLSID (CLSID_ImageList).
3179 * punkOuter [I] Pointer to IUnknown interface for aggregation, if desired
3180 * riid [I] Identifier of the requested interface.
3181 * ppv [O] Returns the address of the pointer requested, or NULL.
3185 * Failure: Error value.
3188 ImageList_CoCreateInstance (REFCLSID rclsid
, const IUnknown
*punkOuter
, REFIID riid
, void **ppv
)
3190 TRACE("(%s,%p,%s,%p)\n", debugstr_guid(rclsid
), punkOuter
, debugstr_guid(riid
), ppv
);
3192 if (!IsEqualCLSID(&CLSID_ImageList
, rclsid
))
3193 return E_NOINTERFACE
;
3195 return ImageListImpl_CreateInstance(punkOuter
, riid
, ppv
);
3199 /*************************************************************************
3200 * IImageList implementation
3203 static HRESULT WINAPI
ImageListImpl_QueryInterface(IImageList
*iface
,
3204 REFIID iid
, void **ppv
)
3206 HIMAGELIST This
= (HIMAGELIST
) iface
;
3207 TRACE("(%p,%s,%p)\n", iface
, debugstr_guid(iid
), ppv
);
3209 if (!ppv
) return E_INVALIDARG
;
3211 if (IsEqualIID(&IID_IUnknown
, iid
) || IsEqualIID(&IID_IImageList
, iid
))
3216 return E_NOINTERFACE
;
3219 IUnknown_AddRef((IUnknown
*)*ppv
);
3223 static ULONG WINAPI
ImageListImpl_AddRef(IImageList
*iface
)
3225 HIMAGELIST This
= (HIMAGELIST
) iface
;
3226 ULONG ref
= InterlockedIncrement(&This
->ref
);
3228 TRACE("(%p) refcount=%u\n", iface
, ref
);
3232 static ULONG WINAPI
ImageListImpl_Release(IImageList
*iface
)
3234 HIMAGELIST This
= (HIMAGELIST
) iface
;
3235 ULONG ref
= InterlockedDecrement(&This
->ref
);
3237 TRACE("(%p) refcount=%u\n", iface
, ref
);
3241 /* delete image bitmaps */
3242 if (This
->hbmImage
) DeleteObject (This
->hbmImage
);
3243 if (This
->hbmMask
) DeleteObject (This
->hbmMask
);
3245 /* delete image & mask DCs */
3246 if (This
->hdcImage
) DeleteDC (This
->hdcImage
);
3247 if (This
->hdcMask
) DeleteDC (This
->hdcMask
);
3249 /* delete blending brushes */
3250 if (This
->hbrBlend25
) DeleteObject (This
->hbrBlend25
);
3251 if (This
->hbrBlend50
) DeleteObject (This
->hbrBlend50
);
3253 This
->lpVtbl
= NULL
;
3254 HeapFree(GetProcessHeap(), 0, This
->has_alpha
);
3255 HeapFree(GetProcessHeap(), 0, This
);
3261 static HRESULT WINAPI
ImageListImpl_Add(IImageList
*iface
, HBITMAP hbmImage
,
3262 HBITMAP hbmMask
, int *pi
)
3264 HIMAGELIST This
= (HIMAGELIST
) iface
;
3270 ret
= ImageList_Add(This
, hbmImage
, hbmMask
);
3279 static HRESULT WINAPI
ImageListImpl_ReplaceIcon(IImageList
*iface
, int i
,
3280 HICON hicon
, int *pi
)
3282 HIMAGELIST This
= (HIMAGELIST
) iface
;
3288 ret
= ImageList_ReplaceIcon(This
, i
, hicon
);
3297 static HRESULT WINAPI
ImageListImpl_SetOverlayImage(IImageList
*iface
,
3298 int iImage
, int iOverlay
)
3300 return ImageList_SetOverlayImage((HIMAGELIST
) iface
, iImage
, iOverlay
)
3304 static HRESULT WINAPI
ImageListImpl_Replace(IImageList
*iface
, int i
,
3305 HBITMAP hbmImage
, HBITMAP hbmMask
)
3307 return ImageList_Replace((HIMAGELIST
) iface
, i
, hbmImage
, hbmMask
) ? S_OK
:
3311 static HRESULT WINAPI
ImageListImpl_AddMasked(IImageList
*iface
, HBITMAP hbmImage
,
3312 COLORREF crMask
, int *pi
)
3314 HIMAGELIST This
= (HIMAGELIST
) iface
;
3320 ret
= ImageList_AddMasked(This
, hbmImage
, crMask
);
3329 static HRESULT WINAPI
ImageListImpl_Draw(IImageList
*iface
,
3330 IMAGELISTDRAWPARAMS
*pimldp
)
3332 HIMAGELIST This
= (HIMAGELIST
) iface
;
3333 HIMAGELIST old_himl
;
3336 /* As far as I can tell, Windows simply ignores the contents of pimldp->himl
3337 so we shall simulate the same */
3338 old_himl
= pimldp
->himl
;
3339 pimldp
->himl
= This
;
3341 ret
= ImageList_DrawIndirect(pimldp
);
3343 pimldp
->himl
= old_himl
;
3344 return ret
? S_OK
: E_INVALIDARG
;
3347 static HRESULT WINAPI
ImageListImpl_Remove(IImageList
*iface
, int i
)
3349 return (ImageList_Remove((HIMAGELIST
) iface
, i
) == 0) ? E_INVALIDARG
: S_OK
;
3352 static HRESULT WINAPI
ImageListImpl_GetIcon(IImageList
*iface
, int i
, UINT flags
,
3360 hIcon
= ImageList_GetIcon((HIMAGELIST
) iface
, i
, flags
);
3369 static HRESULT WINAPI
ImageListImpl_GetImageInfo(IImageList
*iface
, int i
,
3370 IMAGEINFO
*pImageInfo
)
3372 return ImageList_GetImageInfo((HIMAGELIST
) iface
, i
, pImageInfo
) ? S_OK
: E_FAIL
;
3375 static HRESULT WINAPI
ImageListImpl_Copy(IImageList
*iface
, int iDst
,
3376 IUnknown
*punkSrc
, int iSrc
, UINT uFlags
)
3378 HIMAGELIST This
= (HIMAGELIST
) iface
;
3379 IImageList
*src
= NULL
;
3385 /* TODO: Add test for IID_ImageList2 too */
3386 if (FAILED(IUnknown_QueryInterface(punkSrc
, &IID_IImageList
,
3390 if (ImageList_Copy(This
, iDst
, (HIMAGELIST
) src
, iSrc
, uFlags
))
3395 IImageList_Release(src
);
3399 static HRESULT WINAPI
ImageListImpl_Merge(IImageList
*iface
, int i1
,
3400 IUnknown
*punk2
, int i2
, int dx
, int dy
, REFIID riid
, void **ppv
)
3402 HIMAGELIST This
= (HIMAGELIST
) iface
;
3403 IImageList
*iml2
= NULL
;
3405 HRESULT ret
= E_FAIL
;
3407 TRACE("(%p)->(%d %p %d %d %d %s %p)\n", iface
, i1
, punk2
, i2
, dx
, dy
, debugstr_guid(riid
), ppv
);
3409 /* TODO: Add test for IID_ImageList2 too */
3410 if (FAILED(IUnknown_QueryInterface(punk2
, &IID_IImageList
,
3414 hNew
= ImageList_Merge(This
, i1
, (HIMAGELIST
) iml2
, i2
, dx
, dy
);
3416 /* Get the interface for the new image list */
3419 IImageList
*imerge
= (IImageList
*)hNew
;
3421 ret
= HIMAGELIST_QueryInterface(hNew
, riid
, ppv
);
3422 IImageList_Release(imerge
);
3425 IImageList_Release(iml2
);
3429 static HRESULT WINAPI
ImageListImpl_Clone(IImageList
*iface
, REFIID riid
, void **ppv
)
3431 HIMAGELIST This
= (HIMAGELIST
) iface
;
3433 HRESULT ret
= E_FAIL
;
3435 TRACE("(%p)->(%s %p)\n", iface
, debugstr_guid(riid
), ppv
);
3437 clone
= ImageList_Duplicate(This
);
3439 /* Get the interface for the new image list */
3442 IImageList
*iclone
= (IImageList
*)clone
;
3444 ret
= HIMAGELIST_QueryInterface(clone
, riid
, ppv
);
3445 IImageList_Release(iclone
);
3451 static HRESULT WINAPI
ImageListImpl_GetImageRect(IImageList
*iface
, int i
,
3454 HIMAGELIST This
= (HIMAGELIST
) iface
;
3460 if (!ImageList_GetImageInfo(This
, i
, &info
))
3463 return CopyRect(prc
, &info
.rcImage
) ? S_OK
: E_FAIL
;
3466 static HRESULT WINAPI
ImageListImpl_GetIconSize(IImageList
*iface
, int *cx
,
3469 HIMAGELIST This
= (HIMAGELIST
) iface
;
3471 return ImageList_GetIconSize(This
, cx
, cy
) ? S_OK
: E_INVALIDARG
;
3474 static HRESULT WINAPI
ImageListImpl_SetIconSize(IImageList
*iface
, int cx
,
3477 return ImageList_SetIconSize((HIMAGELIST
) iface
, cx
, cy
) ? S_OK
: E_FAIL
;
3480 static HRESULT WINAPI
ImageListImpl_GetImageCount(IImageList
*iface
, int *pi
)
3482 *pi
= ImageList_GetImageCount((HIMAGELIST
) iface
);
3486 static HRESULT WINAPI
ImageListImpl_SetImageCount(IImageList
*iface
,
3489 return ImageList_SetImageCount((HIMAGELIST
) iface
, uNewCount
) ? S_OK
: E_FAIL
;
3492 static HRESULT WINAPI
ImageListImpl_SetBkColor(IImageList
*iface
, COLORREF clrBk
,
3495 *pclr
= ImageList_SetBkColor((HIMAGELIST
) iface
, clrBk
);
3499 static HRESULT WINAPI
ImageListImpl_GetBkColor(IImageList
*iface
, COLORREF
*pclr
)
3501 *pclr
= ImageList_GetBkColor((HIMAGELIST
) iface
);
3505 static HRESULT WINAPI
ImageListImpl_BeginDrag(IImageList
*iface
, int iTrack
,
3506 int dxHotspot
, int dyHotspot
)
3508 return ImageList_BeginDrag((HIMAGELIST
) iface
, iTrack
, dxHotspot
, dyHotspot
) ? S_OK
: E_FAIL
;
3511 static HRESULT WINAPI
ImageListImpl_EndDrag(IImageList
*iface
)
3513 ImageList_EndDrag();
3517 static HRESULT WINAPI
ImageListImpl_DragEnter(IImageList
*iface
, HWND hwndLock
,
3520 return ImageList_DragEnter(hwndLock
, x
, y
) ? S_OK
: E_FAIL
;
3523 static HRESULT WINAPI
ImageListImpl_DragLeave(IImageList
*iface
, HWND hwndLock
)
3525 return ImageList_DragLeave(hwndLock
) ? S_OK
: E_FAIL
;
3528 static HRESULT WINAPI
ImageListImpl_DragMove(IImageList
*iface
, int x
, int y
)
3530 return ImageList_DragMove(x
, y
) ? S_OK
: E_FAIL
;
3533 static HRESULT WINAPI
ImageListImpl_SetDragCursorImage(IImageList
*iface
,
3534 IUnknown
*punk
, int iDrag
, int dxHotspot
, int dyHotspot
)
3536 IImageList
*iml2
= NULL
;
3542 /* TODO: Add test for IID_ImageList2 too */
3543 if (FAILED(IUnknown_QueryInterface(punk
, &IID_IImageList
,
3547 ret
= ImageList_SetDragCursorImage((HIMAGELIST
) iml2
, iDrag
, dxHotspot
,
3550 IImageList_Release(iml2
);
3552 return ret
? S_OK
: E_FAIL
;
3555 static HRESULT WINAPI
ImageListImpl_DragShowNolock(IImageList
*iface
, BOOL fShow
)
3557 return ImageList_DragShowNolock(fShow
) ? S_OK
: E_FAIL
;
3560 static HRESULT WINAPI
ImageListImpl_GetDragImage(IImageList
*iface
, POINT
*ppt
,
3561 POINT
*pptHotspot
, REFIID riid
, PVOID
*ppv
)
3563 HRESULT ret
= E_FAIL
;
3569 hNew
= ImageList_GetDragImage(ppt
, pptHotspot
);
3571 /* Get the interface for the new image list */
3574 IImageList
*idrag
= (IImageList
*)hNew
;
3576 ret
= HIMAGELIST_QueryInterface(hNew
, riid
, ppv
);
3577 IImageList_Release(idrag
);
3583 static HRESULT WINAPI
ImageListImpl_GetItemFlags(IImageList
*iface
, int i
,
3586 FIXME("STUB: %p %d %p\n", iface
, i
, dwFlags
);
3590 static HRESULT WINAPI
ImageListImpl_GetOverlayImage(IImageList
*iface
, int iOverlay
,
3593 HIMAGELIST This
= (HIMAGELIST
) iface
;
3596 if ((iOverlay
< 0) || (iOverlay
> This
->cCurImage
))
3599 for (i
= 0; i
< MAX_OVERLAYIMAGE
; i
++)
3601 if (This
->nOvlIdx
[i
] == iOverlay
)
3612 static const IImageListVtbl ImageListImpl_Vtbl
= {
3613 ImageListImpl_QueryInterface
,
3614 ImageListImpl_AddRef
,
3615 ImageListImpl_Release
,
3617 ImageListImpl_ReplaceIcon
,
3618 ImageListImpl_SetOverlayImage
,
3619 ImageListImpl_Replace
,
3620 ImageListImpl_AddMasked
,
3622 ImageListImpl_Remove
,
3623 ImageListImpl_GetIcon
,
3624 ImageListImpl_GetImageInfo
,
3626 ImageListImpl_Merge
,
3627 ImageListImpl_Clone
,
3628 ImageListImpl_GetImageRect
,
3629 ImageListImpl_GetIconSize
,
3630 ImageListImpl_SetIconSize
,
3631 ImageListImpl_GetImageCount
,
3632 ImageListImpl_SetImageCount
,
3633 ImageListImpl_SetBkColor
,
3634 ImageListImpl_GetBkColor
,
3635 ImageListImpl_BeginDrag
,
3636 ImageListImpl_EndDrag
,
3637 ImageListImpl_DragEnter
,
3638 ImageListImpl_DragLeave
,
3639 ImageListImpl_DragMove
,
3640 ImageListImpl_SetDragCursorImage
,
3641 ImageListImpl_DragShowNolock
,
3642 ImageListImpl_GetDragImage
,
3643 ImageListImpl_GetItemFlags
,
3644 ImageListImpl_GetOverlayImage
3647 static BOOL
is_valid(HIMAGELIST himl
)
3652 valid
= himl
&& himl
->lpVtbl
== &ImageListImpl_Vtbl
;
3662 /*************************************************************************
3663 * HIMAGELIST_QueryInterface [COMCTL32.@]
3665 * Returns a pointer to an IImageList or IImageList2 object for the given
3669 * himl [I] Image list handle.
3670 * riid [I] Identifier of the requested interface.
3671 * ppv [O] Returns the address of the pointer requested, or NULL.
3675 * Failure: Error value.
3678 HIMAGELIST_QueryInterface (HIMAGELIST himl
, REFIID riid
, void **ppv
)
3680 TRACE("(%p,%s,%p)\n", himl
, debugstr_guid(riid
), ppv
);
3681 return IImageList_QueryInterface((IImageList
*) himl
, riid
, ppv
);
3684 static HRESULT
ImageListImpl_CreateInstance(const IUnknown
*pUnkOuter
, REFIID iid
, void** ppv
)
3689 TRACE("(%p,%s,%p)\n", pUnkOuter
, debugstr_guid(iid
), ppv
);
3693 if (pUnkOuter
) return CLASS_E_NOAGGREGATION
;
3695 This
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct _IMAGELIST
));
3696 if (!This
) return E_OUTOFMEMORY
;
3698 This
->lpVtbl
= &ImageListImpl_Vtbl
;
3701 ret
= IUnknown_QueryInterface((IUnknown
*)This
, iid
, ppv
);
3702 IUnknown_Release((IUnknown
*)This
);