Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1 | /* |
| 2 | * ImageList implementation |
| 3 | * |
| 4 | * Copyright 1998 Eric Kohl |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 5 | * Copyright 2000 Jason Mawdsley |
| 6 | * Copyright 2001 Michael Stefaniuc |
| 7 | * Copyright 2001 Charles Loep for CodeWeavers |
| 8 | * Copyright 2002 Dimitrie O. Paun |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 9 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 10 | * This library is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU Lesser General Public |
| 12 | * License as published by the Free Software Foundation; either |
| 13 | * version 2.1 of the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This library is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 | * Lesser General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU Lesser General Public |
| 21 | * License along with this library; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 23 | * |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 24 | * NOTE |
| 25 | * |
| 26 | * This code was audited for completeness against the documented features |
| 27 | * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun. |
| 28 | * |
| 29 | * Unless otherwise noted, we belive this code to be complete, as per |
| 30 | * the specification mentioned above. |
| 31 | * If you discover missing features, or bugs, please note them below. |
| 32 | * |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 33 | * TODO: |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 34 | * - Add support for ILD_PRESERVEALPHA, ILD_SCALE, ILD_DPISCALE |
| 35 | * - Add support for ILS_GLOW, ILS_SHADOW, ILS_SATURATE, ILS_ALPHA |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 36 | * |
Dimitrie O. Paun | da9bac4 | 2002-10-16 18:57:14 +0000 | [diff] [blame] | 37 | * FIXME: |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 38 | * - Hotspot handling still not correct. The Hotspot passed to BeginDrag |
| 39 | * is the offset of the image position relative to the actual mouse pointer |
| 40 | * position. However the Hotspot passed to SetDragCursorImage is the |
| 41 | * offset of the mouse messages sent to the application... |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 42 | */ |
| 43 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 44 | #include <stdlib.h> |
James Juran | f4d5fef | 2001-01-26 20:43:40 +0000 | [diff] [blame] | 45 | #include <string.h> |
Alexandre Julliard | 74af67e | 2000-09-26 00:00:55 +0000 | [diff] [blame] | 46 | #include "winerror.h" |
| 47 | #include "winbase.h" |
Alexandre Julliard | 638f169 | 1999-01-17 16:32:32 +0000 | [diff] [blame] | 48 | #include "wine/obj_base.h" |
| 49 | #include "wine/obj_storage.h" |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 50 | #include "commctrl.h" |
Alexandre Julliard | 70c9e09 | 2000-08-09 00:41:17 +0000 | [diff] [blame] | 51 | #include "imagelist.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 52 | #include "wine/debug.h" |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 53 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 54 | WINE_DEFAULT_DEBUG_CHANNEL(imagelist); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 55 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 56 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 57 | #define MAX_OVERLAYIMAGE 15 |
| 58 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 59 | /* internal image list data used for Drag & Drop operations */ |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 60 | typedef struct |
| 61 | { |
| 62 | HWND hwnd; |
| 63 | HIMAGELIST himl; |
| 64 | /* position of the drag image relative to the window */ |
| 65 | INT x; |
| 66 | INT y; |
| 67 | /* offset of the hotspot relative to the origin of the image */ |
| 68 | INT dxHotspot; |
| 69 | INT dyHotspot; |
| 70 | /* is the drag image visible */ |
| 71 | BOOL bShow; |
| 72 | /* saved background */ |
| 73 | HBITMAP hbmBg; |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 74 | BOOL bHSPending; |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 75 | } INTERNALDRAG; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 76 | |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 77 | static INTERNALDRAG InternalDrag = { 0, 0, 0, 0, 0, 0, FALSE, 0, FALSE }; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 78 | |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 79 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 80 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 81 | /************************************************************************* |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 82 | * IMAGELIST_InternalExpandBitmaps [Internal] |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 83 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 84 | * Expands the bitmaps of an image list by the given number of images. |
| 85 | * |
| 86 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 87 | * himl [I] handle to image list |
| 88 | * nImageCount [I] number of images to add |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 89 | * |
| 90 | * RETURNS |
| 91 | * nothing |
| 92 | * |
| 93 | * NOTES |
| 94 | * This function can NOT be used to reduce the number of images. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 95 | */ |
Dimitrie O. Paun | d969605 | 2002-09-06 18:32:46 +0000 | [diff] [blame] | 96 | static void |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 97 | IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 98 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 99 | HDC hdcImageList, hdcBitmap; |
| 100 | HBITMAP hbmNewBitmap; |
| 101 | INT nNewWidth, nNewCount; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 102 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 103 | if ((himl->cCurImage + nImageCount <= himl->cMaxImage) |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 104 | && (himl->cy >= cy)) |
| 105 | return; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 106 | |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 107 | if (cy == 0) cy = himl->cy; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 108 | nNewCount = himl->cCurImage + nImageCount + himl->cGrow; |
| 109 | nNewWidth = nNewCount * himl->cx; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 110 | |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 111 | TRACE("Create expanded bitmaps : himl=%p x=%d y=%d count=%d\n", himl, nNewWidth, cy, nNewCount); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 112 | hdcImageList = CreateCompatibleDC (0); |
| 113 | hdcBitmap = CreateCompatibleDC (0); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 114 | |
| 115 | hbmNewBitmap = |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 116 | CreateBitmap (nNewWidth, cy, 1, himl->uBitsPixel, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 117 | if (hbmNewBitmap == 0) |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 118 | ERR("creating new image bitmap (x=%d y=%d)!\n", nNewWidth, cy); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 119 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 120 | SelectObject (hdcImageList, himl->hbmImage); |
| 121 | SelectObject (hdcBitmap, hbmNewBitmap); |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 122 | BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 123 | hdcImageList, 0, 0, SRCCOPY); |
| 124 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 125 | DeleteObject (himl->hbmImage); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 126 | himl->hbmImage = hbmNewBitmap; |
| 127 | |
| 128 | if (himl->hbmMask) { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 129 | hbmNewBitmap = |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 130 | CreateBitmap (nNewWidth, cy, 1, 1, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 131 | |
| 132 | if (hbmNewBitmap == 0) |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 133 | ERR("creating new mask bitmap!\n"); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 134 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 135 | SelectObject (hdcImageList, himl->hbmMask); |
| 136 | SelectObject (hdcBitmap, hbmNewBitmap); |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 137 | BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 138 | hdcImageList, 0, 0, SRCCOPY); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 139 | DeleteObject (himl->hbmMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 140 | himl->hbmMask = hbmNewBitmap; |
| 141 | } |
| 142 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 143 | himl->cMaxImage = nNewCount; |
| 144 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 145 | DeleteDC (hdcImageList); |
| 146 | DeleteDC (hdcBitmap); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 147 | } |
| 148 | |
| 149 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 150 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 151 | * ImageList_Add [COMCTL32.@] |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 152 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 153 | * Add an image or images to an image list. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 154 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 155 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 156 | * himl [I] handle to image list |
| 157 | * hbmImage [I] handle to image bitmap |
| 158 | * hbmMask [I] handle to mask bitmap |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 159 | * |
| 160 | * RETURNS |
| 161 | * Success: Index of the first new image. |
| 162 | * Failure: -1 |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 163 | */ |
| 164 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 165 | INT WINAPI |
| 166 | ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 167 | { |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 168 | HDC hdcImage, hdcBitmap; |
| 169 | INT nFirstIndex, nImageCount; |
| 170 | INT nStartX; |
| 171 | BITMAP bmp; |
| 172 | HBITMAP hOldBitmapImage, hOldBitmap; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 173 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 174 | TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl, hbmImage, hbmMask); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 175 | if (!himl || !hbmImage) |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 176 | return -1; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 177 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 178 | GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 179 | nImageCount = bmp.bmWidth / himl->cx; |
| 180 | |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 181 | IMAGELIST_InternalExpandBitmaps (himl, nImageCount, bmp.bmWidth, bmp.bmHeight); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 182 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 183 | nStartX = himl->cCurImage * himl->cx; |
| 184 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 185 | hdcImage = CreateCompatibleDC(0); |
| 186 | hdcBitmap = CreateCompatibleDC(0); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 187 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 188 | hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage); |
| 189 | hOldBitmap = SelectObject(hdcBitmap, hbmImage); |
| 190 | |
| 191 | /* Copy result to the imagelist |
| 192 | */ |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 193 | BitBlt (hdcImage, nStartX, 0, bmp.bmWidth, bmp.bmHeight, |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 194 | hdcBitmap, 0, 0, SRCCOPY); |
| 195 | |
| 196 | if(himl->hbmMask) |
| 197 | { |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 198 | HDC hdcMask, hdcTemp; |
| 199 | HBITMAP hOldBitmapMask, hOldBitmapTemp; |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 200 | |
| 201 | hdcMask = CreateCompatibleDC (0); |
| 202 | hdcTemp = CreateCompatibleDC(0); |
Michael Stefaniuc | f3d1893 | 2002-10-23 20:19:22 +0000 | [diff] [blame] | 203 | hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask); |
| 204 | hOldBitmapTemp = SelectObject(hdcTemp, hbmMask); |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 205 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 206 | BitBlt (hdcMask, |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 207 | nStartX, 0, bmp.bmWidth, bmp.bmHeight, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 208 | hdcTemp, |
| 209 | 0, 0, |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 210 | SRCCOPY); |
| 211 | |
| 212 | SelectObject(hdcTemp, hOldBitmapTemp); |
| 213 | DeleteDC(hdcTemp); |
| 214 | |
| 215 | /* Remove the background from the image |
| 216 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 217 | BitBlt (hdcImage, |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 218 | nStartX, 0, bmp.bmWidth, bmp.bmHeight, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 219 | hdcMask, |
| 220 | nStartX, 0, |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 221 | 0x220326); /* NOTSRCAND */ |
| 222 | |
| 223 | SelectObject(hdcMask, hOldBitmapMask); |
| 224 | DeleteDC(hdcMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 227 | SelectObject(hdcImage, hOldBitmapImage); |
| 228 | SelectObject(hdcBitmap, hOldBitmap); |
| 229 | DeleteDC(hdcImage); |
| 230 | DeleteDC(hdcBitmap); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 231 | |
| 232 | nFirstIndex = himl->cCurImage; |
| 233 | himl->cCurImage += nImageCount; |
| 234 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 235 | return nFirstIndex; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 239 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 240 | * ImageList_AddIcon [COMCTL32.@] |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 241 | * |
| 242 | * Adds an icon to an image list. |
| 243 | * |
| 244 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 245 | * himl [I] handle to image list |
| 246 | * hIcon [I] handle to icon |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 247 | * |
| 248 | * RETURNS |
| 249 | * Success: index of the new image |
| 250 | * Failure: -1 |
| 251 | */ |
| 252 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 253 | INT WINAPI |
| 254 | ImageList_AddIcon (HIMAGELIST himl, HICON hIcon) |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 255 | { |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 256 | return ImageList_ReplaceIcon (himl, -1, hIcon); |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 257 | } |
| 258 | |
| 259 | |
| 260 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 261 | * ImageList_AddMasked [COMCTL32.@] |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 262 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 263 | * Adds an image or images to an image list and creates a mask from the |
| 264 | * specified bitmap using the mask color. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 265 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 266 | * PARAMS |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 267 | * himl [I] handle to image list. |
| 268 | * hBitmap [I] handle to bitmap |
| 269 | * clrMask [I] mask color. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 270 | * |
| 271 | * RETURNS |
| 272 | * Success: Index of the first new image. |
| 273 | * Failure: -1 |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 274 | */ |
| 275 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 276 | INT WINAPI |
| 277 | ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 278 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 279 | HDC hdcImage, hdcMask, hdcBitmap; |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 280 | INT nIndex, nImageCount, nMaskXOffset=0; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 281 | BITMAP bmp; |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 282 | HBITMAP hOldBitmap, hOldBitmapMask, hOldBitmapImage; |
| 283 | HBITMAP hMaskBitmap=0; |
| 284 | COLORREF bkColor; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 285 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 286 | TRACE("himl=%p hbitmap=%p clrmask=%lx\n", himl, hBitmap, clrMask); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 287 | if (himl == NULL) |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 288 | return -1; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 289 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 290 | if (!GetObjectA (hBitmap, sizeof(BITMAP), &bmp)) |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 291 | return -1; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 292 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 293 | nImageCount = bmp.bmWidth / himl->cx; |
| 294 | |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 295 | IMAGELIST_InternalExpandBitmaps (himl, nImageCount, bmp.bmWidth, bmp.bmHeight); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 296 | |
| 297 | nIndex = himl->cCurImage; |
| 298 | himl->cCurImage += nImageCount; |
| 299 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 300 | hdcMask = CreateCompatibleDC (0); |
| 301 | hdcImage = CreateCompatibleDC(0); |
| 302 | hdcBitmap = CreateCompatibleDC(0); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 303 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 304 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 305 | hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage); |
| 306 | hOldBitmap = SelectObject(hdcBitmap, hBitmap); |
| 307 | if(himl->hbmMask) |
| 308 | { |
| 309 | hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask); |
| 310 | nMaskXOffset = nIndex * himl->cx; |
| 311 | } |
| 312 | else |
| 313 | { |
| 314 | /* |
| 315 | Create a temp Mask so we can remove the background of |
| 316 | the Image (Windows does this even if there is no mask) |
| 317 | */ |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 318 | hMaskBitmap = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL); |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 319 | hOldBitmapMask = SelectObject(hdcMask, hMaskBitmap); |
| 320 | nMaskXOffset = 0; |
| 321 | } |
| 322 | /* create monochrome image to the mask bitmap */ |
| 323 | bkColor = (clrMask != CLR_DEFAULT) ? clrMask : |
| 324 | GetPixel (hdcBitmap, 0, 0); |
| 325 | SetBkColor (hdcBitmap, bkColor); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 326 | BitBlt (hdcMask, |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 327 | nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 328 | hdcBitmap, 0, 0, |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 329 | SRCCOPY); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 330 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 331 | SetBkColor(hdcBitmap, RGB(255,255,255)); |
| 332 | /*Remove the background from the image |
| 333 | */ |
| 334 | /* |
| 335 | WINDOWS BUG ALERT!!!!!! |
| 336 | The statement below should not be done in common practice |
| 337 | but this is how ImageList_AddMasked works in Windows. |
| 338 | It overwrites the original bitmap passed, this was discovered |
Andreas Mohr | 641405a | 2001-04-20 18:29:17 +0000 | [diff] [blame] | 339 | by using the same bitmap to iterate the different styles |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 340 | on windows where it failed (BUT ImageList_Add is OK) |
Andreas Mohr | 641405a | 2001-04-20 18:29:17 +0000 | [diff] [blame] | 341 | This is here in case some apps rely on this bug |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 342 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 343 | BitBlt(hdcBitmap, |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 344 | 0, 0, bmp.bmWidth, bmp.bmHeight, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 345 | hdcMask, |
| 346 | nMaskXOffset, 0, |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 347 | 0x220326); /* NOTSRCAND */ |
| 348 | /* Copy result to the imagelist |
| 349 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 350 | BitBlt (hdcImage, |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 351 | nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 352 | hdcBitmap, |
| 353 | 0, 0, |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 354 | SRCCOPY); |
| 355 | /* Clean up |
| 356 | */ |
| 357 | SelectObject(hdcMask,hOldBitmapMask); |
| 358 | SelectObject(hdcImage, hOldBitmapImage); |
| 359 | SelectObject(hdcBitmap, hOldBitmap); |
| 360 | DeleteDC(hdcMask); |
| 361 | DeleteDC(hdcImage); |
| 362 | DeleteDC(hdcBitmap); |
| 363 | if(!himl->hbmMask) |
| 364 | { |
| 365 | DeleteObject(hMaskBitmap); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 366 | } |
| 367 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 368 | return nIndex; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 372 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 373 | * ImageList_BeginDrag [COMCTL32.@] |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 374 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 375 | * Creates a temporary image list that contains one image. It will be used |
| 376 | * as a drag image. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 377 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 378 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 379 | * himlTrack [I] handle to the source image list |
| 380 | * iTrack [I] index of the drag image in the source image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 381 | * dxHotspot [I] X position of the hot spot of the drag image |
| 382 | * dyHotspot [I] Y position of the hot spot of the drag image |
| 383 | * |
| 384 | * RETURNS |
| 385 | * Success: TRUE |
| 386 | * Failure: FALSE |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 387 | */ |
| 388 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 389 | BOOL WINAPI |
| 390 | ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack, |
| 391 | INT dxHotspot, INT dyHotspot) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 392 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 393 | HDC hdcSrc, hdcDst; |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 394 | INT cx, cy; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 395 | |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 396 | TRACE("(himlTrack=%p iTrack=%d dx=%d dy=%d)\n", himlTrack, iTrack, |
| 397 | dxHotspot, dyHotspot); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 398 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 399 | if (himlTrack == NULL) |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 400 | return FALSE; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 401 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 402 | if (InternalDrag.himl) |
| 403 | ImageList_EndDrag (); |
| 404 | |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 405 | cx = himlTrack->cx; |
| 406 | cy = himlTrack->cy; |
| 407 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 408 | InternalDrag.himl = ImageList_Create (cx, cy, himlTrack->flags, 1, 1); |
| 409 | if (InternalDrag.himl == NULL) { |
Dimitrie O. Paun | 7ad3d12 | 2002-09-04 18:44:46 +0000 | [diff] [blame] | 410 | WARN("Error creating drag image list!\n"); |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 411 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 412 | } |
| 413 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 414 | InternalDrag.dxHotspot = dxHotspot; |
| 415 | InternalDrag.dyHotspot = dyHotspot; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 416 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 417 | hdcSrc = CreateCompatibleDC (0); |
| 418 | hdcDst = CreateCompatibleDC (0); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 419 | |
| 420 | /* copy image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 421 | SelectObject (hdcSrc, himlTrack->hbmImage); |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 422 | SelectObject (hdcDst, InternalDrag.himl->hbmImage); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 423 | BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 424 | |
| 425 | /* copy mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 426 | SelectObject (hdcSrc, himlTrack->hbmMask); |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 427 | SelectObject (hdcDst, InternalDrag.himl->hbmMask); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 428 | BitBlt (hdcDst, 0, 0, cx, cy, hdcSrc, iTrack * cx, 0, SRCCOPY); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 429 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 430 | DeleteDC (hdcSrc); |
| 431 | DeleteDC (hdcDst); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 432 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 433 | InternalDrag.himl->cCurImage = 1; |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 434 | InternalDrag.bHSPending = TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 435 | |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 436 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 437 | } |
| 438 | |
| 439 | |
| 440 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 441 | * ImageList_Copy [COMCTL32.@] |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 442 | * |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 443 | * Copies an image of the source image list to an image of the |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 444 | * destination image list. Images can be copied or swapped. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 445 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 446 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 447 | * himlDst [I] handle to the destination image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 448 | * iDst [I] destination image index. |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 449 | * himlSrc [I] handle to the source image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 450 | * iSrc [I] source image index |
| 451 | * uFlags [I] flags for the copy operation |
| 452 | * |
| 453 | * RETURNS |
| 454 | * Success: TRUE |
| 455 | * Failure: FALSE |
| 456 | * |
| 457 | * NOTES |
| 458 | * Copying from one image list to another is possible. The original |
Andreas Mohr | 641405a | 2001-04-20 18:29:17 +0000 | [diff] [blame] | 459 | * implementation just copies or swaps within one image list. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 460 | * Could this feature become a bug??? ;-) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 461 | */ |
| 462 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 463 | BOOL WINAPI |
| 464 | ImageList_Copy (HIMAGELIST himlDst, INT iDst, HIMAGELIST himlSrc, |
| 465 | INT iSrc, INT uFlags) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 466 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 467 | HDC hdcSrc, hdcDst; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 468 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 469 | TRACE("iDst=%d iSrc=%d\n", iDst, iSrc); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 470 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 471 | if ((himlSrc == NULL) || (himlDst == NULL)) |
| 472 | return FALSE; |
| 473 | if ((iDst < 0) || (iDst >= himlDst->cCurImage)) |
| 474 | return FALSE; |
| 475 | if ((iSrc < 0) || (iSrc >= himlSrc->cCurImage)) |
| 476 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 477 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 478 | hdcSrc = CreateCompatibleDC (0); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 479 | if (himlDst == himlSrc) |
| 480 | hdcDst = hdcSrc; |
| 481 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 482 | hdcDst = CreateCompatibleDC (0); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 483 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 484 | if (uFlags & ILCF_SWAP) { |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 485 | /* swap */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 486 | HBITMAP hbmTempImage, hbmTempMask; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 487 | |
| 488 | /* create temporary bitmaps */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 489 | hbmTempImage = CreateBitmap (himlSrc->cx, himlSrc->cy, 1, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 490 | himlSrc->uBitsPixel, NULL); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 491 | hbmTempMask = CreateBitmap (himlSrc->cx, himlSrc->cy, 1, |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 492 | 1, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 493 | |
| 494 | /* copy (and stretch) destination to temporary bitmaps.(save) */ |
| 495 | /* image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 496 | SelectObject (hdcSrc, himlDst->hbmImage); |
| 497 | SelectObject (hdcDst, hbmTempImage); |
| 498 | StretchBlt (hdcDst, 0, 0, himlSrc->cx, himlSrc->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 499 | hdcSrc, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, |
| 500 | SRCCOPY); |
| 501 | /* mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 502 | SelectObject (hdcSrc, himlDst->hbmMask); |
| 503 | SelectObject (hdcDst, hbmTempMask); |
| 504 | StretchBlt (hdcDst, 0, 0, himlSrc->cx, himlSrc->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 505 | hdcSrc, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, |
| 506 | SRCCOPY); |
| 507 | |
| 508 | /* copy (and stretch) source to destination */ |
| 509 | /* image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 510 | SelectObject (hdcSrc, himlSrc->hbmImage); |
| 511 | SelectObject (hdcDst, himlDst->hbmImage); |
| 512 | StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 513 | hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, |
| 514 | SRCCOPY); |
| 515 | /* mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 516 | SelectObject (hdcSrc, himlSrc->hbmMask); |
| 517 | SelectObject (hdcDst, himlDst->hbmMask); |
| 518 | StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 519 | hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, |
| 520 | SRCCOPY); |
| 521 | |
| 522 | /* copy (without stretching) temporary bitmaps to source (restore) */ |
| 523 | /* image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 524 | SelectObject (hdcSrc, hbmTempImage); |
| 525 | SelectObject (hdcDst, himlSrc->hbmImage); |
| 526 | BitBlt (hdcDst, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 527 | hdcSrc, 0, 0, SRCCOPY); |
| 528 | /* mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 529 | SelectObject (hdcSrc, hbmTempMask); |
| 530 | SelectObject (hdcDst, himlSrc->hbmMask); |
| 531 | BitBlt (hdcDst, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 532 | hdcSrc, 0, 0, SRCCOPY); |
| 533 | |
| 534 | /* delete temporary bitmaps */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 535 | DeleteObject (hbmTempMask); |
| 536 | DeleteObject (hbmTempImage); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 537 | } |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 538 | else { |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 539 | /* copy image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 540 | SelectObject (hdcSrc, himlSrc->hbmImage); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 541 | if (himlSrc == himlDst) |
| 542 | hdcDst = hdcSrc; |
| 543 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 544 | SelectObject (hdcDst, himlDst->hbmImage); |
| 545 | StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 546 | hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, |
| 547 | SRCCOPY); |
| 548 | |
| 549 | /* copy mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 550 | SelectObject (hdcSrc, himlSrc->hbmMask); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 551 | if (himlSrc == himlDst) |
| 552 | hdcDst = hdcSrc; |
| 553 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 554 | SelectObject (hdcDst, himlDst->hbmMask); |
| 555 | StretchBlt (hdcDst, iDst * himlDst->cx, 0, himlDst->cx, himlDst->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 556 | hdcSrc, iSrc * himlSrc->cx, 0, himlSrc->cx, himlSrc->cy, |
| 557 | SRCCOPY); |
| 558 | } |
| 559 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 560 | DeleteDC (hdcSrc); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 561 | if (himlSrc != himlDst) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 562 | DeleteDC (hdcDst); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 563 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 564 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 565 | } |
| 566 | |
| 567 | |
| 568 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 569 | * ImageList_Create [COMCTL32.@] Creates a new image list. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 570 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 571 | * PARAMS |
| 572 | * cx [I] image height |
| 573 | * cy [I] image width |
| 574 | * flags [I] creation flags |
| 575 | * cInitial [I] initial number of images in the image list |
| 576 | * cGrow [I] number of images by which image list grows |
| 577 | * |
| 578 | * RETURNS |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 579 | * Success: Handle to the created image list |
| 580 | * Failure: NULL |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 581 | */ |
| 582 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 583 | HIMAGELIST WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 584 | ImageList_Create (INT cx, INT cy, UINT flags, |
| 585 | INT cInitial, INT cGrow) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 586 | { |
| 587 | HIMAGELIST himl; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 588 | HDC hdc; |
| 589 | INT nCount; |
| 590 | HBITMAP hbmTemp; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 591 | static WORD aBitBlend25[] = |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 592 | {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00}; |
| 593 | |
| 594 | static WORD aBitBlend50[] = |
| 595 | {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 596 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 597 | TRACE("(%d %d 0x%x %d %d)\n", cx, cy, flags, cInitial, cGrow); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 598 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 599 | himl = (HIMAGELIST)COMCTL32_Alloc (sizeof(struct _IMAGELIST)); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 600 | if (!himl) |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 601 | return NULL; |
| 602 | |
| 603 | himl->cx = cx; |
| 604 | himl->cy = cy; |
| 605 | himl->flags = flags; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 606 | himl->cMaxImage = cInitial + cGrow; |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 607 | himl->cInitial = cInitial; |
| 608 | himl->cGrow = cGrow; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 609 | himl->cCurImage = 0; |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 610 | himl->clrFg = CLR_DEFAULT; |
| 611 | himl->clrBk = CLR_NONE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 612 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 613 | /* initialize overlay mask indices */ |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 614 | for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 615 | himl->nOvlIdx[nCount] = -1; |
| 616 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 617 | hdc = CreateCompatibleDC (0); |
| 618 | himl->uBitsPixel = (UINT)GetDeviceCaps (hdc, BITSPIXEL); |
| 619 | DeleteDC (hdc); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 620 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 621 | TRACE("Image: %d Bits per Pixel\n", himl->uBitsPixel); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 622 | |
Stephane Lussier | 2511477 | 1999-09-22 15:15:57 +0000 | [diff] [blame] | 623 | if (himl->cMaxImage > 0) { |
| 624 | himl->hbmImage = |
| 625 | CreateBitmap (himl->cx * himl->cMaxImage, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 626 | 1, himl->uBitsPixel, NULL); |
Stephane Lussier | 2511477 | 1999-09-22 15:15:57 +0000 | [diff] [blame] | 627 | if (himl->hbmImage == 0) { |
| 628 | ERR("Error creating image bitmap!\n"); |
| 629 | return NULL; |
| 630 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 631 | } |
Stephane Lussier | 2511477 | 1999-09-22 15:15:57 +0000 | [diff] [blame] | 632 | else |
| 633 | himl->hbmImage = 0; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 634 | |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 635 | if ( (himl->flags & ILC_MASK)) { |
| 636 | int images = himl->cMaxImage; |
| 637 | if (images <= 0) |
| 638 | images = 1; |
| 639 | |
| 640 | himl->hbmMask = CreateBitmap (himl->cx * images, himl->cy, |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 641 | 1, 1, NULL); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 642 | if (himl->hbmMask == 0) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 643 | ERR("Error creating mask bitmap!\n"); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 644 | if (himl->hbmImage) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 645 | DeleteObject (himl->hbmImage); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 646 | return NULL; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 647 | } |
| 648 | } |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 649 | else |
| 650 | himl->hbmMask = 0; |
| 651 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 652 | /* create blending brushes */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 653 | hbmTemp = CreateBitmap (8, 8, 1, 1, &aBitBlend25); |
| 654 | himl->hbrBlend25 = CreatePatternBrush (hbmTemp); |
| 655 | DeleteObject (hbmTemp); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 656 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 657 | hbmTemp = CreateBitmap (8, 8, 1, 1, &aBitBlend50); |
| 658 | himl->hbrBlend50 = CreatePatternBrush (hbmTemp); |
| 659 | DeleteObject (hbmTemp); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 660 | |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 661 | TRACE("created imagelist %p\n", himl); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 662 | return himl; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 666 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 667 | * ImageList_Destroy [COMCTL32.@] |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 668 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 669 | * Destroys an image list. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 670 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 671 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 672 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 673 | * |
| 674 | * RETURNS |
| 675 | * Success: TRUE |
| 676 | * Failure: FALSE |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 677 | */ |
| 678 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 679 | BOOL WINAPI |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 680 | ImageList_Destroy (HIMAGELIST himl) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 681 | { |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 682 | if (!himl) |
| 683 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 684 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 685 | /* delete image bitmaps */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 686 | if (himl->hbmImage) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 687 | DeleteObject (himl->hbmImage); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 688 | if (himl->hbmMask) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 689 | DeleteObject (himl->hbmMask); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 690 | |
| 691 | /* delete blending brushes */ |
| 692 | if (himl->hbrBlend25) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 693 | DeleteObject (himl->hbrBlend25); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 694 | if (himl->hbrBlend50) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 695 | DeleteObject (himl->hbrBlend50); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 696 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 697 | COMCTL32_Free (himl); |
| 698 | |
| 699 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 700 | } |
| 701 | |
| 702 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 703 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 704 | * ImageList_DragEnter [COMCTL32.@] |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 705 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 706 | * Locks window update and displays the drag image at the given position. |
| 707 | * |
| 708 | * PARAMS |
| 709 | * hwndLock [I] handle of the window that owns the drag image. |
| 710 | * x [I] X position of the drag image. |
| 711 | * y [I] Y position of the drag image. |
| 712 | * |
| 713 | * RETURNS |
| 714 | * Success: TRUE |
| 715 | * Failure: FALSE |
| 716 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 717 | * NOTES |
| 718 | * The position of the drag image is relative to the window, not |
| 719 | * the client area. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 720 | */ |
| 721 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 722 | BOOL WINAPI |
| 723 | ImageList_DragEnter (HWND hwndLock, INT x, INT y) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 724 | { |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 725 | TRACE("(hwnd=%p x=%d y=%d)\n", hwndLock, x, y); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 726 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 727 | if (InternalDrag.himl == NULL) |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 728 | return FALSE; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 729 | |
| 730 | if (hwndLock) |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 731 | InternalDrag.hwnd = hwndLock; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 732 | else |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 733 | InternalDrag.hwnd = GetDesktopWindow (); |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 734 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 735 | InternalDrag.x = x; |
| 736 | InternalDrag.y = y; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 737 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 738 | /* draw the drag image and save the background */ |
| 739 | if (!ImageList_DragShowNolock(TRUE)) { |
| 740 | return FALSE; |
| 741 | } |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 742 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 743 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 744 | } |
| 745 | |
| 746 | |
| 747 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 748 | * ImageList_DragLeave [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 749 | * |
| 750 | * Unlocks window update and hides the drag image. |
| 751 | * |
| 752 | * PARAMS |
| 753 | * hwndLock [I] handle of the window that owns the drag image. |
| 754 | * |
| 755 | * RETURNS |
| 756 | * Success: TRUE |
| 757 | * Failure: FALSE |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 758 | */ |
| 759 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 760 | BOOL WINAPI |
| 761 | ImageList_DragLeave (HWND hwndLock) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 762 | { |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 763 | /* As we don't save drag info in the window this can lead to problems if |
| 764 | an app does not supply the same window as DragEnter */ |
| 765 | /* if (hwndLock) |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 766 | InternalDrag.hwnd = hwndLock; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 767 | else |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 768 | InternalDrag.hwnd = GetDesktopWindow (); */ |
| 769 | if(!hwndLock) |
| 770 | hwndLock = GetDesktopWindow(); |
| 771 | if(InternalDrag.hwnd != hwndLock) |
| 772 | FIXME("DragLeave hWnd != DragEnter hWnd\n"); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 773 | |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 774 | ImageList_DragShowNolock (FALSE); |
| 775 | |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 776 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | |
| 780 | /************************************************************************* |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 781 | * ImageList_InternalDragDraw [Internal] |
| 782 | * |
| 783 | * Draws the drag image. |
| 784 | * |
| 785 | * PARAMS |
| 786 | * hdc [I] device context to draw into. |
| 787 | * x [I] X position of the drag image. |
| 788 | * y [I] Y position of the drag image. |
| 789 | * |
| 790 | * RETURNS |
| 791 | * Success: TRUE |
| 792 | * Failure: FALSE |
| 793 | * |
| 794 | * NOTES |
| 795 | * The position of the drag image is relative to the window, not |
| 796 | * the client area. |
| 797 | * |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 798 | */ |
| 799 | |
| 800 | static inline void |
| 801 | ImageList_InternalDragDraw (HDC hdc, INT x, INT y) |
| 802 | { |
| 803 | IMAGELISTDRAWPARAMS imldp; |
| 804 | |
| 805 | ZeroMemory (&imldp, sizeof(imldp)); |
| 806 | imldp.cbSize = sizeof(imldp); |
| 807 | imldp.himl = InternalDrag.himl; |
| 808 | imldp.i = 0; |
| 809 | imldp.hdcDst = hdc, |
| 810 | imldp.x = x; |
| 811 | imldp.y = y; |
| 812 | imldp.rgbBk = CLR_DEFAULT; |
| 813 | imldp.rgbFg = CLR_DEFAULT; |
| 814 | imldp.fStyle = ILD_NORMAL; |
| 815 | imldp.fState = ILS_ALPHA; |
| 816 | imldp.Frame = 128; |
| 817 | |
Dimitrie O. Paun | 326021b | 2002-09-24 18:26:42 +0000 | [diff] [blame] | 818 | /* FIXME: instead of using the alpha blending, we should |
| 819 | * create a 50% mask, and draw it semitransparantly that way */ |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 820 | ImageList_DrawIndirect (&imldp); |
| 821 | } |
| 822 | |
| 823 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 824 | * ImageList_DragMove [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 825 | * |
| 826 | * Moves the drag image. |
| 827 | * |
| 828 | * PARAMS |
| 829 | * x [I] X position of the drag image. |
| 830 | * y [I] Y position of the drag image. |
| 831 | * |
| 832 | * RETURNS |
| 833 | * Success: TRUE |
| 834 | * Failure: FALSE |
| 835 | * |
| 836 | * NOTES |
| 837 | * The position of the drag image is relative to the window, not |
| 838 | * the client area. |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 839 | * |
| 840 | * BUGS |
| 841 | * The drag image should be drawn semitransparent. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 842 | */ |
| 843 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 844 | BOOL WINAPI |
| 845 | ImageList_DragMove (INT x, INT y) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 846 | { |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 847 | TRACE("(x=%d y=%d)\n", x, y); |
| 848 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 849 | if (!InternalDrag.himl) { |
| 850 | return FALSE; |
| 851 | } |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 852 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 853 | /* draw/update the drag image */ |
| 854 | if (InternalDrag.bShow) { |
| 855 | HDC hdcDrag; |
| 856 | HDC hdcOffScreen; |
| 857 | HDC hdcBg; |
| 858 | HBITMAP hbmOffScreen; |
| 859 | INT origNewX, origNewY; |
| 860 | INT origOldX, origOldY; |
| 861 | INT origRegX, origRegY; |
| 862 | INT sizeRegX, sizeRegY; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 863 | |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 864 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 865 | /* calculate the update region */ |
| 866 | origNewX = x - InternalDrag.dxHotspot; |
| 867 | origNewY = y - InternalDrag.dyHotspot; |
| 868 | origOldX = InternalDrag.x - InternalDrag.dxHotspot; |
| 869 | origOldY = InternalDrag.y - InternalDrag.dyHotspot; |
| 870 | origRegX = min(origNewX, origOldX); |
| 871 | origRegY = min(origNewY, origOldY); |
| 872 | sizeRegX = InternalDrag.himl->cx + abs(x - InternalDrag.x); |
| 873 | sizeRegY = InternalDrag.himl->cy + abs(y - InternalDrag.y); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 874 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 875 | hdcDrag = GetDCEx(InternalDrag.hwnd, 0, |
| 876 | DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE); |
| 877 | hdcOffScreen = CreateCompatibleDC(hdcDrag); |
| 878 | hdcBg = CreateCompatibleDC(hdcDrag); |
| 879 | |
| 880 | hbmOffScreen = CreateCompatibleBitmap(hdcDrag, sizeRegX, sizeRegY); |
| 881 | SelectObject(hdcOffScreen, hbmOffScreen); |
| 882 | SelectObject(hdcBg, InternalDrag.hbmBg); |
| 883 | |
| 884 | /* get the actual background of the update region */ |
| 885 | BitBlt(hdcOffScreen, 0, 0, sizeRegX, sizeRegY, hdcDrag, |
| 886 | origRegX, origRegY, SRCCOPY); |
| 887 | /* erase the old image */ |
| 888 | BitBlt(hdcOffScreen, origOldX - origRegX, origOldY - origRegY, |
| 889 | InternalDrag.himl->cx, InternalDrag.himl->cy, hdcBg, 0, 0, |
| 890 | SRCCOPY); |
| 891 | /* save the background */ |
| 892 | BitBlt(hdcBg, 0, 0, InternalDrag.himl->cx, InternalDrag.himl->cy, |
| 893 | hdcOffScreen, origNewX - origRegX, origNewY - origRegY, SRCCOPY); |
| 894 | /* draw the image */ |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 895 | ImageList_InternalDragDraw(hdcOffScreen, origNewX - origRegX, |
| 896 | origNewY - origRegY); |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 897 | /* draw the update region to the screen */ |
| 898 | BitBlt(hdcDrag, origRegX, origRegY, sizeRegX, sizeRegY, |
| 899 | hdcOffScreen, 0, 0, SRCCOPY); |
| 900 | |
| 901 | DeleteDC(hdcBg); |
| 902 | DeleteDC(hdcOffScreen); |
Michael Stefaniuc | 00bd799 | 2001-12-31 22:21:24 +0000 | [diff] [blame] | 903 | DeleteObject(hbmOffScreen); |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 904 | ReleaseDC(InternalDrag.hwnd, hdcDrag); |
| 905 | } |
| 906 | |
| 907 | /* update the image position */ |
| 908 | InternalDrag.x = x; |
| 909 | InternalDrag.y = y; |
| 910 | |
| 911 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 912 | } |
| 913 | |
| 914 | |
| 915 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 916 | * ImageList_DragShowNolock [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 917 | * |
| 918 | * Shows or hides the drag image. |
| 919 | * |
| 920 | * PARAMS |
| 921 | * bShow [I] TRUE shows the drag image, FALSE hides it. |
| 922 | * |
| 923 | * RETURNS |
| 924 | * Success: TRUE |
| 925 | * Failure: FALSE |
| 926 | * |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 927 | * BUGS |
| 928 | * The drag image should be drawn semitransparent. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 929 | */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 930 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 931 | BOOL WINAPI |
| 932 | ImageList_DragShowNolock (BOOL bShow) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 933 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 934 | HDC hdcDrag; |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 935 | HDC hdcBg; |
| 936 | INT x, y; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 937 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 938 | TRACE("bShow=0x%X!\n", bShow); |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 939 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 940 | /* DragImage is already visible/hidden */ |
| 941 | if ((InternalDrag.bShow && bShow) || (!InternalDrag.bShow && !bShow)) { |
| 942 | return FALSE; |
| 943 | } |
| 944 | |
| 945 | /* position of the origin of the DragImage */ |
| 946 | x = InternalDrag.x - InternalDrag.dxHotspot; |
| 947 | y = InternalDrag.y - InternalDrag.dyHotspot; |
| 948 | |
| 949 | hdcDrag = GetDCEx (InternalDrag.hwnd, 0, |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 950 | DCX_WINDOW | DCX_CACHE | DCX_LOCKWINDOWUPDATE); |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 951 | if (!hdcDrag) { |
| 952 | return FALSE; |
| 953 | } |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 954 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 955 | hdcBg = CreateCompatibleDC(hdcDrag); |
| 956 | if (!InternalDrag.hbmBg) { |
| 957 | InternalDrag.hbmBg = CreateCompatibleBitmap(hdcDrag, |
| 958 | InternalDrag.himl->cx, InternalDrag.himl->cy); |
| 959 | } |
| 960 | SelectObject(hdcBg, InternalDrag.hbmBg); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 961 | |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 962 | if (bShow) { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 963 | /* save the background */ |
| 964 | BitBlt(hdcBg, 0, 0, InternalDrag.himl->cx, InternalDrag.himl->cy, |
| 965 | hdcDrag, x, y, SRCCOPY); |
| 966 | /* show the image */ |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 967 | ImageList_InternalDragDraw(hdcDrag, x, y); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 968 | } else { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 969 | /* hide the image */ |
| 970 | BitBlt(hdcDrag, x, y, InternalDrag.himl->cx, InternalDrag.himl->cy, |
| 971 | hdcBg, 0, 0, SRCCOPY); |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 972 | } |
| 973 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 974 | InternalDrag.bShow = !InternalDrag.bShow; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 975 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 976 | DeleteDC(hdcBg); |
| 977 | ReleaseDC (InternalDrag.hwnd, hdcDrag); |
| 978 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | |
| 982 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 983 | * ImageList_Draw [COMCTL32.@] Draws an image. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 984 | * |
| 985 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 986 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 987 | * i [I] image index |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 988 | * hdc [I] handle to device context |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 989 | * x [I] x position |
| 990 | * y [I] y position |
| 991 | * fStyle [I] drawing flags |
| 992 | * |
| 993 | * RETURNS |
| 994 | * Success: TRUE |
| 995 | * Failure: FALSE |
| 996 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 997 | * SEE |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 998 | * ImageList_DrawEx. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 999 | */ |
| 1000 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1001 | BOOL WINAPI |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1002 | ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1003 | { |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1004 | return ImageList_DrawEx (himl, i, hdc, x, y, 0, 0, |
| 1005 | CLR_DEFAULT, CLR_DEFAULT, fStyle); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | |
| 1009 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1010 | * ImageList_DrawEx [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1011 | * |
| 1012 | * Draws an image and allows to use extended drawing features. |
| 1013 | * |
| 1014 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1015 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1016 | * i [I] image index |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1017 | * hdc [I] handle to device context |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1018 | * x [I] X position |
| 1019 | * y [I] Y position |
Dimitrie O. Paun | 7ad3d12 | 2002-09-04 18:44:46 +0000 | [diff] [blame] | 1020 | * dx [I] X offset |
| 1021 | * dy [I] Y offset |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1022 | * rgbBk [I] background color |
| 1023 | * rgbFg [I] foreground color |
| 1024 | * fStyle [I] drawing flags |
| 1025 | * |
| 1026 | * RETURNS |
| 1027 | * Success: TRUE |
| 1028 | * Failure: FALSE |
| 1029 | * |
| 1030 | * NOTES |
| 1031 | * Calls ImageList_DrawIndirect. |
| 1032 | * |
| 1033 | * SEE |
| 1034 | * ImageList_DrawIndirect. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1035 | */ |
| 1036 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1037 | BOOL WINAPI |
| 1038 | ImageList_DrawEx (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, |
| 1039 | INT dx, INT dy, COLORREF rgbBk, COLORREF rgbFg, |
| 1040 | UINT fStyle) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1041 | { |
| 1042 | IMAGELISTDRAWPARAMS imldp; |
| 1043 | |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1044 | ZeroMemory (&imldp, sizeof(imldp)); |
| 1045 | imldp.cbSize = sizeof(imldp); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1046 | imldp.himl = himl; |
| 1047 | imldp.i = i; |
| 1048 | imldp.hdcDst = hdc, |
| 1049 | imldp.x = x; |
| 1050 | imldp.y = y; |
Alexandre Julliard | ebfc0fe | 1998-06-28 18:40:26 +0000 | [diff] [blame] | 1051 | imldp.cx = dx; |
| 1052 | imldp.cy = dy; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1053 | imldp.rgbBk = rgbBk; |
| 1054 | imldp.rgbFg = rgbFg; |
| 1055 | imldp.fStyle = fStyle; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1056 | |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 1057 | return ImageList_DrawIndirect (&imldp); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1058 | } |
| 1059 | |
| 1060 | |
| 1061 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1062 | * ImageList_DrawIndirect [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1063 | * |
| 1064 | * Draws an image using ... |
| 1065 | * |
| 1066 | * PARAMS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1067 | * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1068 | * |
| 1069 | * RETURNS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1070 | * Success: TRUE |
| 1071 | * Failure: FALSE |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1072 | */ |
| 1073 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1074 | BOOL WINAPI |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1075 | ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1076 | { |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1077 | INT cx, cy, nOvlIdx; |
| 1078 | DWORD fState, dwRop; |
| 1079 | UINT fStyle; |
| 1080 | COLORREF clrBk, oldImageBk, oldImageFg; |
| 1081 | HDC hImageDC, hImageListDC, hMaskListDC; |
| 1082 | HBITMAP hImageBmp, hOldImageBmp, hOldImageListBmp, hOldMaskListBmp, hBlendMaskBmp; |
| 1083 | BOOL bIsTransparent, bBlend, bResult = FALSE; |
| 1084 | const HIMAGELIST himl = pimldp->himl; |
| 1085 | const INT lx = himl->cx * pimldp->i + pimldp->xBitmap; |
| 1086 | const INT ly = pimldp->yBitmap; |
| 1087 | |
| 1088 | if (!pimldp || !himl) return FALSE; |
| 1089 | if ((pimldp->i < 0) || (pimldp->i >= himl->cCurImage)) return FALSE; |
| 1090 | |
| 1091 | fState = pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS) ? ILS_NORMAL : pimldp->fState; |
| 1092 | fStyle = pimldp->fStyle & ~ILD_OVERLAYMASK; |
| 1093 | cx = (pimldp->cx == 0) ? himl->cx : pimldp->cx; |
| 1094 | cy = (pimldp->cy == 0) ? himl->cy : pimldp->cy; |
| 1095 | clrBk = (pimldp->rgbBk == CLR_DEFAULT) ? himl->clrBk : pimldp->rgbBk; |
Dimitrie O. Paun | 0bc4b56 | 2002-10-15 02:15:09 +0000 | [diff] [blame] | 1096 | bIsTransparent = (fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE; |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1097 | bBlend = fStyle & (ILD_BLEND25 | ILD_BLEND50); |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 1098 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 1099 | TRACE("hbmMask(%p) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n", |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1100 | himl->hbmMask, pimldp->i, pimldp->x, pimldp->y, cx, cy); |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 1101 | |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1102 | /* we will use these DCs to access the images and masks in the ImageList */ |
| 1103 | hImageListDC = CreateCompatibleDC(0); |
| 1104 | hMaskListDC = himl->hbmMask ? CreateCompatibleDC(0) : 0; |
| 1105 | |
| 1106 | /* these will accumulate the image and mask for the image we're drawing */ |
| 1107 | hImageDC = CreateCompatibleDC( pimldp->hdcDst ); |
| 1108 | hImageBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy ); |
| 1109 | hBlendMaskBmp = bBlend ? CreateBitmap(cx, cy, 1, 1, NULL) : 0; |
| 1110 | |
| 1111 | /* Create a compatible DC. */ |
| 1112 | if (!hImageListDC || !hImageDC || !hImageBmp || |
| 1113 | (bBlend && !hBlendMaskBmp) || (himl->hbmMask && !hMaskListDC)) |
| 1114 | goto cleanup; |
| 1115 | |
| 1116 | hOldImageListBmp = SelectObject(hImageListDC, himl->hbmImage); |
| 1117 | hOldImageBmp = SelectObject(hImageDC, hImageBmp); |
| 1118 | hOldMaskListBmp = hMaskListDC ? SelectObject(hMaskListDC, himl->hbmMask) : 0; |
| 1119 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1120 | /* |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1121 | * To obtain a transparent look, background color should be set |
| 1122 | * to white and foreground color to black when blting the |
| 1123 | * monochrome mask. |
| 1124 | */ |
| 1125 | oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) ); |
| 1126 | oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) ); |
| 1127 | |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1128 | /* |
Dimitrie O. Paun | 0bc4b56 | 2002-10-15 02:15:09 +0000 | [diff] [blame] | 1129 | * Draw the initial image |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1130 | */ |
| 1131 | if(fStyle & ILD_MASK) { |
| 1132 | if (himl->hbmMask) { |
| 1133 | BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY); |
| 1134 | } else { |
| 1135 | HBRUSH hOldBrush = SelectObject (hImageDC, GetStockObject(BLACK_BRUSH)); |
| 1136 | PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY); |
| 1137 | SelectObject(hImageDC, hOldBrush); |
| 1138 | } |
Dimitrie O. Paun | 0bc4b56 | 2002-10-15 02:15:09 +0000 | [diff] [blame] | 1139 | } else if (himl->hbmMask && !bIsTransparent) { |
| 1140 | /* blend the image with the needed solid background */ |
| 1141 | HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk)); |
| 1142 | PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY ); |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1143 | BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND ); |
| 1144 | BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT ); |
Dimitrie O. Paun | 0bc4b56 | 2002-10-15 02:15:09 +0000 | [diff] [blame] | 1145 | DeleteObject (SelectObject (hImageDC, hOldBrush)); |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1146 | } else { |
Dimitrie O. Paun | 0bc4b56 | 2002-10-15 02:15:09 +0000 | [diff] [blame] | 1147 | /* start off with the image, if we have a mask, we'll use it later */ |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1148 | BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCCOPY); |
| 1149 | } |
| 1150 | |
| 1151 | /* Time for blending, if required */ |
| 1152 | if (bBlend) { |
| 1153 | HBRUSH hBlendBrush, hOldBrush; |
| 1154 | COLORREF clrBlend = pimldp->rgbFg; |
| 1155 | HDC hBlendMaskDC = hImageListDC; |
| 1156 | HBITMAP hOldBitmap; |
| 1157 | |
| 1158 | /* Create the blend Mask */ |
| 1159 | hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBmp); |
| 1160 | hBlendBrush = fStyle & ILD_BLEND50 ? himl->hbrBlend50 : himl->hbrBlend25; |
| 1161 | hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush); |
| 1162 | PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY); |
| 1163 | SelectObject(hBlendMaskDC, hOldBrush); |
| 1164 | |
| 1165 | /* Modify the blend mask if an Image Mask exist */ |
| 1166 | if(himl->hbmMask) { |
| 1167 | BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskListDC, lx, ly, 0x220326); /* NOTSRCAND */ |
| 1168 | BitBlt(hBlendMaskDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, NOTSRCCOPY); |
| 1169 | } |
| 1170 | |
| 1171 | /* now apply blend to the current image given the BlendMask */ |
| 1172 | if (clrBlend == CLR_DEFAULT) clrBlend = GetSysColor (COLOR_HIGHLIGHT); |
| 1173 | else if (clrBlend == CLR_NONE) clrBlend = GetTextColor (pimldp->hdcDst); |
| 1174 | hOldBrush = (HBRUSH) SelectObject (hImageDC, CreateSolidBrush(clrBlend)); |
| 1175 | BitBlt (hImageDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, 0xB8074A); /* PSDPxax */ |
| 1176 | DeleteObject(SelectObject(hImageDC, hOldBrush)); |
| 1177 | SelectObject(hBlendMaskDC, hOldBitmap); |
| 1178 | } |
| 1179 | |
| 1180 | /* Now do the overlay image, if any */ |
| 1181 | nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8; |
| 1182 | if ( (nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) { |
| 1183 | nOvlIdx = himl->nOvlIdx[nOvlIdx - 1]; |
| 1184 | if ((nOvlIdx >= 0) && (nOvlIdx < himl->cCurImage)) { |
| 1185 | const INT ox = himl->cx * nOvlIdx + pimldp->xBitmap; |
| 1186 | if (himl->hbmMask && !(fStyle & ILD_IMAGE)) |
| 1187 | BitBlt (hImageDC, 0, 0, cx, cy, hMaskListDC, ox, ly, SRCAND); |
| 1188 | BitBlt (hImageDC, 0, 0, cx, cy, hImageListDC, ox, ly, SRCPAINT); |
| 1189 | } |
| 1190 | } |
| 1191 | |
| 1192 | if (fState & ILS_SATURATE) FIXME("ILS_SATURATE: unimplemented!\n"); |
| 1193 | if (fState & ILS_GLOW) FIXME("ILS_GLOW: unimplemented!\n"); |
| 1194 | if (fState & ILS_SHADOW) FIXME("ILS_SHADOW: unimplemented!\n"); |
| 1195 | if (fState & ILS_ALPHA) FIXME("ILS_SHADOW: unimplemented!\n"); |
| 1196 | |
| 1197 | if (fStyle & ILD_PRESERVEALPHA) FIXME("ILD_PRESERVEALPHA: unimplemented!\n"); |
| 1198 | if (fStyle & ILD_SCALE) FIXME("ILD_SCALE: unimplemented!\n"); |
| 1199 | if (fStyle & ILD_DPISCALE) FIXME("ILD_DPISCALE: unimplemented!\n"); |
| 1200 | |
| 1201 | /* now copy the image to the screen */ |
| 1202 | dwRop = SRCCOPY; |
Dimitrie O. Paun | 0bc4b56 | 2002-10-15 02:15:09 +0000 | [diff] [blame] | 1203 | if (himl->hbmMask && bIsTransparent && !(fStyle & ILD_MASK)) { |
Dimitrie O. Paun | 318817f | 2002-09-12 00:51:09 +0000 | [diff] [blame] | 1204 | COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) ); |
| 1205 | COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff )); |
| 1206 | BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND); |
| 1207 | SetBkColor(pimldp->hdcDst, oldDstBk); |
| 1208 | SetTextColor(pimldp->hdcDst, oldDstFg); |
| 1209 | dwRop = SRCPAINT; |
| 1210 | } |
| 1211 | if (fStyle & ILD_ROP) dwRop = pimldp->dwRop; |
| 1212 | BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, dwRop); |
| 1213 | |
| 1214 | bResult = TRUE; |
| 1215 | |
| 1216 | /* cleanup the mess */ |
| 1217 | SetBkColor(hImageDC, oldImageBk); |
| 1218 | SetTextColor(hImageDC, oldImageFg); |
| 1219 | SelectObject(hImageDC, hOldImageBmp); |
| 1220 | SelectObject(hImageListDC, hOldImageListBmp); |
| 1221 | if (hMaskListDC) SelectObject(hMaskListDC, hOldMaskListBmp); |
| 1222 | cleanup: |
| 1223 | DeleteObject(hBlendMaskBmp); |
| 1224 | DeleteObject(hImageBmp); |
| 1225 | DeleteObject(hImageDC); |
| 1226 | DeleteObject(hImageListDC); |
| 1227 | DeleteObject(hMaskListDC); |
| 1228 | |
| 1229 | return bResult; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1230 | } |
| 1231 | |
| 1232 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1233 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1234 | * ImageList_Duplicate [COMCTL32.@] Duplicates an image list. |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1235 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1236 | * PARAMS |
| 1237 | * himlSrc [I] source image list handle |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1238 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1239 | * RETURNS |
| 1240 | * Success: Handle of duplicated image list. |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1241 | * Failure: NULL |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1242 | */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1243 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1244 | HIMAGELIST WINAPI |
| 1245 | ImageList_Duplicate (HIMAGELIST himlSrc) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1246 | { |
| 1247 | HIMAGELIST himlDst; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1248 | HDC hdcSrc, hdcDst; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1249 | |
| 1250 | if (himlSrc == NULL) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 1251 | ERR("Invalid image list handle!\n"); |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1252 | return NULL; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1253 | } |
| 1254 | |
| 1255 | himlDst = ImageList_Create (himlSrc->cx, himlSrc->cy, himlSrc->flags, |
| 1256 | himlSrc->cInitial, himlSrc->cGrow); |
| 1257 | |
| 1258 | if (himlDst) |
| 1259 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1260 | hdcSrc = CreateCompatibleDC (0); |
| 1261 | hdcDst = CreateCompatibleDC (0); |
| 1262 | SelectObject (hdcSrc, himlSrc->hbmImage); |
| 1263 | SelectObject (hdcDst, himlDst->hbmImage); |
| 1264 | BitBlt (hdcDst, 0, 0, himlSrc->cCurImage * himlSrc->cx, himlSrc->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1265 | hdcSrc, 0, 0, SRCCOPY); |
| 1266 | |
| 1267 | if (himlDst->hbmMask) |
| 1268 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1269 | SelectObject (hdcSrc, himlSrc->hbmMask); |
| 1270 | SelectObject (hdcDst, himlDst->hbmMask); |
| 1271 | BitBlt (hdcDst, 0, 0, himlSrc->cCurImage * himlSrc->cx, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1272 | himlSrc->cy, hdcSrc, 0, 0, SRCCOPY); |
| 1273 | } |
| 1274 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1275 | DeleteDC (hdcDst); |
| 1276 | DeleteDC (hdcSrc); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1277 | |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1278 | himlDst->cCurImage = himlSrc->cCurImage; |
| 1279 | himlDst->cMaxImage = himlSrc->cMaxImage; |
| 1280 | } |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1281 | return himlDst; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1282 | } |
| 1283 | |
| 1284 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1285 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1286 | * ImageList_EndDrag [COMCTL32.@] Finishes a drag operation. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1287 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1288 | * Finishes a drag operation. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1289 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1290 | * PARAMS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1291 | * no Parameters |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1292 | * |
| 1293 | * RETURNS |
| 1294 | * Success: TRUE |
| 1295 | * Failure: FALSE |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1296 | */ |
| 1297 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1298 | BOOL WINAPI |
Patrik Stridvall | 9e61c1c | 1999-06-12 08:27:49 +0000 | [diff] [blame] | 1299 | ImageList_EndDrag (void) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1300 | { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 1301 | /* cleanup the InternalDrag struct */ |
| 1302 | InternalDrag.hwnd = 0; |
| 1303 | ImageList_Destroy (InternalDrag.himl); |
| 1304 | InternalDrag.himl = 0; |
| 1305 | InternalDrag.x= 0; |
| 1306 | InternalDrag.y= 0; |
| 1307 | InternalDrag.dxHotspot = 0; |
| 1308 | InternalDrag.dyHotspot = 0; |
| 1309 | InternalDrag.bShow = FALSE; |
| 1310 | DeleteObject(InternalDrag.hbmBg); |
| 1311 | InternalDrag.hbmBg = 0; |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 1312 | InternalDrag.bHSPending = FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1313 | |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1314 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1315 | } |
| 1316 | |
| 1317 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1318 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1319 | * ImageList_GetBkColor [COMCTL32.@] |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1320 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1321 | * Returns the background color of an image list. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1322 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1323 | * PARAMS |
| 1324 | * himl [I] Image list handle. |
| 1325 | * |
| 1326 | * RETURNS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1327 | * Success: background color |
| 1328 | * Failure: CLR_NONE |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1329 | */ |
| 1330 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1331 | COLORREF WINAPI |
| 1332 | ImageList_GetBkColor (HIMAGELIST himl) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1333 | { |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1334 | return himl ? himl->clrBk : CLR_NONE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1335 | } |
| 1336 | |
| 1337 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1338 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1339 | * ImageList_GetDragImage [COMCTL32.@] |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1340 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1341 | * Returns the handle to the internal drag image list. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1342 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1343 | * PARAMS |
| 1344 | * ppt [O] Pointer to the drag position. Can be NULL. |
| 1345 | * pptHotspot [O] Pointer to the position of the hot spot. Can be NULL. |
| 1346 | * |
| 1347 | * RETURNS |
| 1348 | * Success: Handle of the drag image list. |
| 1349 | * Failure: NULL. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1350 | */ |
| 1351 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1352 | HIMAGELIST WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1353 | ImageList_GetDragImage (POINT *ppt, POINT *pptHotspot) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1354 | { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 1355 | if (InternalDrag.himl) { |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 1356 | if (ppt) { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 1357 | ppt->x = InternalDrag.x; |
| 1358 | ppt->y = InternalDrag.y; |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 1359 | } |
| 1360 | if (pptHotspot) { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 1361 | pptHotspot->x = InternalDrag.dxHotspot; |
| 1362 | pptHotspot->y = InternalDrag.dyHotspot; |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 1363 | } |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 1364 | return (InternalDrag.himl); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 1365 | } |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1366 | |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1367 | return NULL; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1368 | } |
| 1369 | |
| 1370 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1371 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1372 | * ImageList_GetFlags [COMCTL32.@] |
Huw D M Davies | 1a65a7b | 2002-01-15 20:28:05 +0000 | [diff] [blame] | 1373 | * |
| 1374 | * BUGS |
| 1375 | * Stub. |
| 1376 | */ |
| 1377 | |
| 1378 | DWORD WINAPI |
| 1379 | ImageList_GetFlags(HIMAGELIST himl) |
| 1380 | { |
| 1381 | FIXME("(%p):empty stub\n", himl); |
| 1382 | return 0; |
| 1383 | } |
| 1384 | |
| 1385 | |
| 1386 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1387 | * ImageList_GetIcon [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1388 | * |
| 1389 | * Creates an icon from a masked image of an image list. |
| 1390 | * |
| 1391 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1392 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1393 | * i [I] image index |
| 1394 | * flags [I] drawing style flags |
| 1395 | * |
| 1396 | * RETURNS |
| 1397 | * Success: icon handle |
| 1398 | * Failure: NULL |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1399 | */ |
| 1400 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1401 | HICON WINAPI |
| 1402 | ImageList_GetIcon (HIMAGELIST himl, INT i, UINT fStyle) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1403 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1404 | ICONINFO ii; |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1405 | HICON hIcon; |
| 1406 | HBITMAP hOldDstBitmap; |
| 1407 | HDC hdcDst; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1408 | |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1409 | if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) return 0; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1410 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1411 | hdcDst = CreateCompatibleDC(0); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1412 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1413 | ii.fIcon = TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1414 | |
| 1415 | /* draw mask*/ |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1416 | ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 1417 | hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask); |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1418 | ImageList_Draw(himl, i, hdcDst, 0, 0, ILD_MASK); |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 1419 | |
| 1420 | /* draw image*/ |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1421 | SelectObject (hdcDst, himl->hbmImage); |
| 1422 | ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); |
Luc Tourangeau | 296def2 | 1999-07-18 13:25:31 +0000 | [diff] [blame] | 1423 | SelectObject (hdcDst, ii.hbmColor); |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1424 | ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1425 | |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 1426 | /* |
| 1427 | * CreateIconIndirect requires us to deselect the bitmaps from |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1428 | * the DCs before calling |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 1429 | */ |
Pierre Mageau | 6231a17 | 1999-07-24 10:20:06 +0000 | [diff] [blame] | 1430 | SelectObject(hdcDst, hOldDstBitmap); |
| 1431 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1432 | hIcon = CreateIconIndirect (&ii); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1433 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1434 | DeleteObject (ii.hbmMask); |
| 1435 | DeleteObject (ii.hbmColor); |
Dimitrie O. Paun | 4d1e49d | 2002-09-04 23:31:48 +0000 | [diff] [blame] | 1436 | DeleteDC (hdcDst); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1437 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1438 | return hIcon; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1442 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1443 | * ImageList_GetIconSize [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1444 | * |
| 1445 | * Retrieves the size of an image in an image list. |
| 1446 | * |
| 1447 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1448 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1449 | * cx [O] pointer to the image width. |
| 1450 | * cy [O] pointer to the image height. |
| 1451 | * |
| 1452 | * RETURNS |
| 1453 | * Success: TRUE |
| 1454 | * Failure: FALSE |
| 1455 | * |
| 1456 | * NOTES |
| 1457 | * All images in an image list have the same size. |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1458 | */ |
| 1459 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1460 | BOOL WINAPI |
| 1461 | ImageList_GetIconSize (HIMAGELIST himl, INT *cx, INT *cy) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1462 | { |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1463 | if (himl == NULL) |
| 1464 | return FALSE; |
| 1465 | if ((himl->cx <= 0) || (himl->cy <= 0)) |
| 1466 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1467 | |
| 1468 | if (cx) |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1469 | *cx = himl->cx; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1470 | if (cy) |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1471 | *cy = himl->cy; |
| 1472 | |
| 1473 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1474 | } |
| 1475 | |
| 1476 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1477 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1478 | * ImageList_GetImageCount [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1479 | * |
| 1480 | * Returns the number of images in an image list. |
| 1481 | * |
| 1482 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1483 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1484 | * |
| 1485 | * RETURNS |
| 1486 | * Success: Number of images. |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1487 | * Failure: 0 |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1488 | */ |
| 1489 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1490 | INT WINAPI |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1491 | ImageList_GetImageCount (HIMAGELIST himl) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1492 | { |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1493 | if (himl == NULL) |
| 1494 | return 0; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1495 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1496 | return himl->cCurImage; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1497 | } |
| 1498 | |
| 1499 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1500 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1501 | * ImageList_GetImageInfo [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1502 | * |
| 1503 | * Returns information about an image in an image list. |
| 1504 | * |
| 1505 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1506 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1507 | * i [I] image index |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1508 | * pImageInfo [O] pointer to the image information |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1509 | * |
| 1510 | * RETURNS |
| 1511 | * Success: TRUE |
| 1512 | * Failure: FALSE |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1513 | */ |
| 1514 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1515 | BOOL WINAPI |
| 1516 | ImageList_GetImageInfo (HIMAGELIST himl, INT i, IMAGEINFO *pImageInfo) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1517 | { |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1518 | if ((himl == NULL) || (pImageInfo == NULL)) |
| 1519 | return FALSE; |
| 1520 | if ((i < 0) || (i >= himl->cCurImage)) |
| 1521 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1522 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1523 | pImageInfo->hbmImage = himl->hbmImage; |
| 1524 | pImageInfo->hbmMask = himl->hbmMask; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1525 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1526 | pImageInfo->rcImage.top = 0; |
| 1527 | pImageInfo->rcImage.bottom = himl->cy; |
| 1528 | pImageInfo->rcImage.left = i * himl->cx; |
| 1529 | pImageInfo->rcImage.right = (i+1) * himl->cx; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1530 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1531 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1532 | } |
| 1533 | |
| 1534 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1535 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1536 | * ImageList_GetImageRect [COMCTL32.@] |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1537 | * |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1538 | * Retrieves the rectangle of the specified image in an image list. |
| 1539 | * |
| 1540 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1541 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1542 | * i [I] image index |
| 1543 | * lpRect [O] pointer to the image rectangle |
| 1544 | * |
| 1545 | * RETURNS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1546 | * Success: TRUE |
| 1547 | * Failure: FALSE |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1548 | * |
| 1549 | * NOTES |
| 1550 | * This is an UNDOCUMENTED function!!! |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1551 | */ |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1552 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1553 | BOOL WINAPI |
| 1554 | ImageList_GetImageRect (HIMAGELIST himl, INT i, LPRECT lpRect) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1555 | { |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1556 | if ((himl == NULL) || (lpRect == NULL)) |
| 1557 | return FALSE; |
| 1558 | if ((i < 0) || (i >= himl->cCurImage)) |
| 1559 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1560 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1561 | lpRect->left = i * himl->cx; |
| 1562 | lpRect->top = 0; |
| 1563 | lpRect->right = lpRect->left + himl->cx; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1564 | lpRect->bottom = himl->cy; |
| 1565 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1566 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1567 | } |
| 1568 | |
| 1569 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1570 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1571 | * ImageList_LoadImage [COMCTL32.@] |
| 1572 | * ImageList_LoadImageA [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1573 | * |
| 1574 | * Creates an image list from a bitmap, icon or cursor. |
| 1575 | * |
| 1576 | * PARAMS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1577 | * hi [I] instance handle |
| 1578 | * lpbmp [I] name or id of the image |
| 1579 | * cx [I] width of each image |
| 1580 | * cGrow [I] number of images to expand |
| 1581 | * clrMask [I] mask color |
| 1582 | * uType [I] type of image to load |
| 1583 | * uFlags [I] loading flags |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1584 | * |
| 1585 | * RETURNS |
Eric Kohl | d68d501 | 1999-01-24 19:14:58 +0000 | [diff] [blame] | 1586 | * Success: handle to the loaded image list |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1587 | * Failure: NULL |
| 1588 | * |
| 1589 | * SEE |
| 1590 | * LoadImage () |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1591 | */ |
| 1592 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1593 | HIMAGELIST WINAPI |
Andreas Mohr | 641405a | 2001-04-20 18:29:17 +0000 | [diff] [blame] | 1594 | ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow, |
| 1595 | COLORREF clrMask, UINT uType, UINT uFlags) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1596 | { |
| 1597 | HIMAGELIST himl = NULL; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1598 | HANDLE handle; |
| 1599 | INT nImageCount; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1600 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1601 | handle = LoadImageA (hi, lpbmp, uType, 0, 0, uFlags); |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1602 | if (!handle) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 1603 | ERR("Error loading image!\n"); |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1604 | return NULL; |
| 1605 | } |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1606 | |
| 1607 | if (uType == IMAGE_BITMAP) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1608 | BITMAP bmp; |
| 1609 | GetObjectA (handle, sizeof(BITMAP), &bmp); |
Francois Boisvert | 0e6f061 | 1999-06-22 19:02:07 +0000 | [diff] [blame] | 1610 | |
| 1611 | /* To match windows behavior, if cx is set to zero and |
| 1612 | the flag DI_DEFAULTSIZE is specified, cx becomes the |
| 1613 | system metric value for icons. If the flag is not specified |
| 1614 | the function sets the size to the height of the bitmap */ |
| 1615 | if (cx == 0) |
| 1616 | { |
| 1617 | if (uFlags & DI_DEFAULTSIZE) |
| 1618 | cx = GetSystemMetrics (SM_CXICON); |
| 1619 | else |
| 1620 | cx = bmp.bmHeight; |
| 1621 | } |
| 1622 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1623 | nImageCount = bmp.bmWidth / cx; |
| 1624 | |
| 1625 | himl = ImageList_Create (cx, bmp.bmHeight, ILC_MASK | ILC_COLOR, |
| 1626 | nImageCount, cGrow); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1627 | ImageList_AddMasked (himl, (HBITMAP)handle, clrMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1628 | } |
| 1629 | else if ((uType == IMAGE_ICON) || (uType == IMAGE_CURSOR)) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1630 | ICONINFO ii; |
| 1631 | BITMAP bmp; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1632 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1633 | GetIconInfo (handle, &ii); |
| 1634 | GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1635 | himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1636 | ILC_MASK | ILC_COLOR, 1, cGrow); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1637 | ImageList_Add (himl, ii.hbmColor, ii.hbmMask); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1638 | DeleteObject (ii.hbmColor); |
| 1639 | DeleteObject (ii.hbmMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1640 | } |
| 1641 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1642 | DeleteObject (handle); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1643 | |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1644 | return himl; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1645 | } |
| 1646 | |
| 1647 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1648 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1649 | * ImageList_LoadImageW [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1650 | * |
| 1651 | * Creates an image list from a bitmap, icon or cursor. |
| 1652 | * |
| 1653 | * PARAMS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1654 | * hi [I] instance handle |
| 1655 | * lpbmp [I] name or id of the image |
| 1656 | * cx [I] width of each image |
| 1657 | * cGrow [I] number of images to expand |
| 1658 | * clrMask [I] mask color |
| 1659 | * uType [I] type of image to load |
| 1660 | * uFlags [I] loading flags |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1661 | * |
| 1662 | * RETURNS |
Eric Kohl | d68d501 | 1999-01-24 19:14:58 +0000 | [diff] [blame] | 1663 | * Success: handle to the loaded image list |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1664 | * Failure: NULL |
| 1665 | * |
| 1666 | * SEE |
| 1667 | * LoadImage () |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1668 | */ |
| 1669 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1670 | HIMAGELIST WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1671 | ImageList_LoadImageW (HINSTANCE hi, LPCWSTR lpbmp, INT cx, INT cGrow, |
| 1672 | COLORREF clrMask, UINT uType, UINT uFlags) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1673 | { |
| 1674 | HIMAGELIST himl = NULL; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1675 | HANDLE handle; |
| 1676 | INT nImageCount; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1677 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1678 | handle = LoadImageW (hi, lpbmp, uType, 0, 0, uFlags); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1679 | if (!handle) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 1680 | ERR("Error loading image!\n"); |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1681 | return NULL; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1682 | } |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1683 | |
| 1684 | if (uType == IMAGE_BITMAP) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1685 | BITMAP bmp; |
| 1686 | GetObjectA (handle, sizeof(BITMAP), &bmp); |
Sander van Leeuwen | 9851f7a | 2002-05-30 20:38:13 +0000 | [diff] [blame] | 1687 | |
| 1688 | /* To match windows behavior, if cx is set to zero and |
| 1689 | the flag DI_DEFAULTSIZE is specified, cx becomes the |
| 1690 | system metric value for icons. If the flag is not specified |
| 1691 | the function sets the size to the height of the bitmap */ |
| 1692 | if (cx == 0) |
| 1693 | { |
| 1694 | if (uFlags & DI_DEFAULTSIZE) |
| 1695 | cx = GetSystemMetrics (SM_CXICON); |
| 1696 | else |
| 1697 | cx = bmp.bmHeight; |
| 1698 | } |
| 1699 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1700 | nImageCount = bmp.bmWidth / cx; |
| 1701 | |
| 1702 | himl = ImageList_Create (cx, bmp.bmHeight, ILC_MASK | ILC_COLOR, |
| 1703 | nImageCount, cGrow); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1704 | ImageList_AddMasked (himl, (HBITMAP)handle, clrMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1705 | } |
| 1706 | else if ((uType == IMAGE_ICON) || (uType == IMAGE_CURSOR)) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1707 | ICONINFO ii; |
| 1708 | BITMAP bmp; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1709 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1710 | GetIconInfo (handle, &ii); |
| 1711 | GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1712 | himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1713 | ILC_MASK | ILC_COLOR, 1, cGrow); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 1714 | ImageList_Add (himl, ii.hbmColor, ii.hbmMask); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1715 | DeleteObject (ii.hbmColor); |
| 1716 | DeleteObject (ii.hbmMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1717 | } |
| 1718 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1719 | DeleteObject (handle); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1720 | |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1721 | return himl; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1722 | } |
| 1723 | |
| 1724 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1725 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1726 | * ImageList_Merge [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1727 | * |
| 1728 | * Creates a new image list that contains a merged image from the specified |
| 1729 | * images of both source image lists. |
| 1730 | * |
| 1731 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1732 | * himl1 [I] handle to first image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1733 | * i1 [I] first image index |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1734 | * himl2 [I] handle to second image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1735 | * i2 [I] second image index |
| 1736 | * dx [I] X offset of the second image relative to the first. |
| 1737 | * dy [I] Y offset of the second image relative to the first. |
| 1738 | * |
| 1739 | * RETURNS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1740 | * Success: handle of the merged image list. |
| 1741 | * Failure: NULL |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1742 | */ |
| 1743 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1744 | HIMAGELIST WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1745 | ImageList_Merge (HIMAGELIST himl1, INT i1, HIMAGELIST himl2, INT i2, |
| 1746 | INT dx, INT dy) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1747 | { |
| 1748 | HIMAGELIST himlDst = NULL; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1749 | HDC hdcSrcImage, hdcDstImage; |
| 1750 | INT cxDst, cyDst; |
| 1751 | INT xOff1, yOff1, xOff2, yOff2; |
| 1752 | INT nX1, nX2; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1753 | |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 1754 | TRACE("(himl1=%p i1=%d himl2=%p i2=%d dx=%d dy=%d)\n", himl1, i1, himl2, |
| 1755 | i2, dx, dy); |
| 1756 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1757 | if ((himl1 == NULL) || (himl2 == NULL)) |
| 1758 | return NULL; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1759 | |
| 1760 | /* check indices */ |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1761 | if ((i1 < 0) || (i1 >= himl1->cCurImage)) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 1762 | ERR("Index 1 out of range! %d\n", i1); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1763 | return NULL; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1764 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1765 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1766 | if ((i2 < 0) || (i2 >= himl2->cCurImage)) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 1767 | ERR("Index 2 out of range! %d\n", i2); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1768 | return NULL; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 1769 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1770 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1771 | if (dx > 0) { |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 1772 | cxDst = max (himl1->cx, dx + himl2->cx); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1773 | xOff1 = 0; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1774 | xOff2 = dx; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1775 | } |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1776 | else if (dx < 0) { |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 1777 | cxDst = max (himl2->cx, himl1->cx - dx); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1778 | xOff1 = -dx; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1779 | xOff2 = 0; |
| 1780 | } |
| 1781 | else { |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 1782 | cxDst = max (himl1->cx, himl2->cx); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1783 | xOff1 = 0; |
| 1784 | xOff2 = 0; |
| 1785 | } |
| 1786 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1787 | if (dy > 0) { |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 1788 | cyDst = max (himl1->cy, dy + himl2->cy); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1789 | yOff1 = 0; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1790 | yOff2 = dy; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1791 | } |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1792 | else if (dy < 0) { |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 1793 | cyDst = max (himl2->cy, himl1->cy - dy); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1794 | yOff1 = -dy; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1795 | yOff2 = 0; |
| 1796 | } |
| 1797 | else { |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 1798 | cyDst = max (himl1->cy, himl2->cy); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1799 | yOff1 = 0; |
| 1800 | yOff2 = 0; |
| 1801 | } |
| 1802 | |
| 1803 | himlDst = ImageList_Create (cxDst, cyDst, ILC_MASK | ILC_COLOR, 1, 1); |
| 1804 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1805 | if (himlDst) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1806 | hdcSrcImage = CreateCompatibleDC (0); |
| 1807 | hdcDstImage = CreateCompatibleDC (0); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1808 | nX1 = i1 * himl1->cx; |
| 1809 | nX2 = i2 * himl2->cx; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1810 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1811 | /* copy image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1812 | SelectObject (hdcSrcImage, himl1->hbmImage); |
| 1813 | SelectObject (hdcDstImage, himlDst->hbmImage); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1814 | BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1815 | hdcSrcImage, 0, 0, BLACKNESS); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1816 | BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1817 | hdcSrcImage, nX1, 0, SRCCOPY); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1818 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1819 | SelectObject (hdcSrcImage, himl2->hbmMask); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1820 | BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1821 | hdcSrcImage, nX2, 0, SRCAND); |
| 1822 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1823 | SelectObject (hdcSrcImage, himl2->hbmImage); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1824 | BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1825 | hdcSrcImage, nX2, 0, SRCPAINT); |
| 1826 | |
| 1827 | /* copy mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1828 | SelectObject (hdcSrcImage, himl1->hbmMask); |
| 1829 | SelectObject (hdcDstImage, himlDst->hbmMask); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1830 | BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1831 | hdcSrcImage, 0, 0, WHITENESS); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1832 | BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1833 | hdcSrcImage, nX1, 0, SRCCOPY); |
| 1834 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1835 | SelectObject (hdcSrcImage, himl2->hbmMask); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1836 | BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1837 | hdcSrcImage, nX2, 0, SRCAND); |
| 1838 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1839 | DeleteDC (hdcSrcImage); |
| 1840 | DeleteDC (hdcDstImage); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 1841 | himlDst->cCurImage = 1; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1842 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1843 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 1844 | return himlDst; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 1845 | } |
| 1846 | |
| 1847 | |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1848 | /* helper for _read_bitmap currently unused */ |
Serge Ivanov | a39cbbc | 2000-02-25 20:47:26 +0000 | [diff] [blame] | 1849 | #if 0 |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1850 | static int may_use_dibsection(HDC hdc) { |
| 1851 | int bitspixel = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES); |
| 1852 | if (bitspixel>8) |
| 1853 | return TRUE; |
| 1854 | if (bitspixel<=4) |
| 1855 | return FALSE; |
Brian Teague | 161bc83 | 2000-11-29 20:02:46 +0000 | [diff] [blame] | 1856 | return GetDeviceCaps(hdc,CAPS1) & C1_DIBENGINE; |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1857 | } |
Serge Ivanov | a39cbbc | 2000-02-25 20:47:26 +0000 | [diff] [blame] | 1858 | #endif |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1859 | |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1860 | /* helper for ImageList_Read, see comments below */ |
| 1861 | static HBITMAP _read_bitmap(LPSTREAM pstm,int ilcFlag,int cx,int cy) { |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1862 | HDC xdc = 0; |
| 1863 | BITMAPFILEHEADER bmfh; |
| 1864 | BITMAPINFOHEADER bmih; |
| 1865 | int bitsperpixel,palspace,longsperline,width,height; |
| 1866 | LPBITMAPINFOHEADER bmihc = NULL; |
| 1867 | int result = 0; |
| 1868 | HBITMAP hbitmap = 0; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1869 | LPBYTE bits = NULL,nbits = NULL; |
| 1870 | int nbytesperline,bytesperline; |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1871 | |
| 1872 | if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) || |
| 1873 | (bmfh.bfType != (('M'<<8)|'B')) || |
| 1874 | !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL)) || |
| 1875 | (bmih.biSize != sizeof(bmih)) |
| 1876 | ) |
| 1877 | return 0; |
| 1878 | |
| 1879 | bitsperpixel = bmih.biPlanes * bmih.biBitCount; |
| 1880 | if (bitsperpixel<=8) |
| 1881 | palspace = (1<<bitsperpixel)*sizeof(RGBQUAD); |
| 1882 | else |
| 1883 | palspace = 0; |
| 1884 | width = bmih.biWidth; |
| 1885 | height = bmih.biHeight; |
| 1886 | bmihc = (LPBITMAPINFOHEADER)LocalAlloc(LMEM_ZEROINIT,sizeof(bmih)+palspace); |
| 1887 | memcpy(bmihc,&bmih,sizeof(bmih)); |
| 1888 | longsperline = ((width*bitsperpixel+31)&~0x1f)>>5; |
| 1889 | bmihc->biSizeImage = (longsperline*height)<<2; |
| 1890 | |
| 1891 | /* read the palette right after the end of the bitmapinfoheader */ |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1892 | if (palspace) |
| 1893 | if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL))) |
| 1894 | goto ret1; |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1895 | |
| 1896 | xdc = GetDC(0); |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1897 | #if 0 /* Magic for NxM -> 1x(N*M) not implemented for DIB Sections */ |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1898 | if ((bitsperpixel>1) && |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1899 | ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc))) |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1900 | ) { |
| 1901 | hbitmap = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0); |
| 1902 | if (!hbitmap) |
| 1903 | goto ret1; |
| 1904 | if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL))) |
| 1905 | goto ret1; |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1906 | result = 1; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1907 | } else |
| 1908 | #endif |
| 1909 | { |
| 1910 | int i,nwidth,nheight; |
| 1911 | |
| 1912 | nwidth = width*(height/cy); |
| 1913 | nheight = cy; |
| 1914 | |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1915 | if (bitsperpixel==1) |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1916 | hbitmap = CreateBitmap(nwidth,nheight,1,1,NULL); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1917 | else |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1918 | hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1919 | |
| 1920 | /* Might be a bit excessive memory use here */ |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1921 | bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); |
| 1922 | nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); |
| 1923 | if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL))) |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1924 | goto ret1; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1925 | |
| 1926 | /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */ |
| 1927 | /* Do not forget that windows bitmaps are bottom->top */ |
| 1928 | bytesperline = longsperline*4; |
| 1929 | nbytesperline = (height/cy)*bytesperline; |
| 1930 | for (i=0;i<height;i++) { |
| 1931 | memcpy( |
Marcus Meissner | bd26e4d | 2000-02-07 16:00:33 +0000 | [diff] [blame] | 1932 | nbits+((height-1-i)%cy)*nbytesperline+(i/cy)*bytesperline, |
| 1933 | bits+bytesperline*(height-1-i), |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1934 | bytesperline |
| 1935 | ); |
| 1936 | } |
| 1937 | bmihc->biWidth = nwidth; |
| 1938 | bmihc->biHeight = nheight; |
| 1939 | if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0)) |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1940 | goto ret1; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1941 | LocalFree((HLOCAL)nbits); |
| 1942 | LocalFree((HLOCAL)bits); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1943 | result = 1; |
| 1944 | } |
| 1945 | ret1: |
| 1946 | if (xdc) ReleaseDC(0,xdc); |
| 1947 | if (bmihc) LocalFree((HLOCAL)bmihc); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1948 | if (!result) { |
| 1949 | if (hbitmap) { |
| 1950 | DeleteObject(hbitmap); |
| 1951 | hbitmap = 0; |
| 1952 | } |
| 1953 | } |
| 1954 | return hbitmap; |
| 1955 | } |
| 1956 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1957 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 1958 | * ImageList_Read [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1959 | * |
| 1960 | * Reads an image list from a stream. |
| 1961 | * |
| 1962 | * PARAMS |
| 1963 | * pstm [I] pointer to a stream |
| 1964 | * |
| 1965 | * RETURNS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 1966 | * Success: handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1967 | * Failure: NULL |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 1968 | * |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1969 | * The format is like this: |
| 1970 | * ILHEAD ilheadstruct; |
| 1971 | * |
| 1972 | * for the color image part: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1973 | * BITMAPFILEHEADER bmfh; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1974 | * BITMAPINFOHEADER bmih; |
| 1975 | * only if it has a palette: |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1976 | * RGBQUAD rgbs[nr_of_paletted_colors]; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1977 | * |
| 1978 | * BYTE colorbits[imagesize]; |
| 1979 | * |
| 1980 | * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags: |
| 1981 | * BITMAPFILEHEADER bmfh_mask; |
| 1982 | * BITMAPINFOHEADER bmih_mask; |
| 1983 | * only if it has a palette (it usually does not): |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1984 | * RGBQUAD rgbs[nr_of_paletted_colors]; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 1985 | * |
| 1986 | * BYTE maskbits[imagesize]; |
| 1987 | * |
| 1988 | * CAVEAT: Those images are within a NxM bitmap, not the 1xN we expect. |
| 1989 | * _read_bitmap needs to convert them. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 1990 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1991 | HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 1992 | { |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1993 | ILHEAD ilHead; |
| 1994 | HIMAGELIST himl; |
| 1995 | HBITMAP hbmColor=0,hbmMask=0; |
| 1996 | int i; |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 1997 | |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 1998 | if (!SUCCEEDED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL))) |
| 1999 | return NULL; |
| 2000 | if (ilHead.usMagic != (('L' << 8) | 'I')) |
| 2001 | return NULL; |
| 2002 | if (ilHead.usVersion != 0x101) /* probably version? */ |
| 2003 | return NULL; |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2004 | |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2005 | #if 0 |
| 2006 | FIXME(" ilHead.cCurImage = %d\n",ilHead.cCurImage); |
| 2007 | FIXME(" ilHead.cMaxImage = %d\n",ilHead.cMaxImage); |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2008 | FIXME(" ilHead.cGrow = %d\n",ilHead.cGrow); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2009 | FIXME(" ilHead.cx = %d\n",ilHead.cx); |
| 2010 | FIXME(" ilHead.cy = %d\n",ilHead.cy); |
| 2011 | FIXME(" ilHead.flags = %x\n",ilHead.flags); |
| 2012 | FIXME(" ilHead.ovls[0] = %d\n",ilHead.ovls[0]); |
| 2013 | FIXME(" ilHead.ovls[1] = %d\n",ilHead.ovls[1]); |
| 2014 | FIXME(" ilHead.ovls[2] = %d\n",ilHead.ovls[2]); |
| 2015 | FIXME(" ilHead.ovls[3] = %d\n",ilHead.ovls[3]); |
| 2016 | #endif |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2017 | |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2018 | hbmColor = _read_bitmap(pstm,ilHead.flags & ~ILC_MASK,ilHead.cx,ilHead.cy); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2019 | if (!hbmColor) |
| 2020 | return NULL; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2021 | if (ilHead.flags & ILC_MASK) { |
| 2022 | hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2023 | if (!hbmMask) { |
| 2024 | DeleteObject(hbmColor); |
| 2025 | return NULL; |
| 2026 | } |
| 2027 | } |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2028 | |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2029 | himl = ImageList_Create ( |
| 2030 | ilHead.cx, |
| 2031 | ilHead.cy, |
| 2032 | ilHead.flags, |
| 2033 | 1, /* initial */ |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2034 | ilHead.cGrow |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2035 | ); |
| 2036 | if (!himl) { |
| 2037 | DeleteObject(hbmColor); |
| 2038 | DeleteObject(hbmMask); |
| 2039 | return NULL; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2040 | } |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2041 | himl->hbmImage = hbmColor; |
| 2042 | himl->hbmMask = hbmMask; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2043 | himl->cCurImage = ilHead.cCurImage; |
| 2044 | himl->cMaxImage = ilHead.cMaxImage; |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2045 | |
| 2046 | ImageList_SetBkColor(himl,ilHead.bkcolor); |
Marcus Meissner | d40170d | 2000-01-29 21:00:25 +0000 | [diff] [blame] | 2047 | for (i=0;i<4;i++) |
| 2048 | ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1); |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2049 | return himl; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2050 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2051 | |
| 2052 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2053 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2054 | * ImageList_Remove [COMCTL32.@] Removes an image from an image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2055 | * |
| 2056 | * PARAMS |
| 2057 | * himl [I] image list handle |
| 2058 | * i [I] image index |
| 2059 | * |
| 2060 | * RETURNS |
| 2061 | * Success: TRUE |
| 2062 | * Failure: FALSE |
| 2063 | */ |
| 2064 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2065 | BOOL WINAPI |
| 2066 | ImageList_Remove (HIMAGELIST himl, INT i) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2067 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2068 | HBITMAP hbmNewImage, hbmNewMask; |
| 2069 | HDC hdcSrc, hdcDst; |
| 2070 | INT cxNew, nCount; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2071 | |
Michael Stefaniuc | 15fc236 | 2002-07-22 20:38:41 +0000 | [diff] [blame] | 2072 | TRACE("(himl=%p i=%d)\n", himl, i); |
| 2073 | |
Andreas Mohr | 641405a | 2001-04-20 18:29:17 +0000 | [diff] [blame] | 2074 | if (himl == NULL) { |
| 2075 | ERR("Invalid image list handle!\n"); |
| 2076 | return FALSE; |
| 2077 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2078 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2079 | if ((i < -1) || (i >= himl->cCurImage)) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2080 | ERR("index out of range! %d\n", i); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2081 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2082 | } |
| 2083 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2084 | if (i == -1) { |
| 2085 | /* remove all */ |
Michael Stefaniuc | 15fc236 | 2002-07-22 20:38:41 +0000 | [diff] [blame] | 2086 | if (himl->cCurImage == 0) { |
| 2087 | /* remove all on empty ImageList is allowed */ |
| 2088 | TRACE("remove all on empty ImageList!\n"); |
| 2089 | return TRUE; |
| 2090 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2091 | |
| 2092 | himl->cMaxImage = himl->cInitial + himl->cGrow; |
| 2093 | himl->cCurImage = 0; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2094 | for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2095 | himl->nOvlIdx[nCount] = -1; |
| 2096 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2097 | DeleteObject (himl->hbmImage); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2098 | himl->hbmImage = |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2099 | CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2100 | 1, himl->uBitsPixel, NULL); |
| 2101 | |
| 2102 | if (himl->hbmMask) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2103 | DeleteObject (himl->hbmMask); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2104 | himl->hbmMask = |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2105 | CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2106 | 1, 1, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2107 | } |
| 2108 | } |
| 2109 | else { |
| 2110 | /* delete one image */ |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2111 | TRACE("Remove single image! %d\n", i); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2112 | |
| 2113 | /* create new bitmap(s) */ |
| 2114 | cxNew = (himl->cCurImage + himl->cGrow - 1) * himl->cx; |
| 2115 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2116 | TRACE(" - Number of images: %d / %d (Old/New)\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2117 | himl->cCurImage, himl->cCurImage - 1); |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2118 | TRACE(" - Max. number of images: %d / %d (Old/New)\n", |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2119 | himl->cMaxImage, himl->cCurImage + himl->cGrow - 1); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2120 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2121 | hbmNewImage = |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2122 | CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2123 | |
| 2124 | if (himl->hbmMask) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2125 | hbmNewMask = CreateBitmap (cxNew, himl->cy, 1, 1, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2126 | else |
| 2127 | hbmNewMask = 0; /* Just to keep compiler happy! */ |
| 2128 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2129 | hdcSrc = CreateCompatibleDC (0); |
| 2130 | hdcDst = CreateCompatibleDC (0); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2131 | |
| 2132 | /* copy all images and masks prior to the "removed" image */ |
| 2133 | if (i > 0) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2134 | TRACE("Pre image copy: Copy %d images\n", i); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2135 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2136 | SelectObject (hdcSrc, himl->hbmImage); |
| 2137 | SelectObject (hdcDst, hbmNewImage); |
| 2138 | BitBlt (hdcDst, 0, 0, i * himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2139 | hdcSrc, 0, 0, SRCCOPY); |
| 2140 | |
| 2141 | if (himl->hbmMask) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2142 | SelectObject (hdcSrc, himl->hbmMask); |
| 2143 | SelectObject (hdcDst, hbmNewMask); |
| 2144 | BitBlt (hdcDst, 0, 0, i * himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2145 | hdcSrc, 0, 0, SRCCOPY); |
| 2146 | } |
| 2147 | } |
| 2148 | |
| 2149 | /* copy all images and masks behind the removed image */ |
| 2150 | if (i < himl->cCurImage - 1) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2151 | TRACE("Post image copy!\n"); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2152 | SelectObject (hdcSrc, himl->hbmImage); |
| 2153 | SelectObject (hdcDst, hbmNewImage); |
| 2154 | BitBlt (hdcDst, i * himl->cx, 0, (himl->cCurImage - i - 1) * himl->cx, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2155 | himl->cy, hdcSrc, (i + 1) * himl->cx, 0, SRCCOPY); |
| 2156 | |
| 2157 | if (himl->hbmMask) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2158 | SelectObject (hdcSrc, himl->hbmMask); |
| 2159 | SelectObject (hdcDst, hbmNewMask); |
| 2160 | BitBlt (hdcDst, i * himl->cx, 0, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2161 | (himl->cCurImage - i - 1) * himl->cx, |
| 2162 | himl->cy, hdcSrc, (i + 1) * himl->cx, 0, SRCCOPY); |
| 2163 | } |
| 2164 | } |
| 2165 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2166 | DeleteDC (hdcSrc); |
| 2167 | DeleteDC (hdcDst); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2168 | |
| 2169 | /* delete old images and insert new ones */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2170 | DeleteObject (himl->hbmImage); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2171 | himl->hbmImage = hbmNewImage; |
| 2172 | if (himl->hbmMask) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2173 | DeleteObject (himl->hbmMask); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2174 | himl->hbmMask = hbmNewMask; |
| 2175 | } |
| 2176 | |
| 2177 | himl->cCurImage--; |
| 2178 | himl->cMaxImage = himl->cCurImage + himl->cGrow; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2179 | } |
| 2180 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2181 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2182 | } |
| 2183 | |
| 2184 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2185 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2186 | * ImageList_Replace [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2187 | * |
| 2188 | * Replaces an image in an image list with a new image. |
| 2189 | * |
| 2190 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2191 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2192 | * i [I] image index |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2193 | * hbmImage [I] handle to image bitmap |
| 2194 | * hbmMask [I] handle to mask bitmap. Can be NULL. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2195 | * |
| 2196 | * RETURNS |
| 2197 | * Success: TRUE |
| 2198 | * Failure: FALSE |
| 2199 | */ |
| 2200 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2201 | BOOL WINAPI |
| 2202 | ImageList_Replace (HIMAGELIST himl, INT i, HBITMAP hbmImage, |
| 2203 | HBITMAP hbmMask) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2204 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2205 | HDC hdcImageList, hdcImage; |
| 2206 | BITMAP bmp; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2207 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 2208 | TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask); |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 2209 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2210 | if (himl == NULL) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2211 | ERR("Invalid image list handle!\n"); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2212 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2213 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2214 | |
Andreas Mohr | d31c1f6 | 2000-08-26 20:28:17 +0000 | [diff] [blame] | 2215 | if ((i >= himl->cMaxImage) || (i < 0)) { |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2216 | ERR("Invalid image index!\n"); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2217 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2218 | } |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2219 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2220 | hdcImageList = CreateCompatibleDC (0); |
| 2221 | hdcImage = CreateCompatibleDC (0); |
| 2222 | GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2223 | |
| 2224 | /* Replace Image */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2225 | SelectObject (hdcImageList, himl->hbmImage); |
| 2226 | SelectObject (hdcImage, hbmImage); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2227 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2228 | StretchBlt (hdcImageList, i * himl->cx, 0, himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2229 | hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2230 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2231 | if (himl->hbmMask) |
| 2232 | { |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2233 | /* Replace Mask */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2234 | SelectObject (hdcImageList, himl->hbmMask); |
| 2235 | SelectObject (hdcImage, hbmMask); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2236 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2237 | StretchBlt (hdcImageList, i * himl->cx, 0, himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2238 | hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); |
Aric Stewart | 031793e | 2000-05-11 21:39:45 +0000 | [diff] [blame] | 2239 | |
| 2240 | |
| 2241 | /* Remove the background from the image |
| 2242 | */ |
| 2243 | SelectObject (hdcImageList, himl->hbmImage); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2244 | StretchBlt (hdcImageList, |
Aric Stewart | 031793e | 2000-05-11 21:39:45 +0000 | [diff] [blame] | 2245 | i*himl->cx, 0, himl->cx, himl->cy, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2246 | hdcImage, |
| 2247 | 0, 0, bmp.bmWidth, bmp.bmHeight, |
Aric Stewart | 031793e | 2000-05-11 21:39:45 +0000 | [diff] [blame] | 2248 | 0x220326); /* NOTSRCAND */ |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2249 | } |
| 2250 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2251 | DeleteDC (hdcImage); |
| 2252 | DeleteDC (hdcImageList); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2253 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2254 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2255 | } |
| 2256 | |
| 2257 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2258 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2259 | * ImageList_ReplaceIcon [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2260 | * |
| 2261 | * Replaces an image in an image list using an icon. |
| 2262 | * |
| 2263 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2264 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2265 | * i [I] image index |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2266 | * hIcon [I] handle to icon |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2267 | * |
| 2268 | * RETURNS |
| 2269 | * Success: index of the replaced image |
| 2270 | * Failure: -1 |
| 2271 | */ |
| 2272 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2273 | INT WINAPI |
| 2274 | ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2275 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2276 | HDC hdcImageList, hdcImage; |
| 2277 | INT nIndex; |
Pierre Mageau | 4ac8db7 | 1999-09-04 11:16:48 +0000 | [diff] [blame] | 2278 | HICON hBestFitIcon; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2279 | HBITMAP hbmOldSrc, hbmOldDst; |
| 2280 | ICONINFO ii; |
| 2281 | BITMAP bmp; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2282 | |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 2283 | TRACE("(0x%lx 0x%x %p)\n", (DWORD)himl, i, hIcon); |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 2284 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2285 | if (himl == NULL) |
| 2286 | return -1; |
Andreas Mohr | d31c1f6 | 2000-08-26 20:28:17 +0000 | [diff] [blame] | 2287 | if ((i >= himl->cMaxImage) || (i < -1)) |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2288 | return -1; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2289 | |
Pierre Mageau | 4ac8db7 | 1999-09-04 11:16:48 +0000 | [diff] [blame] | 2290 | hBestFitIcon = CopyImage( |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2291 | hIcon, IMAGE_ICON, |
| 2292 | himl->cx, himl->cy, |
Pierre Mageau | 4ac8db7 | 1999-09-04 11:16:48 +0000 | [diff] [blame] | 2293 | LR_COPYFROMRESOURCE); |
| 2294 | |
| 2295 | GetIconInfo (hBestFitIcon, &ii); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2296 | if (ii.hbmMask == 0) |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2297 | ERR("no mask!\n"); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2298 | if (ii.hbmColor == 0) |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2299 | ERR("no color!\n"); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2300 | GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2301 | |
| 2302 | if (i == -1) { |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2303 | if (himl->cCurImage + 1 > himl->cMaxImage) |
Gerard Patel | 19cef6c | 2000-07-08 12:48:37 +0000 | [diff] [blame] | 2304 | IMAGELIST_InternalExpandBitmaps (himl, 1, 0, 0); |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 2305 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2306 | nIndex = himl->cCurImage; |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 2307 | himl->cCurImage++; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2308 | } |
| 2309 | else |
| 2310 | nIndex = i; |
| 2311 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2312 | hdcImageList = CreateCompatibleDC (0); |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 2313 | TRACE("hdcImageList=%p!\n", hdcImageList); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2314 | if (hdcImageList == 0) |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2315 | ERR("invalid hdcImageList!\n"); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2316 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2317 | hdcImage = CreateCompatibleDC (0); |
Michael Stefaniuc | 353529b | 2002-10-23 22:19:10 +0000 | [diff] [blame] | 2318 | TRACE("hdcImage=%p!\n", hdcImage); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2319 | if (hdcImage == 0) |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2320 | ERR("invalid hdcImage!\n"); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2321 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2322 | hbmOldDst = SelectObject (hdcImageList, himl->hbmImage); |
| 2323 | SetTextColor( hdcImageList, RGB(0,0,0)); |
| 2324 | SetBkColor( hdcImageList, RGB(255,255,255)); |
| 2325 | hbmOldSrc = SelectObject (hdcImage, ii.hbmColor); |
| 2326 | StretchBlt (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2327 | hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2328 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2329 | if (himl->hbmMask) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2330 | SelectObject (hdcImageList, himl->hbmMask); |
| 2331 | SelectObject (hdcImage, ii.hbmMask); |
| 2332 | StretchBlt (hdcImageList, nIndex * himl->cx, 0, himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2333 | hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY); |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2334 | } |
| 2335 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2336 | SelectObject (hdcImage, hbmOldSrc); |
| 2337 | SelectObject (hdcImageList, hbmOldDst); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2338 | |
Pierre Mageau | 4ac8db7 | 1999-09-04 11:16:48 +0000 | [diff] [blame] | 2339 | if(hBestFitIcon) |
| 2340 | DestroyIcon(hBestFitIcon); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2341 | if (hdcImageList) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2342 | DeleteDC (hdcImageList); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2343 | if (hdcImage) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2344 | DeleteDC (hdcImage); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2345 | if (ii.hbmColor) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2346 | DeleteObject (ii.hbmColor); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 2347 | if (ii.hbmMask) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2348 | DeleteObject (ii.hbmMask); |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2349 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2350 | return nIndex; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2351 | } |
| 2352 | |
| 2353 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2354 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2355 | * ImageList_SetBkColor [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2356 | * |
| 2357 | * Sets the background color of an image list. |
| 2358 | * |
| 2359 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2360 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2361 | * clrBk [I] background color |
| 2362 | * |
| 2363 | * RETURNS |
| 2364 | * Success: previous background color |
| 2365 | * Failure: CLR_NONE |
| 2366 | */ |
| 2367 | |
| 2368 | COLORREF WINAPI |
| 2369 | ImageList_SetBkColor (HIMAGELIST himl, COLORREF clrBk) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2370 | { |
| 2371 | COLORREF clrOldBk; |
| 2372 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2373 | if (himl == NULL) |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2374 | return CLR_NONE; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2375 | |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2376 | clrOldBk = himl->clrBk; |
| 2377 | himl->clrBk = clrBk; |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2378 | return clrOldBk; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2379 | } |
| 2380 | |
| 2381 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2382 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2383 | * ImageList_SetDragCursorImage [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2384 | * |
| 2385 | * Combines the specified image with the current drag image |
| 2386 | * |
| 2387 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2388 | * himlDrag [I] handle to drag image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2389 | * iDrag [I] drag image index |
| 2390 | * dxHotspot [I] X position of the hot spot |
| 2391 | * dyHotspot [I] Y position of the hot spot |
| 2392 | * |
| 2393 | * RETURNS |
| 2394 | * Success: TRUE |
| 2395 | * Failure: FALSE |
| 2396 | * |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2397 | * NOTES |
| 2398 | * When this function is called and the drag image is visible, a |
| 2399 | * short flickering occurs but this matches the Win9x behavior. It is |
| 2400 | * possible to fix the flickering using code like in ImageList_DragMove. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2401 | */ |
| 2402 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2403 | BOOL WINAPI |
| 2404 | ImageList_SetDragCursorImage (HIMAGELIST himlDrag, INT iDrag, |
| 2405 | INT dxHotspot, INT dyHotspot) |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2406 | { |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2407 | HIMAGELIST himlTemp; |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 2408 | INT dx, dy; |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2409 | BOOL visible; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2410 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2411 | if (InternalDrag.himl == NULL) |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2412 | return FALSE; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2413 | |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2414 | TRACE(" dxH=%d dyH=%d nX=%d nY=%d\n", |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2415 | dxHotspot, dyHotspot, InternalDrag.dxHotspot, InternalDrag.dyHotspot); |
| 2416 | |
| 2417 | visible = InternalDrag.bShow; |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2418 | |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 2419 | /* Calculate the offset between the origin of the old image and the |
| 2420 | * origin of the second image. |
| 2421 | * dxHotspot, dyHotspot is the offset of THE Hotspot (there is only one |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2422 | * hotspot) to the origin of the second image. |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 2423 | * See M$DN for details */ |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 2424 | if(InternalDrag.bHSPending) { |
| 2425 | dx = 0; |
| 2426 | dy = 0; |
| 2427 | InternalDrag.bHSPending = FALSE; |
| 2428 | } else { |
| 2429 | dx = InternalDrag.dxHotspot - dxHotspot; |
| 2430 | dy = InternalDrag.dyHotspot - dyHotspot; |
| 2431 | } |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2432 | himlTemp = ImageList_Merge (InternalDrag.himl, 0, himlDrag, iDrag, dx, dy); |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2433 | |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2434 | if (visible) { |
| 2435 | /* hide the drag image */ |
| 2436 | ImageList_DragShowNolock(FALSE); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 2437 | } |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2438 | if ((InternalDrag.himl->cx != himlTemp->cx) || |
| 2439 | (InternalDrag.himl->cy != himlTemp->cy)) { |
| 2440 | /* the size of the drag image changed, invalidate the buffer */ |
| 2441 | DeleteObject(InternalDrag.hbmBg); |
| 2442 | InternalDrag.hbmBg = 0; |
| 2443 | } |
| 2444 | |
| 2445 | ImageList_Destroy (InternalDrag.himl); |
| 2446 | InternalDrag.himl = himlTemp; |
| 2447 | |
| 2448 | /* update the InternalDragOffset, if the origin of the |
| 2449 | * DragImage was changed by ImageList_Merge. */ |
Dave Hawkes | 770a5bf | 2002-02-26 00:33:51 +0000 | [diff] [blame] | 2450 | if (dx <= 0) |
| 2451 | InternalDrag.dxHotspot = dxHotspot; |
| 2452 | if (dy <= 0) |
| 2453 | InternalDrag.dyHotspot = dyHotspot; |
Michael Stefaniuc | 3bc5ffd | 2001-12-19 18:47:14 +0000 | [diff] [blame] | 2454 | |
| 2455 | if (visible) { |
| 2456 | /* show the drag image */ |
| 2457 | ImageList_DragShowNolock(TRUE); |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 2458 | } |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2459 | |
Michael Stefaniuc | caf81dc | 2001-11-30 23:15:00 +0000 | [diff] [blame] | 2460 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2461 | } |
| 2462 | |
| 2463 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2464 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2465 | * ImageList_SetFilter [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2466 | * |
| 2467 | * Sets a filter (or does something completely different)!!??? |
Dimitrie O. Paun | d969605 | 2002-09-06 18:32:46 +0000 | [diff] [blame] | 2468 | * It removes 12 Bytes from the stack (3 Parameters). |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2469 | * |
| 2470 | * PARAMS |
Dimitrie O. Paun | d969605 | 2002-09-06 18:32:46 +0000 | [diff] [blame] | 2471 | * himl [I] SHOULD be a handle to image list |
| 2472 | * i [I] COULD be an index? |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2473 | * dwFilter [I] ??? |
| 2474 | * |
| 2475 | * RETURNS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 2476 | * Success: TRUE ??? |
| 2477 | * Failure: FALSE ??? |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2478 | * |
| 2479 | * BUGS |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 2480 | * This is an UNDOCUMENTED function!!!! |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2481 | * empty stub. |
| 2482 | */ |
| 2483 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2484 | BOOL WINAPI |
| 2485 | ImageList_SetFilter (HIMAGELIST himl, INT i, DWORD dwFilter) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2486 | { |
Dimitrie O. Paun | d969605 | 2002-09-06 18:32:46 +0000 | [diff] [blame] | 2487 | FIXME("(%p 0x%x 0x%lx):empty stub!\n", himl, i, dwFilter); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2488 | |
Alexandre Julliard | 642d313 | 1998-07-12 19:29:36 +0000 | [diff] [blame] | 2489 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2490 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2491 | |
| 2492 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2493 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2494 | * ImageList_SetFlags [COMCTL32.@] |
Huw D M Davies | 1a65a7b | 2002-01-15 20:28:05 +0000 | [diff] [blame] | 2495 | * |
| 2496 | * BUGS |
| 2497 | * Stub. |
| 2498 | */ |
| 2499 | |
| 2500 | DWORD WINAPI |
| 2501 | ImageList_SetFlags(HIMAGELIST himl, DWORD flags) |
| 2502 | { |
| 2503 | FIXME("(%p %08lx):empty stub\n", himl, flags); |
| 2504 | return 0; |
| 2505 | } |
| 2506 | |
| 2507 | |
| 2508 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2509 | * ImageList_SetIconSize [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2510 | * |
| 2511 | * Sets the image size of the bitmap and deletes all images. |
| 2512 | * |
| 2513 | * PARAMS |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2514 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2515 | * cx [I] image width |
| 2516 | * cy [I] image height |
| 2517 | * |
| 2518 | * RETURNS |
| 2519 | * Success: TRUE |
| 2520 | * Failure: FALSE |
| 2521 | */ |
| 2522 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2523 | BOOL WINAPI |
| 2524 | ImageList_SetIconSize (HIMAGELIST himl, INT cx, INT cy) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2525 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2526 | INT nCount; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2527 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2528 | if (!himl) |
| 2529 | return FALSE; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 2530 | |
Andreas Mohr | d31c1f6 | 2000-08-26 20:28:17 +0000 | [diff] [blame] | 2531 | /* remove all images */ |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2532 | himl->cMaxImage = himl->cInitial + himl->cGrow; |
| 2533 | himl->cCurImage = 0; |
| 2534 | himl->cx = cx; |
| 2535 | himl->cy = cy; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2536 | |
| 2537 | /* initialize overlay mask indices */ |
| 2538 | for (nCount = 0; nCount < MAX_OVERLAYIMAGE; nCount++) |
| 2539 | himl->nOvlIdx[nCount] = -1; |
| 2540 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2541 | DeleteObject (himl->hbmImage); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2542 | himl->hbmImage = |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2543 | CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2544 | 1, himl->uBitsPixel, NULL); |
| 2545 | |
| 2546 | if (himl->hbmMask) { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2547 | DeleteObject (himl->hbmMask); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2548 | himl->hbmMask = |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2549 | CreateBitmap (himl->cMaxImage * himl->cx, himl->cy, |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2550 | 1, 1, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2551 | } |
| 2552 | |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2553 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2554 | } |
| 2555 | |
| 2556 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2557 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2558 | * ImageList_SetImageCount [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2559 | * |
| 2560 | * Resizes an image list to the specified number of images. |
| 2561 | * |
| 2562 | * PARAMS |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2563 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2564 | * iImageCount [I] number of images in the image list |
| 2565 | * |
| 2566 | * RETURNS |
| 2567 | * Success: TRUE |
| 2568 | * Failure: FALSE |
| 2569 | */ |
| 2570 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2571 | BOOL WINAPI |
| 2572 | ImageList_SetImageCount (HIMAGELIST himl, INT iImageCount) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2573 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2574 | HDC hdcImageList, hdcBitmap; |
| 2575 | HBITMAP hbmNewBitmap; |
| 2576 | INT nNewCount, nCopyCount; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2577 | |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 2578 | TRACE("%p %d\n",himl,iImageCount); |
| 2579 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2580 | if (!himl) |
| 2581 | return FALSE; |
Pascal Lessard | 60935ec | 1999-03-25 16:42:27 +0000 | [diff] [blame] | 2582 | if (himl->cCurImage >= iImageCount) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2583 | return FALSE; |
| 2584 | if (himl->cMaxImage > iImageCount) |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 2585 | { |
| 2586 | himl->cCurImage = iImageCount; |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2587 | return TRUE; |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 2588 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2589 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 2590 | nNewCount = iImageCount + himl->cGrow; |
Patrik Stridvall | 3566973 | 2001-09-10 23:09:04 +0000 | [diff] [blame] | 2591 | nCopyCount = min(himl->cCurImage, iImageCount); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2592 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2593 | hdcImageList = CreateCompatibleDC (0); |
| 2594 | hdcBitmap = CreateCompatibleDC (0); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2595 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2596 | hbmNewBitmap = CreateBitmap (nNewCount * himl->cx, himl->cy, |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 2597 | 1, himl->uBitsPixel, NULL); |
Francis Beaudet | 64307f3 | 1999-04-01 10:11:23 +0000 | [diff] [blame] | 2598 | if (hbmNewBitmap != 0) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2599 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2600 | SelectObject (hdcImageList, himl->hbmImage); |
| 2601 | SelectObject (hdcBitmap, hbmNewBitmap); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2602 | |
| 2603 | /* copy images */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2604 | BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2605 | hdcImageList, 0, 0, SRCCOPY); |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2606 | #if 0 |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2607 | /* delete 'empty' image space */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2608 | SetBkColor (hdcBitmap, RGB(255, 255, 255)); |
| 2609 | SetTextColor (hdcBitmap, RGB(0, 0, 0)); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2610 | PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2611 | (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2612 | #endif |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2613 | DeleteObject (himl->hbmImage); |
Eric Kohl | 9d8e864 | 1998-10-24 10:49:27 +0000 | [diff] [blame] | 2614 | himl->hbmImage = hbmNewBitmap; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2615 | } |
| 2616 | else |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2617 | ERR("Could not create new image bitmap !\n"); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2618 | |
| 2619 | if (himl->hbmMask) |
| 2620 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2621 | hbmNewBitmap = CreateBitmap (nNewCount * himl->cx, himl->cy, |
Alexandre Julliard | 829fe32 | 1998-07-26 14:27:39 +0000 | [diff] [blame] | 2622 | 1, 1, NULL); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2623 | if (hbmNewBitmap != 0) |
| 2624 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2625 | SelectObject (hdcImageList, himl->hbmMask); |
| 2626 | SelectObject (hdcBitmap, hbmNewBitmap); |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2627 | |
| 2628 | /* copy images */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2629 | BitBlt (hdcBitmap, 0, 0, nCopyCount * himl->cx, himl->cy, |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2630 | hdcImageList, 0, 0, SRCCOPY); |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2631 | #if 0 |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2632 | /* delete 'empty' image space */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2633 | SetBkColor (hdcBitmap, RGB(255, 255, 255)); |
| 2634 | SetTextColor (hdcBitmap, RGB(0, 0, 0)); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2635 | PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, |
Eric Kohl | 978137d | 1998-10-11 13:12:54 +0000 | [diff] [blame] | 2636 | (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); |
Eric Kohl | 69a9359 | 1999-11-23 23:40:01 +0000 | [diff] [blame] | 2637 | #endif |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2638 | DeleteObject (himl->hbmMask); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2639 | himl->hbmMask = hbmNewBitmap; |
| 2640 | } |
| 2641 | else |
Alexandre Julliard | a099a55 | 1999-06-12 15:45:58 +0000 | [diff] [blame] | 2642 | ERR("Could not create new mask bitmap!\n"); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2643 | } |
| 2644 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2645 | DeleteDC (hdcImageList); |
| 2646 | DeleteDC (hdcBitmap); |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2647 | |
Alexandre Julliard | c7c217b | 1998-04-13 12:21:30 +0000 | [diff] [blame] | 2648 | /* Update max image count and current image count */ |
| 2649 | himl->cMaxImage = nNewCount; |
Mike McCormack | 5a6a71f | 2002-08-16 01:35:43 +0000 | [diff] [blame] | 2650 | himl->cCurImage = iImageCount; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2651 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2652 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2653 | } |
| 2654 | |
| 2655 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2656 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2657 | * ImageList_SetOverlayImage [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2658 | * |
| 2659 | * Assigns an overlay mask index to an existing image in an image list. |
| 2660 | * |
| 2661 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2662 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2663 | * iImage [I] image index |
| 2664 | * iOverlay [I] overlay mask index |
| 2665 | * |
| 2666 | * RETURNS |
| 2667 | * Success: TRUE |
| 2668 | * Failure: FALSE |
| 2669 | */ |
| 2670 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2671 | BOOL WINAPI |
| 2672 | ImageList_SetOverlayImage (HIMAGELIST himl, INT iImage, INT iOverlay) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2673 | { |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2674 | if (!himl) |
| 2675 | return FALSE; |
| 2676 | if ((iOverlay < 1) || (iOverlay > MAX_OVERLAYIMAGE)) |
| 2677 | return FALSE; |
Marcus Meissner | 9c978ab | 2000-01-30 22:21:22 +0000 | [diff] [blame] | 2678 | if ((iImage!=-1) && ((iImage < 0) || (iImage > himl->cCurImage))) |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2679 | return FALSE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2680 | himl->nOvlIdx[iOverlay - 1] = iImage; |
Alexandre Julliard | a845b88 | 1998-06-01 10:44:35 +0000 | [diff] [blame] | 2681 | return TRUE; |
Alexandre Julliard | a69b88b | 1998-03-15 20:29:56 +0000 | [diff] [blame] | 2682 | } |
| 2683 | |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2684 | |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2685 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2686 | /* helper for ImageList_Write - write bitmap to pstm |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2687 | * currently everything is written as 24 bit RGB, except masks |
| 2688 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2689 | static BOOL |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2690 | _write_bitmap(HBITMAP hBitmap, LPSTREAM pstm, int cx, int cy) |
| 2691 | { |
| 2692 | LPBITMAPFILEHEADER bmfh; |
| 2693 | LPBITMAPINFOHEADER bmih; |
| 2694 | LPBYTE data, lpBits, lpBitsOrg; |
| 2695 | BITMAP bm; |
| 2696 | INT bitCount, sizeImage, offBits, totalSize; |
| 2697 | INT nwidth, nheight, nsizeImage, icount; |
| 2698 | HDC xdc; |
| 2699 | BOOL result = FALSE; |
| 2700 | |
| 2701 | |
| 2702 | xdc = GetDC(0); |
| 2703 | GetObjectA(hBitmap, sizeof(BITMAP), (LPVOID)&bm); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2704 | |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2705 | /* XXX is this always correct? */ |
| 2706 | icount = bm.bmWidth / cx; |
| 2707 | nwidth = cx << 2; |
| 2708 | nheight = cy * ((icount+3)>>2); |
| 2709 | |
| 2710 | bitCount = bm.bmBitsPixel == 1 ? 1 : 24; |
| 2711 | sizeImage = ((((bm.bmWidth * bitCount)+31) & ~31) >> 3) * bm.bmHeight; |
| 2712 | nsizeImage = ((((nwidth * bitCount)+31) & ~31) >> 3) * nheight; |
| 2713 | |
| 2714 | totalSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); |
| 2715 | if(bitCount != 24) |
| 2716 | totalSize += (1 << bitCount) * sizeof(RGBQUAD); |
| 2717 | offBits = totalSize; |
| 2718 | totalSize += nsizeImage; |
| 2719 | |
| 2720 | data = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, totalSize); |
| 2721 | bmfh = (LPBITMAPFILEHEADER)data; |
| 2722 | bmih = (LPBITMAPINFOHEADER)(data + sizeof(BITMAPFILEHEADER)); |
| 2723 | lpBits = data + offBits; |
| 2724 | |
| 2725 | /* setup BITMAPFILEHEADER */ |
| 2726 | bmfh->bfType = (('M' << 8) | 'B'); |
| 2727 | bmfh->bfSize = 0; |
| 2728 | bmfh->bfReserved1 = 0; |
| 2729 | bmfh->bfReserved2 = 0; |
| 2730 | bmfh->bfOffBits = offBits; |
| 2731 | |
| 2732 | /* setup BITMAPINFOHEADER */ |
| 2733 | bmih->biSize = sizeof(BITMAPINFOHEADER); |
| 2734 | bmih->biWidth = bm.bmWidth; |
| 2735 | bmih->biHeight = bm.bmHeight; |
| 2736 | bmih->biPlanes = 1; |
| 2737 | bmih->biBitCount = bitCount; |
| 2738 | bmih->biCompression = BI_RGB; |
| 2739 | bmih->biSizeImage = nsizeImage; |
| 2740 | bmih->biXPelsPerMeter = 0; |
| 2741 | bmih->biYPelsPerMeter = 0; |
| 2742 | bmih->biClrUsed = 0; |
| 2743 | bmih->biClrImportant = 0; |
| 2744 | |
| 2745 | lpBitsOrg = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, nsizeImage); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2746 | if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg, |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2747 | (BITMAPINFO *)bmih, DIB_RGB_COLORS)) |
| 2748 | goto failed; |
| 2749 | else { |
| 2750 | int i; |
| 2751 | int obpl = (((bm.bmWidth*bitCount+31) & ~31)>>3); |
| 2752 | int nbpl = (((nwidth*bitCount+31) & ~31)>>3); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2753 | |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2754 | for(i = 0; i < nheight; i++) { |
| 2755 | int ooff = ((nheight-1-i)%cy) * obpl + ((i/cy) * nbpl); |
| 2756 | int noff = (nbpl * (nheight-1-i)); |
| 2757 | memcpy(lpBits + noff, lpBitsOrg + ooff, nbpl); |
| 2758 | } |
| 2759 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2760 | |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2761 | bmih->biWidth = nwidth; |
| 2762 | bmih->biHeight = nheight; |
| 2763 | |
| 2764 | if(bitCount == 1) { |
Patrik Stridvall | fc2be7e | 2002-04-29 18:48:56 +0000 | [diff] [blame] | 2765 | /* Hack. */ |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2766 | LPBITMAPINFO inf = (LPBITMAPINFO)bmih; |
| 2767 | inf->bmiColors[0].rgbRed = inf->bmiColors[0].rgbGreen = inf->bmiColors[0].rgbBlue = 0; |
| 2768 | inf->bmiColors[1].rgbRed = inf->bmiColors[1].rgbGreen = inf->bmiColors[1].rgbBlue = 0xff; |
| 2769 | } |
| 2770 | |
| 2771 | if(!SUCCEEDED(IStream_Write(pstm, data, totalSize, NULL))) |
| 2772 | goto failed; |
| 2773 | |
| 2774 | result = TRUE; |
| 2775 | |
| 2776 | failed: |
| 2777 | ReleaseDC(0, xdc); |
| 2778 | LocalFree((HLOCAL)lpBitsOrg); |
| 2779 | |
| 2780 | return result; |
| 2781 | } |
| 2782 | |
| 2783 | |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2784 | /************************************************************************* |
Patrik Stridvall | 4325554 | 2002-08-09 01:07:29 +0000 | [diff] [blame] | 2785 | * ImageList_Write [COMCTL32.@] |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2786 | * |
| 2787 | * Writes an image list to a stream. |
| 2788 | * |
| 2789 | * PARAMS |
Eric Kohl | f280961 | 1998-11-08 11:36:04 +0000 | [diff] [blame] | 2790 | * himl [I] handle to image list |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2791 | * pstm [O] Pointer to a stream. |
| 2792 | * |
| 2793 | * RETURNS |
| 2794 | * Success: TRUE |
| 2795 | * Failure: FALSE |
| 2796 | * |
| 2797 | * BUGS |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2798 | * probably. |
Alexandre Julliard | dadf78f | 1998-05-17 17:13:43 +0000 | [diff] [blame] | 2799 | */ |
| 2800 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2801 | BOOL WINAPI |
| 2802 | ImageList_Write (HIMAGELIST himl, LPSTREAM pstm) |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2803 | { |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2804 | ILHEAD ilHead; |
| 2805 | int i; |
| 2806 | |
Alexandre Julliard | d30dfd2 | 1998-09-27 18:28:36 +0000 | [diff] [blame] | 2807 | if (!himl) |
| 2808 | return FALSE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2809 | |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2810 | ilHead.usMagic = (('L' << 8) | 'I'); |
| 2811 | ilHead.usVersion = 0x101; |
| 2812 | ilHead.cCurImage = himl->cCurImage; |
| 2813 | ilHead.cMaxImage = himl->cMaxImage; |
| 2814 | ilHead.cGrow = himl->cGrow; |
| 2815 | ilHead.cx = himl->cx; |
| 2816 | ilHead.cy = himl->cy; |
| 2817 | ilHead.bkcolor = himl->clrBk; |
| 2818 | ilHead.flags = himl->flags; |
| 2819 | for(i = 0; i < 4; i++) { |
| 2820 | ilHead.ovls[i] = himl->nOvlIdx[i]; |
| 2821 | } |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2822 | |
Charles Loep | 02cbb36 | 2002-01-29 17:12:20 +0000 | [diff] [blame] | 2823 | if(!SUCCEEDED(IStream_Write(pstm, &ilHead, sizeof(ILHEAD), NULL))) |
| 2824 | return FALSE; |
| 2825 | |
| 2826 | /* write the bitmap */ |
| 2827 | if(!_write_bitmap(himl->hbmImage, pstm, himl->cx, himl->cy)) |
| 2828 | return FALSE; |
| 2829 | |
| 2830 | /* write the mask if we have one */ |
| 2831 | if(himl->flags & ILC_MASK) { |
| 2832 | if(!_write_bitmap(himl->hbmMask, pstm, himl->cx, himl->cy)) |
| 2833 | return FALSE; |
| 2834 | } |
| 2835 | |
| 2836 | return TRUE; |
Alexandre Julliard | 54c2711 | 1998-03-29 19:44:57 +0000 | [diff] [blame] | 2837 | } |