描述:
用ATL做的一个控件,每次改变一次属性就要刷新一次(FireViewChange)。但是有个属性改变得很频繁,这样就导致控件狂闪。能不能在改变属性的时候只重绘控件的一部分而不影响其他啊?
解决方案1:
同意: I_Love_CPP(我爱C++)
BOOL InvalidateRect(
LPCRECT lpRect,
BOOL bErase = TRUE);
CWnd::SetRedraw
void SetRedraw( BOOL bRedraw = TRUE );
Parameters
bRedraw
Specifies the state of the redraw flag. If this parameter is TRUE, the redraw flag is set; if FALSE, the flag is cleared.
Remarks
An application calls SetRedraw to allow changes to be redrawn or to prevent changes from being redrawn.
This member function sets or clears the redraw flag. While the redraw flag is cleared, the contents will not be updated after each change and will not be repainted until the redraw flag is set. For example, an application that needs to add several items to a list box can clear the redraw flag, add the items, and then set the redraw flag. Finally, the application can call the Invalidate or InvalidateRect member function to cause the list box to be repainted.
This method invalidates the client area within the specified rectangle.
BOOL InvalidateRect(
LPCRECT lpRect,
BOOL bErase = TRUE);