[PATCH 1/3] comctl32: Correctly handle the ImageList index in BeginDrag().

Michael Stefaniuc mstefani at redhat.de
Mon Oct 6 17:59:32 CDT 2014


Fixes bug https://bugs.winehq.org/show_bug.cgi?id=36761
---
 dlls/comctl32/imagelist.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/imagelist.c b/dlls/comctl32/imagelist.c
index 645068d..3b11e89 100644
--- a/dlls/comctl32/imagelist.c
+++ b/dlls/comctl32/imagelist.c
@@ -599,6 +599,7 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
 	             INT dxHotspot, INT dyHotspot)
 {
     INT cx, cy;
+    POINT src, dst;
 
     TRACE("(himlTrack=%p iTrack=%d dx=%d dy=%d)\n", himlTrack, iTrack,
 	  dxHotspot, dyHotspot);
@@ -606,6 +607,9 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
     if (!is_valid(himlTrack))
 	return FALSE;
 
+    if (iTrack >= himlTrack->cCurImage)
+        return FALSE;
+
     if (InternalDrag.himl)
         ImageList_EndDrag ();
 
@@ -622,10 +626,12 @@ ImageList_BeginDrag (HIMAGELIST himlTrack, INT iTrack,
     InternalDrag.dyHotspot = dyHotspot;
 
     /* copy image */
-    BitBlt (InternalDrag.himl->hdcImage, 0, 0, cx, cy, himlTrack->hdcImage, iTrack * cx, 0, SRCCOPY);
-
-    /* copy mask */
-    BitBlt (InternalDrag.himl->hdcMask, 0, 0, cx, cy, himlTrack->hdcMask, iTrack * cx, 0, SRCCOPY);
+    imagelist_point_from_index(InternalDrag.himl, 0, &dst);
+    imagelist_point_from_index(himlTrack, iTrack, &src);
+    BitBlt(InternalDrag.himl->hdcImage, dst.x, dst.y, cx, cy, himlTrack->hdcImage, src.x, src.y,
+            SRCCOPY);
+    BitBlt(InternalDrag.himl->hdcMask, dst.x, dst.y, cx, cy, himlTrack->hdcMask, src.x, src.y,
+            SRCCOPY);
 
     InternalDrag.himl->cCurImage = 1;
 
-- 
1.8.3.1



More information about the wine-patches mailing list