From 491bc7c7515261509dffcfd0df3501a7e3676ab8 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Sun, 23 Apr 2000 19:56:07 +0000 Subject: [PATCH] Authors: Chris Morgan , James Abbatiello Redraw toolbar button inside TOOLBAR_EnableButton() only if the state of the button changes. Stops flickering in toolbars caused by excessive redrawing. --- dlls/comctl32/toolbar.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c index ae308b8a95a..19ad494b898 100644 --- a/dlls/comctl32/toolbar.c +++ b/dlls/comctl32/toolbar.c @@ -1566,20 +1566,29 @@ TOOLBAR_EnableButton (HWND hwnd, WPARAM wParam, LPARAM lParam) TBUTTON_INFO *btnPtr; HDC hdc; INT nIndex; + DWORD bState; nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam); if (nIndex == -1) return FALSE; btnPtr = &infoPtr->buttons[nIndex]; - if (LOWORD(lParam) == FALSE) - btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); - else + + bState = btnPtr->fsState & TBSTATE_ENABLED; + + /* update the toolbar button state */ + if(LOWORD(lParam) == FALSE) { + btnPtr->fsState &= ~(TBSTATE_ENABLED | TBSTATE_PRESSED); + } else { btnPtr->fsState |= TBSTATE_ENABLED; + } - hdc = GetDC (hwnd); - TOOLBAR_DrawButton (hwnd, btnPtr, hdc); - ReleaseDC (hwnd, hdc); + /* redraw the button only if the state of the button changed */ + if(bState != (btnPtr->fsState & TBSTATE_ENABLED)) { + hdc = GetDC (hwnd); + TOOLBAR_DrawButton (hwnd, btnPtr, hdc); + ReleaseDC (hwnd, hdc); + } return TRUE; } -- 2.11.4.GIT