Authors: Chris Morgan <cmorgan@wpi.edu>, James Abbatiello <abbeyj@wpi.edu>

Redraw toolbar button inside TOOLBAR_EnableButton() only if the state
of the button changes.  Stops flickering in toolbars caused by
excessive redrawing.
This commit is contained in:
Alexandre Julliard 2000-04-23 19:56:07 +00:00
parent 9d3845c565
commit 491bc7c751
1 changed files with 16 additions and 7 deletions

View File

@ -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
btnPtr->fsState |= TBSTATE_ENABLED;
hdc = GetDC (hwnd);
TOOLBAR_DrawButton (hwnd, btnPtr, hdc);
ReleaseDC (hwnd, hdc);
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;
}
/* 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;
}