CToolBar Flickers
-
Hi All, I am getting Flicker for Toolbar which is Owner Drawn. I am creating a SplitterWnd which has a Form View in Right Side Pane and TreeView in Leftside Pane. There is no flicer in FormView but when i am trying to Disable the Icons in CToolbar for some Condition it is some times Continuosly Flickers i could not understand why this happens. Code ---- void CMainFrame::OnUpdateFileDeleteplans(CCmdUI* pCmdUI) { bool bExecuteSQLWin = false; if(bExecuteSQLWin) pCmdUI->Enable(FALSE); else pCmdUI->Enable(); pCmdUI->Enable(CheckOpenPlans()); --> Here i added with a Function CheckOpenPlans().......>==========// } bool CMainFrame::CheckOpenPlans() { CMDIChildWnd* MyWnd = NULL; MyWnd = MDIGetActive(); CView* pView = NULL; if(MyWnd != NULL) { pView = (CView*) MyWnd->GetActiveView(); if((pView->IsKindOf(RUNTIME_CLASS(CSelectQueryView)) || pView->IsKindOf(RUNTIME_CLASS(OpenPlansTreeView)))) return false; else return true; } return true; }
-
Hi All, I am getting Flicker for Toolbar which is Owner Drawn. I am creating a SplitterWnd which has a Form View in Right Side Pane and TreeView in Leftside Pane. There is no flicer in FormView but when i am trying to Disable the Icons in CToolbar for some Condition it is some times Continuosly Flickers i could not understand why this happens. Code ---- void CMainFrame::OnUpdateFileDeleteplans(CCmdUI* pCmdUI) { bool bExecuteSQLWin = false; if(bExecuteSQLWin) pCmdUI->Enable(FALSE); else pCmdUI->Enable(); pCmdUI->Enable(CheckOpenPlans()); --> Here i added with a Function CheckOpenPlans().......>==========// } bool CMainFrame::CheckOpenPlans() { CMDIChildWnd* MyWnd = NULL; MyWnd = MDIGetActive(); CView* pView = NULL; if(MyWnd != NULL) { pView = (CView*) MyWnd->GetActiveView(); if((pView->IsKindOf(RUNTIME_CLASS(CSelectQueryView)) || pView->IsKindOf(RUNTIME_CLASS(OpenPlansTreeView)))) return false; else return true; } return true; }
The OnUpdateToolbarButton() functions will be called automatically by the MFC rotuing during the OnIdle action of your application. The flicker is probbaly caused by you changing the state of the button(s) multiple times in the same update call. Try and make sure you only have a single call to Enable(). Assign the desired state to a local variable, compute any required changes in the variable and then call pCmdUI->Enable(variable). By the looks of it you may well be getting a call to Enable with false and true sequentially.
If you vote me down, my score will only get lower
-
The OnUpdateToolbarButton() functions will be called automatically by the MFC rotuing during the OnIdle action of your application. The flicker is probbaly caused by you changing the state of the button(s) multiple times in the same update call. Try and make sure you only have a single call to Enable(). Assign the desired state to a local variable, compute any required changes in the variable and then call pCmdUI->Enable(variable). By the looks of it you may well be getting a call to Enable with false and true sequentially.
If you vote me down, my score will only get lower
Hi Roger, Thank You Very Much for giving me a solution. Thanks & Regards, Uday.