I have a toolbar being displayed on the top of scroll view. When I call invalidate on scroll view, I realize both toolbar and scroll view are having screen flickering problem.
I try to have a workaround, by overriding their erase background event handler.
This method works for scroll view, but not the toolbar.
Here is my code snippet.
void MyCScrollView::OnInitialUpdate() {
CScrollView::OnInitialUpdate();
// ToolBar is NonFlickeringCToolBar, inherited from CToolBar
ToolBar.Create(this);
ToolBar.LoadToolBar(IDR_TOOLBAR);
ToolBar.ShowWindow(SW_SHOW);
ToolBar.SetBarStyle(CBRS_ALIGN_TOP | CBRS_SIZE_FIXED);
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0);
}
BOOL MyCScrollView::OnEraseBkgnd(CDC* pDC)
{
// Override to prevent screen flickering. Works!
return TRUE;
}
BOOL NonFlickeringCToolBar::OnEraseBkgnd(CDC* pDC) {
// Override to prevent screen flickering. Doesn't work!
return TRUE;
}
Here is the screen shoot before I override the erase background event handler.
Here is the screen shoot after I override the erase background event handler. Not that, toolbar still keep flickering, with additional problem : its solid background gone till I swing my mouse cursor over its body.
I wish
- Make scroll view and toolbar both non-flickering
- Solid background for toolbar still there
Anything I had missed out?