Andrew Eikum : comctl32/listview: Derive subitem rect from listview origin.

Alexandre Julliard julliard at winehq.org
Tue May 18 12:33:00 CDT 2010


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

Author: Andrew Eikum <aeikum at codeweavers.com>
Date:   Tue May 18 10:38:23 2010 -0500

comctl32/listview: Derive subitem rect from listview origin.

---

 dlls/comctl32/listview.c       |    4 +-
 dlls/comctl32/tests/listview.c |   54 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index dcb9207..7395bb3 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -6986,7 +6986,7 @@ static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPR
         }
     }
 
-    if (!LISTVIEW_GetItemPosition(infoPtr, nItem, &Position)) return FALSE;
+    LISTVIEW_GetOrigin(infoPtr, &Position);
 
     if (nColumn < 0 || nColumn >= DPA_GetPtrCount(infoPtr->hdpaColumns)) return FALSE;
 
@@ -7011,7 +7011,7 @@ static BOOL LISTVIEW_GetSubItemRect(const LISTVIEW_INFO *infoPtr, INT nItem, LPR
 	return FALSE;
     }
 
-    OffsetRect(lprc, Position.x - REPORT_MARGINX, Position.y);
+    OffsetRect(lprc, Position.x, Position.y);
     return TRUE;
 }
 
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index ecad7b1..929583d 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -2090,6 +2090,7 @@ static void test_subitem_rect(void)
     DWORD r;
     LVCOLUMN col;
     RECT rect;
+    INT arr[3];
 
     /* test LVM_GETSUBITEMRECT for header */
     hwnd = create_listview_control(LVS_REPORT);
@@ -2181,6 +2182,59 @@ todo_wine
 
     DestroyWindow(hwnd);
 
+    /* test subitem rects after re-arranging columns */
+    hwnd = create_listview_control(LVS_REPORT);
+    ok(hwnd != NULL, "failed to create a listview window\n");
+    memset(&col, 0, sizeof(LVCOLUMN));
+    col.mask = LVCF_WIDTH;
+
+    col.cx = 100;
+    r = -1;
+    r = SendMessage(hwnd, LVM_INSERTCOLUMN, 0, (LPARAM)&col);
+    expect(0, r);
+
+    col.cx = 200;
+    r = -1;
+    r = SendMessage(hwnd, LVM_INSERTCOLUMN, 1, (LPARAM)&col);
+    expect(1, r);
+
+    col.cx = 300;
+    r = -1;
+    r = SendMessage(hwnd, LVM_INSERTCOLUMN, 2, (LPARAM)&col);
+    expect(2, r);
+
+    insert_item(hwnd, 0);
+
+    arr[0] = 1; arr[1] = 0; arr[2] = 2;
+    r = SendMessage(hwnd, LVM_SETCOLUMNORDERARRAY, 3, (LPARAM)arr);
+    expect(TRUE, r);
+
+    rect.left = LVIR_BOUNDS;
+    rect.top  = 0;
+    rect.right = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
+    ok(r != 0, "Expected not-null LRESULT\n");
+    expect(0, rect.left);
+    expect(600, rect.right);
+
+    rect.left = LVIR_BOUNDS;
+    rect.top  = 1;
+    rect.right = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
+    ok(r != 0, "Expected not-null LRESULT\n");
+    expect(0, rect.left);
+    expect(200, rect.right);
+
+    rect.left = LVIR_BOUNDS;
+    rect.top  = 2;
+    rect.right = rect.bottom = -1;
+    r = SendMessage(hwnd, LVM_GETSUBITEMRECT, 0, (LPARAM)&rect);
+    ok(r != 0, "Expected not-null LRESULT\n");
+    expect(300, rect.left);
+    expect(600, rect.right);
+
+    DestroyWindow(hwnd);
+
     /* try it for non LVS_REPORT style */
     hwnd = CreateWindow("SysListView32", "Test", LVS_ICON, 0, 0, 100, 100, NULL, NULL,
                          GetModuleHandle(NULL), 0);




More information about the wine-cvs mailing list