Hi,
I have a CFormView with many controls. When I try to resize the view i.e child frame, there is a lot of flickering of all the controls. Can anyone please help to to remove this filckering of controls.
Thanks
Madhavi
Printable View
Hi,
I have a CFormView with many controls. When I try to resize the view i.e child frame, there is a lot of flickering of all the controls. Can anyone please help to to remove this filckering of controls.
Thanks
Madhavi
I hope I'm wrong, but as I know you cannot avoid this.Quote:
Originally Posted by CCC
That's it.
Well, I had done something for dialogs and they might work here as well. Not sure though. First of all you have to set the form's "Clip children" style then, as an advanced feature, try to exlucde the controls from the erase background region of the form.
Here is one way of implementing the OnEraseBkgnd so that the controls on the form do not get erased when the background is redrawn. You will have to populate the id list witht he controls on your form view, but it should work from there:
BOOL CRefinementProView::OnEraseBkgnd(CDC* pDC)
{
CRect clip;
pDC->SaveDC();
static int dont_erase_indexes[] =
{
IDC_TITLE_LABEL,
IDC_TITLE,
IDC_ANALYST_LABEL,
IDC_ANALYST
};
for (int i = 0; i < sizeof(dont_erase_indexes) / sizeof(int); i++)
{
CWnd *pWnd = GetDlgItem(dont_erase_indexes[i]);
if (pWnd && pWnd->IsWindowVisible())
{
pWnd->GetWindowRect(&clip); // get rect of the control
ScreenToClient(&clip);
pDC->ExcludeClipRect(&clip);
}
}
pDC->GetClipBox(&clip);
pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
pDC->RestoreDC(-1);
return FALSE;
}
This is what I used for a flicker problem I had on CFormView. Not sure if this was for my specific sitation or if it might work for you also.
Place in OnIntialUpdate()
Code:ModifyStyle( NULL , WS_CLIPCHILDREN , 0 ); //For flicker free window painting (resizing)
Hi,
Thanks for your help.
I am able to remove flickering now...
Madhavi
I tried these techniques.
This by-passes OnEraseBkgnd:
I still get flicker.Code:void CTRChartFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
...
ModifyStyle( NULL , WS_CLIPCHILDREN , 0 );
...
}
I have a single Picture Control that occupies the entire form view. The image is refreshed in OnSize:
Any ideas?Code:void CChartFormView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
CRect rect(0,0,cx,cy);
if(IsChartInitialized())
{
m_ChartViewer.MoveWindow(&rect, FALSE);
drawChart(&m_ChartViewer);
}
}
Thanks
This does NOT bypass OnEraseBackground. It only tells the view to NOT paint the background of child windows. Since your picture control is the whole client area, it doesn't matter anyway.
Whatever it is that your m_ChartViewer class is derived from, that is probably where you need to put your attention. It's obviously a CWnd at some point so it probaly has a OnPaint override and that is probably where the flicker is coming from.Quote:
I still get flicker.
I have a single Picture Control that occupies the entire form view. The image is refreshed in OnSize:
Any ideas?Code:void CChartFormView::OnSize(UINT nType, int cx, int cy)
{
CFormView::OnSize(nType, cx, cy);
CRect rect(0,0,cx,cy);
if(IsChartInitialized())
{
m_ChartViewer.MoveWindow(&rect, FALSE);
drawChart(&m_ChartViewer);
}
}
Thanks
Thanks for the response. I suspected that might be the issue.
At the beginning of your OnSize handler, call LockWindowUpdate(...), do your sizing and call UnlockWindowUpdate(...) before exiting the OnSize method.
Thanks for the suggestion. It works for the dialog. The image still flickers. I will double buffer the drawing in the ChartViewer class.
Hey...not sure about this.....had watched this long back....
It is for drawing in window. Controls BTW are drawn on to the form. See if that helps.
Just a hint, if the view class in the demo inherits from CScrollView, then instead of inheriting your form view from CSrollView, just inherit it from the view in the tutorial. Seems like a round about way, but keep it as ur last option. Although, double buffering would be a gr8 option if u could get it done....
Regards,
Bhushan