Nikolay Sivov : comctl32/treeview: Erase background on WM_PAINT if BeginPaint() tells us to do it.

Alexandre Julliard julliard at winehq.org
Mon Oct 19 09:56:10 CDT 2009


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

Author: Nikolay Sivov <bunglehead at gmail.com>
Date:   Sat Oct 17 17:23:43 2009 +0400

comctl32/treeview: Erase background on WM_PAINT if BeginPaint() tells us to do it.

---

 dlls/comctl32/tests/treeview.c |   12 ++++++++
 dlls/comctl32/treeview.c       |   59 ++++++++++++++++++++++++++++++---------
 2 files changed, 57 insertions(+), 14 deletions(-)

diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c
index 3091127..adc7422 100644
--- a/dlls/comctl32/tests/treeview.c
+++ b/dlls/comctl32/tests/treeview.c
@@ -928,6 +928,17 @@ static void test_itemedit(void)
     DestroyWindow(hTree);
 }
 
+static void test_treeview_classinfo(void)
+{
+    WNDCLASSA cls;
+
+    memset(&cls, 0, sizeof(cls));
+    GetClassInfo(GetModuleHandleA("comctl32.dll"), WC_TREEVIEWA, &cls);
+    ok(cls.hbrBackground == NULL, "Expected NULL background brush, got %p\n", cls.hbrBackground);
+    ok(cls.style == (CS_GLOBALCLASS | CS_DBLCLKS), "Expected got %x\n", cls.style);
+    expect(0, cls.cbClsExtra);
+}
+
 START_TEST(treeview)
 {
     HMODULE hComctl32;
@@ -976,6 +987,7 @@ START_TEST(treeview)
     test_callback();
     test_expandinvisible();
     test_itemedit();
+    test_treeview_classinfo();
 
     PostMessageA(hMainWnd, WM_CLOSE, 0, 0);
     while(GetMessageA(&msg,0,0,0)) {
diff --git a/dlls/comctl32/treeview.c b/dlls/comctl32/treeview.c
index 29db19a..bff4b81 100644
--- a/dlls/comctl32/treeview.c
+++ b/dlls/comctl32/treeview.c
@@ -2788,19 +2788,27 @@ TREEVIEW_UpdateScrollBars(TREEVIEW_INFO *infoPtr)
 	infoPtr->uInternalStatus &= ~TV_HSCROLL;
 }
 
-/* CtrlSpy doesn't mention this, but CorelDRAW's object manager needs it. */
-static LRESULT
-TREEVIEW_EraseBackground(const TREEVIEW_INFO *infoPtr, HDC hDC)
+static void
+TREEVIEW_FillBkgnd(const TREEVIEW_INFO *infoPtr, HDC hdc, const RECT *rc)
 {
     HBRUSH hBrush;
     COLORREF clrBk = infoPtr->clrBk == -1 ? comctl32_color.clrWindow:
                                             infoPtr->clrBk;
+    hBrush =  CreateSolidBrush(clrBk);
+    FillRect(hdc, rc, hBrush);
+    DeleteObject(hBrush);
+}
+
+/* CtrlSpy doesn't mention this, but CorelDRAW's object manager needs it. */
+static LRESULT
+TREEVIEW_EraseBackground(const TREEVIEW_INFO *infoPtr, HDC hdc)
+{
     RECT rect;
 
-    hBrush =  CreateSolidBrush(clrBk);
+    TRACE("%p\n", infoPtr);
+
     GetClientRect(infoPtr->hwnd, &rect);
-    FillRect(hDC, &rect, hBrush);
-    DeleteObject(hBrush);
+    TREEVIEW_FillBkgnd(infoPtr, hdc, &rect);
 
     return 1;
 }
@@ -2860,7 +2868,7 @@ TREEVIEW_Invalidate(const TREEVIEW_INFO *infoPtr, const TREEVIEW_ITEM *item)
 }
 
 static LRESULT
-TREEVIEW_Paint(TREEVIEW_INFO *infoPtr, WPARAM wParam)
+TREEVIEW_Paint(TREEVIEW_INFO *infoPtr, HDC hdc_ref)
 {
     HDC hdc;
     PAINTSTRUCT ps;
@@ -2868,27 +2876,48 @@ TREEVIEW_Paint(TREEVIEW_INFO *infoPtr, WPARAM wParam)
 
     TRACE("\n");
 
-    if (wParam)
+    if (hdc_ref)
     {
-        hdc = (HDC)wParam;
-        GetClientRect(infoPtr->hwnd, &rc);        
-        TREEVIEW_EraseBackground(infoPtr, hdc);
+        hdc = hdc_ref;
+        GetClientRect(infoPtr->hwnd, &rc);
     }
     else
     {
         hdc = BeginPaint(infoPtr->hwnd, &ps);
-        rc = ps.rcPaint;
+        rc  = ps.rcPaint;
+        if(ps.fErase)
+            TREEVIEW_FillBkgnd(infoPtr, hdc, &rc);
     }
 
     if(infoPtr->bRedraw) /* WM_SETREDRAW sets bRedraw */
         TREEVIEW_Refresh(infoPtr, hdc, &rc);
 
-    if (!wParam)
+    if (!hdc_ref)
 	EndPaint(infoPtr->hwnd, &ps);
 
     return 0;
 }
 
+static LRESULT
+TREEVIEW_PrintClient(TREEVIEW_INFO *infoPtr, HDC hdc, DWORD options)
+{
+    FIXME("Partial Stub: (hdc=%p options=0x%08x)\n", hdc, options);
+
+    if ((options & PRF_CHECKVISIBLE) && !IsWindowVisible(infoPtr->hwnd))
+        return 0;
+
+    if (options & PRF_ERASEBKGND)
+        TREEVIEW_EraseBackground(infoPtr, hdc);
+
+    if (options & PRF_CLIENT)
+    {
+        RECT rc;
+        GetClientRect(infoPtr->hwnd, &rc);
+        TREEVIEW_Refresh(infoPtr, hdc, &rc);
+    }
+
+    return 0;
+}
 
 /* Sorting **************************************************************/
 
@@ -5707,8 +5736,10 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 	return TREEVIEW_NotifyFormat(infoPtr, (HWND)wParam, (UINT)lParam);
 
     case WM_PRINTCLIENT:
+        return TREEVIEW_PrintClient(infoPtr, (HDC)wParam, lParam);
+
     case WM_PAINT:
-	return TREEVIEW_Paint(infoPtr, wParam);
+	return TREEVIEW_Paint(infoPtr, (HDC)wParam);
 
     case WM_RBUTTONDOWN:
 	return TREEVIEW_RButtonDown(infoPtr, lParam);




More information about the wine-cvs mailing list