diff --git a/dlls/comctl32/tests/treeview.c b/dlls/comctl32/tests/treeview.c index 30911278bab..adc74225b19 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 29db19ae062..bff4b815b3f 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);