[4/4] comctl32/listview: Forward WM_ERASEBKGND to parent on CLR_NONE

Nikolay Sivov bunglehead at gmail.com
Sat May 2 18:20:09 CDT 2009


Changelog:
    - Forward WM_ERASEBKGND to parent on CLR_NONE

>From df57e68406b5fe856775c67df0402ad42fc50055 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Sun, 3 May 2009 03:14:44 +0400
Subject: Forward WM_ERASEBKGND to parent on CLR_NONE

---
 dlls/comctl32/listview.c       |    5 +++--
 dlls/comctl32/tests/listview.c |   31 ++++++++++++++++++++++++++++---
 2 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/dlls/comctl32/listview.c b/dlls/comctl32/listview.c
index 52f13cb..1a38dd0 100644
--- a/dlls/comctl32/listview.c
+++ b/dlls/comctl32/listview.c
@@ -36,8 +36,6 @@
  *   -- EN_KILLFOCUS should be handled in WM_COMMAND
  *   -- WM_CREATE: create the icon and small icon image lists at this point only if
  *      the LVS_SHAREIMAGELISTS style is not specified.
- *   -- WM_ERASEBKGND: forward this message to the parent window if the bkgnd
- *      color is CLR_NONE.
  *   -- WM_WINDOWPOSCHANGED: arrange the list items if the current view is icon
  *      or small icon and the LVS_AUTOARRANGE style is specified.
  *   -- WM_TIMER
@@ -8290,6 +8288,9 @@ static inline BOOL LISTVIEW_EraseBkgnd(const LISTVIEW_INFO *infoPtr, HDC hdc)
 
     if (!GetClipBox(hdc, &rc)) return FALSE;
 
+    if (infoPtr->clrBk == CLR_NONE)
+        return SendMessageW(infoPtr->hwndNotify, WM_ERASEBKGND, (WPARAM)hdc, 0);
+
     /* for double buffered controls we need to do this during refresh */
     if (infoPtr->dwLvExStyle & LVS_EX_DOUBLEBUFFER) return FALSE;
 
diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c
index 42bb189..b6cbd47 100644
--- a/dlls/comctl32/tests/listview.c
+++ b/dlls/comctl32/tests/listview.c
@@ -1068,6 +1068,7 @@ static void test_redraw(void)
     HWND hwnd, hwndheader;
     HDC hdc;
     BOOL res;
+    DWORD r;
 
     hwnd = create_listview_control(0);
     hwndheader = subclass_header(hwnd);
@@ -1082,21 +1083,45 @@ static void test_redraw(void)
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
 
     /* forward WM_ERASEBKGND to parent on CLR_NONE background color */
+    /* 1. Without backbuffer */
     res = ListView_SetBkColor(hwnd, CLR_NONE);
     expect(TRUE, res);
 
     hdc = GetWindowDC(hwndparent);
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
-    SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
+    r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
+    ok(r != 0, "Expected not zero result\n");
+    ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
+                "forward WM_ERASEBKGND on CLR_NONE", FALSE);
+
+    res = ListView_SetBkColor(hwnd, CLR_DEFAULT);
+    expect(TRUE, res);
+
+    flush_sequences(sequences, NUM_MSG_SEQUENCES);
+    r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
+    ok(r != 0, "Expected not zero result\n");
+    ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
+                "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
+
+    /* 2. With backbuffer */
+    SendMessageA(hwnd, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_DOUBLEBUFFER,
+                                                     LVS_EX_DOUBLEBUFFER);
+    res = ListView_SetBkColor(hwnd, CLR_NONE);
+    expect(TRUE, res);
+
+    flush_sequences(sequences, NUM_MSG_SEQUENCES);
+    r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
+    ok(r != 0, "Expected not zero result\n");
     ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, forward_erasebkgnd_parent_seq,
-                "forward WM_ERASEBKGND on CLR_NONE", TRUE);
+                "forward WM_ERASEBKGND on CLR_NONE", FALSE);
 
     res = ListView_SetBkColor(hwnd, CLR_DEFAULT);
     expect(TRUE, res);
 
     flush_sequences(sequences, NUM_MSG_SEQUENCES);
-    SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
+    r = SendMessageA(hwnd, WM_ERASEBKGND, (WPARAM)hdc, 0);
+    todo_wine ok(r != 0, "Expected not zero result\n");
     ok_sequence(sequences, PARENT_FULL_SEQ_INDEX, empty_seq,
                 "don't forward WM_ERASEBKGND on non-CLR_NONE", FALSE);
 
-- 
1.5.6.5





More information about the wine-patches mailing list