From f2fe6f1c2037fb5a99693dd45dbe8d57f582b693 Mon Sep 17 00:00:00 2001 From: =?utf-8?q?Miko=C5=82aj_Zalewski?= Date: Tue, 26 Feb 2008 21:35:15 +0100 Subject: [PATCH] comctl32: rebar: add RBS_AUTOSIZE support (fixes bug #10239) --- dlls/comctl32/rebar.c | 41 +++++++++++++++++++++++++---------------- 1 files changed, 25 insertions(+), 16 deletions(-) diff --git a/dlls/comctl32/rebar.c b/dlls/comctl32/rebar.c index a5c270e..883bddc 100644 --- a/dlls/comctl32/rebar.c +++ b/dlls/comctl32/rebar.c @@ -33,7 +33,6 @@ * - RBS_FIXEDORDER * - RBS_REGISTERDROP * - RBS_TOOLTIPS - * - RBS_AUTOSIZE * Messages: * - RB_BEGINDRAG * - RB_DRAGMOVE @@ -255,7 +254,7 @@ typedef struct #define REBAR_GetInfoPtr(wndPtr) ((REBAR_INFO *)GetWindowLongPtrW (hwnd, 0)) static LRESULT REBAR_NotifyFormat(REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam); - +static void REBAR_AutoSize(REBAR_INFO *infoPtr, BOOL needsLayout); /* "constant values" retrieved when DLL was initialized */ /* FIXME we do this when the classes are registered. */ @@ -1389,6 +1388,7 @@ REBAR_Layout(REBAR_INFO *infoPtr, const RECT *lpRect) { NMHDR heightchange; REBAR_Notify(&heightchange, infoPtr, RBN_HEIGHTCHANGE); + REBAR_AutoSize(infoPtr, FALSE); } } @@ -1495,6 +1495,24 @@ REBAR_SizeToHeight(REBAR_INFO *infoPtr, int height) REBAR_Layout(infoPtr, NULL); } +static VOID +REBAR_AutoSize(REBAR_INFO *infoPtr, BOOL needsLayout) +{ + RECT rc, rcNew; + NMRBAUTOSIZE autosize; + + GetClientRect(infoPtr->hwndSelf, &rc); + if (needsLayout) + REBAR_Layout(infoPtr, NULL); + REBAR_SizeToHeight(infoPtr, get_rect_cy(infoPtr, &rc)); + GetClientRect(infoPtr->hwndSelf, &rcNew); + + GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget); + autosize.fChanged = (memcmp(&rc, &rcNew, sizeof(RECT)) == 0); + autosize.rcTarget = rc; + autosize.rcActual = rcNew; + REBAR_Notify((NMHDR *)&autosize, infoPtr, RBN_AUTOSIZE); +} static VOID REBAR_ValidateBand (const REBAR_INFO *infoPtr, REBAR_BAND *lpBand) @@ -3398,7 +3416,7 @@ REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { TRACE("wParam=%lx, lParam=%lx\n", wParam, lParam); - /* avoid auto resize infinite recursion */ + /* avoid _Layout resize recursion (but it shouldn't be infinite and it seems Windows does recurse) */ if (infoPtr->fStatus & AUTO_RESIZE) { infoPtr->fStatus &= ~AUTO_RESIZE; TRACE("AUTO_RESIZE was set, reset, fStatus=%08x lparam=%08lx\n", @@ -3406,19 +3424,10 @@ REBAR_Size (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) return 0; } - /* FIXME: wrong */ - if (infoPtr->dwStyle & RBS_AUTOSIZE) { - NMRBAUTOSIZE autosize; - - GetClientRect(infoPtr->hwndSelf, &autosize.rcTarget); - autosize.fChanged = 0; /* ??? */ - autosize.rcActual = autosize.rcTarget; /* ??? */ - REBAR_Notify((NMHDR *) &autosize, infoPtr, RBN_AUTOSIZE); - TRACE("RBN_AUTOSIZE client=(%d,%d), lp=%08lx\n", - autosize.rcTarget.right, autosize.rcTarget.bottom, lParam); - } - - REBAR_Layout(infoPtr, NULL); + if (infoPtr->dwStyle & RBS_AUTOSIZE) + REBAR_AutoSize(infoPtr, TRUE); + else + REBAR_Layout(infoPtr, NULL); return 0; } -- 1.4.4.2