comctl32: Fix a potential regression in ImageList_ReplaceIcon().
authorMike McCormack <mike@codeweavers.com>
Tue, 14 Nov 2006 07:48:29 +0000 (16:48 +0900)
committerAlexandre Julliard <julliard@winehq.org>
Tue, 14 Nov 2006 10:35:24 +0000 (11:35 +0100)
dlls/comctl32/imagelist.c

index b626584..17b267d 100644 (file)
@@ -2253,6 +2253,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
     BITMAP  bmp;
     BOOL    ret;
     POINT   pt;
+    INT     i;
 
     TRACE("(%p %d %p)\n", himl, i, hIcon);
 
@@ -2317,14 +2318,17 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
     SetBkColor  (himl->hdcImage, RGB(255,255,255));
     hbmOldSrc = SelectObject (hdcImage, ii.hbmColor);
 
-    imagelist_point_from_index(himl, nIndex, &pt);
-    StretchBlt (himl->hdcImage, pt.x, pt.y, himl->cx, himl->cy,
-                  hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
+    for (i=0; i<(bmp.bmWidth/himl->cx); i++) {
 
-    if (himl->hbmMask) {
-        SelectObject (hdcImage, ii.hbmMask);
-        StretchBlt   (himl->hdcMask, pt.x, pt.y, himl->cx, himl->cy,
-                      hdcImage, 0, 0, bmp.bmWidth, bmp.bmHeight, SRCCOPY);
+        imagelist_point_from_index(himl, nIndex+i, &pt);
+        StretchBlt (himl->hdcImage, pt.x, pt.y, himl->cx, himl->cy,
+                      hdcImage, 0, 0, himl->cx*i, bmp.bmHeight, SRCCOPY);
+
+        if (himl->hbmMask) {
+            SelectObject (hdcImage, ii.hbmMask);
+            StretchBlt   (himl->hdcMask, pt.x, pt.y, himl->cx, himl->cy,
+                          hdcImage, 0, 0, himl->cx*i, bmp.bmHeight, SRCCOPY);
+        }
     }
 
     SelectObject (hdcImage, hbmOldSrc);