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:
parent
9d3845c565
commit
491bc7c751
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue