Tests how the rects for the listviews header should be refreshed during painting.
-- v3: comctl32/listview: Force a header rect cache update in LVM_SUBITEMHITTEST. comctl32/tests: Add test for header item rect caching in LVS_REPORT listview during paint.
From: Jacob Czekalla jczekalla@codeweavers.com
Tests how the rects for the listviews header should be refreshed during painting. --- dlls/comctl32/tests/listview.c | 54 ++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+)
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index b767106e97a..1020f28b092 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -7489,6 +7489,59 @@ static void test_LVM_GETHOTCURSOR(void) DestroyWindow(hwnd); }
+static void test_column_rect_caching(void) +{ + HWND listview, header; + LVCOLUMNA column = { 0 }; + LVITEMA item = { 0 }; + char a_text[] = "A", b_text[] = "B"; + int order[2] = { 1, 0 }; + RECT listview_rect; + POINT pt; + LVHITTESTINFO hit_info = { 0 }; + + listview = create_listview_control(LVS_REPORT); + subclass_header(listview); + header = (HWND)SendMessageA(listview, LVM_GETHEADER, 0, 0); + + column.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; + column.cx = 50; + column.pszText = a_text; + column.iSubItem = 0; + SendMessageA(listview, LVM_INSERTCOLUMNA, 0, (LPARAM)&column); + column.cx = 50; + column.pszText = b_text; + column.iSubItem = 1; + SendMessageA(listview, LVM_INSERTCOLUMNA, 1, (LPARAM)&column); + + item.mask = LVIF_TEXT; + item.iItem = 0; + item.pszText = a_text; + SendMessageA(listview, LVM_INSERTITEMA, 0, (LPARAM)&item); + item.iSubItem = 1; + item.iItem = 0; + item.pszText = b_text; + SendMessageA(listview, LVM_SETITEMTEXTA, 0, (LPARAM)&item); + + listview_rect.left = LVIR_LABEL; + SendMessageA(listview, LVM_GETITEMRECT, 0, (LPARAM)&listview_rect); + pt.x = listview_rect.left + 5; + pt.y = listview_rect.top + 5; + hit_info.pt = pt; + SendMessageA(listview, LVM_SUBITEMHITTEST, 0, (LPARAM)&hit_info); + ok(hit_info.iSubItem == 0, "expected 0, but got %d\n", hit_info.iSubItem); + + SendMessageA(header, HDM_SETORDERARRAY, 2, (LPARAM)&order); + + ZeroMemory(&hit_info, sizeof(hit_info)); + hit_info.pt = pt; + SendMessageA(listview, LVM_SUBITEMHITTEST, 0, (LPARAM)&hit_info); + todo_wine + ok(hit_info.iSubItem == 1, "expected 1, but got %d\n", hit_info.iSubItem); + + DestroyWindow(listview); +} + START_TEST(listview) { ULONG_PTR ctx_cookie; @@ -7559,6 +7612,7 @@ START_TEST(listview) test_custom_sort(); test_LVM_GETNEXTITEM(); test_LVM_GETHOTCURSOR(); + test_column_rect_caching();
if (!load_v6_module(&ctx_cookie, &hCtx)) {
From: Jacob Czekalla jczekalla@codeweavers.com
The cached header rects need to be updated otherwise hittest will return wrong subitem. --- dlls/comctl32/listview.c | 1 + dlls/comctl32/tests/listview.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-)
diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c index 31f8a933e56..43701ccc729 100644 --- a/dlls/comctl32/listview.c +++ b/dlls/comctl32/listview.c @@ -7654,6 +7654,7 @@ static INT LISTVIEW_HitTest(const LISTVIEW_INFO *infoPtr, LPLVHITTESTINFO lpht, /* set whole list relation flags */ if (subitem && infoPtr->uView == LV_VIEW_DETAILS) { + ((LISTVIEW_INFO *)infoPtr)->colRectsDirty = TRUE; /* LVM_SUBITEMHITTEST checks left bound of possible client area */ if (infoPtr->rcList.left > lpht->pt.x && Origin.x < lpht->pt.x) lpht->flags |= LVHT_TOLEFT; diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 1020f28b092..61f8ee1ee58 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -7536,7 +7536,6 @@ static void test_column_rect_caching(void) ZeroMemory(&hit_info, sizeof(hit_info)); hit_info.pt = pt; SendMessageA(listview, LVM_SUBITEMHITTEST, 0, (LPARAM)&hit_info); - todo_wine ok(hit_info.iSubItem == 1, "expected 1, but got %d\n", hit_info.iSubItem);
DestroyWindow(listview);
I am going to split this into two different merge requests, one to fix the subitemhit test and another to fix the painting. I will close this one.
This merge request was closed by Jacob Czekalla.