Nikolay Sivov : comctl32/listview: Fix returning LVHT_ONITEMSTATEICON flag on hittesting.

Alexandre Julliard julliard at winehq.org
Mon May 25 10:06:32 CDT 2009


Module: wine
Branch: master
Commit: ce12717c9e8dfa9831157b699e5af4a133a513e6
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=ce12717c9e8dfa9831157b699e5af4a133a513e6

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Sun May 24 22:39:31 2009 +0400

comctl32/listview: Fix returning LVHT_ONITEMSTATEICON flag on hittesting.

---

 dlls/comctl32/listview.c       |    2 +-
 dlls/comctl32/tests/listview.c |   28 +++++++++++++++++++++++-----
 2 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 75ce291..4d9b261 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -6593,7 +6593,7 @@ static INT LISTVIEW_HitTest(const LISTVIEW_INFO *infoPtr, LPLVHITTESTINFO lpht,
 	lpht->flags |= LVHT_ONITEMICON;
     else if (PtInRect(&rcLabel, opt))
 	lpht->flags |= LVHT_ONITEMLABEL;
-    else if (infoPtr->himlState && STATEIMAGEINDEX(lvItem.state) && PtInRect(&rcState, opt))
+    else if (infoPtr->himlState && PtInRect(&rcState, opt))
 	lpht->flags |= LVHT_ONITEMSTATEICON;
     /* special case for LVS_EX_FULLROWSELECT */
     if (uView == LVS_REPORT && infoPtr->dwLvExStyle & LVS_EX_FULLROWSELECT &&
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index d3e4ee8..cd171cb 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2389,13 +2389,17 @@ static void test_hittest(void)
     y = pos.y + (bounds.bottom - bounds.top) / 2;
     test_lvm_hittest(hwnd, x, y, -1, LVHT_TORIGHT, FALSE, FALSE, __LINE__);
     test_lvm_subitemhittest(hwnd, x, y, 0, 1, LVHT_ONITEMLABEL, TRUE, TRUE, TRUE, __LINE__);
-    /* try with icons */
+    /* try with icons, state icons index is 1 based so at least 2 bitmaps needed */
     himl = ImageList_Create(16, 16, 0, 4, 4);
     ok(himl != NULL, "failed to create imagelist\n");
     hbmp = CreateBitmap(16, 16, 1, 1, NULL);
     ok(hbmp != NULL, "failed to create bitmap\n");
     r = ImageList_Add(himl, hbmp, 0);
     ok(r == 0, "should be zero\n");
+    hbmp = CreateBitmap(16, 16, 1, 1, NULL);
+    ok(hbmp != NULL, "failed to create bitmap\n");
+    r = ImageList_Add(himl, hbmp, 0);
+    ok(r == 1, "should be one\n");
 
     r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)himl);
     ok(r == 0, "should return zero\n");
@@ -2407,10 +2411,24 @@ static void test_hittest(void)
     r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
     expect(TRUE, r);
     /* on state icon */
-    x = pos.x + 8; /* outside column */
+    x = pos.x + 8;
+    y = pos.y + (bounds.bottom - bounds.top) / 2;
+    test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, __LINE__);
+    test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
+
+    /* state icons indices are 1 based, check with valid index */
+    item.mask = LVIF_STATE;
+    item.state = INDEXTOSTATEIMAGEMASK(1);
+    item.stateMask = LVIS_STATEIMAGEMASK;
+    item.iItem = 0;
+    item.iSubItem = 0;
+    r = SendMessage(hwnd, LVM_SETITEM, 0, (LPARAM)&item);
+    expect(TRUE, r);
+    /* on state icon */
+    x = pos.x + 8;
     y = pos.y + (bounds.bottom - bounds.top) / 2;
-    test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, TRUE, __LINE__);
-    test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, TRUE, __LINE__);
+    test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, __LINE__);
+    test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMSTATEICON, FALSE, FALSE, FALSE, __LINE__);
 
     himl2 = (HIMAGELIST)SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_STATE, (LPARAM)NULL);
     ok(himl2 == himl, "should return handle\n");
@@ -2418,7 +2436,7 @@ static void test_hittest(void)
     r = SendMessage(hwnd, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)himl);
     ok(r == 0, "should return zero\n");
     /* on item icon */
-    x = pos.x + 8; /* outside column */
+    x = pos.x + 8;
     y = pos.y + (bounds.bottom - bounds.top) / 2;
     test_lvm_hittest(hwnd, x, y, 0, LVHT_ONITEMICON, FALSE, FALSE, __LINE__);
     test_lvm_subitemhittest(hwnd, x, y, 0, 0, LVHT_ONITEMICON, FALSE, FALSE, FALSE, __LINE__);




More information about the wine-cvs mailing list