comctrl32/toolbar.c: avoid unnecessary redraw on TB_HIDEBUTTON

Aled Hughes winehq at aledhughes.co.uk
Sun Mar 29 17:04:10 CDT 2009


Relates to bugzilla entry 17886.

Changelog:
Prevent unnecessary redrawing of the comctl32 toolbar control when
message TB_HIDEBUTTON is sent and the targeted button is already in the
requested visibility state.


---
  dlls/comctl32/toolbar.c |   11 +++++++----
  1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/dlls/comctl32/toolbar.c b/dlls/comctl32/toolbar.c
index 5ef701d..f5b4879 100644
--- a/dlls/comctl32/toolbar.c
+++ b/dlls/comctl32/toolbar.c
@@ -3718,6 +3718,7 @@ TOOLBAR_HideButton (HWND hwnd, WPARAM wParam,
LPARAM lParam)
  {
      TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd);
      TBUTTON_INFO *btnPtr;
+    BYTE oldState;
      INT nIndex;

      TRACE("\n");
@@ -3727,15 +3728,17 @@ TOOLBAR_HideButton (HWND hwnd, WPARAM wParam,
LPARAM lParam)
  	return FALSE;

      btnPtr = &infoPtr->buttons[nIndex];
+    oldState = btnPtr->fsState;
      if (LOWORD(lParam) == FALSE)
  	btnPtr->fsState &= ~TBSTATE_HIDDEN;
      else
  	btnPtr->fsState |= TBSTATE_HIDDEN;

-    TOOLBAR_LayoutToolbar (hwnd);
-
-    InvalidateRect (hwnd, NULL, TRUE);
-
+    /* Redraw only if state has changed */
+    if (oldState != btnPtr->fsState) {
+        TOOLBAR_LayoutToolbar (hwnd);
+        InvalidateRect (hwnd, NULL, TRUE);
+    }
      return TRUE;
  }



More information about the wine-patches mailing list