-
October 1st, 2004, 06:06 AM
#1
How to avoid flickering of controls on CFormview
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
-
October 1st, 2004, 06:34 AM
#2
Re: How to avoid flickering of controls on CFormview
Originally Posted by CCC
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.
That's it.
-
October 1st, 2004, 07:04 AM
#3
Re: How to avoid flickering of controls on CFormview
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.
Har Har
-
October 1st, 2004, 10:48 AM
#4
Re: How to avoid flickering of controls on CFormview
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;
}
Please use meaningful question titles - "Help me" does not let me know whether I can help with your question, and I am unlikely to bother reading it.
Please remember to rate useful answers. It lets us know when a question has been answered.
-
October 1st, 2004, 12:04 PM
#5
Re: How to avoid flickering of controls on CFormview
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)
-
October 4th, 2004, 12:37 AM
#6
Re: How to avoid flickering of controls on CFormview
Hi,
Thanks for your help.
I am able to remove flickering now...
Madhavi
-
September 14th, 2009, 04:19 AM
#7
Re: How to avoid flickering of controls on CFormview
I tried these techniques.
This by-passes OnEraseBkgnd:
Code:
void CTRChartFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
...
ModifyStyle( NULL , WS_CLIPCHILDREN , 0 );
...
}
I still get flicker.
I have a single Picture Control that occupies the entire form view. The image is refreshed in OnSize:
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);
}
}
Any ideas?
Thanks
Last edited by CCmdTarget; September 14th, 2009 at 04:25 AM.
-
September 14th, 2009, 07:58 AM
#8
Re: How to avoid flickering of controls on CFormview
Originally Posted by CCmdTarget
I tried these techniques.
This by-passes OnEraseBkgnd:
Code:
void CTRChartFormView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
...
ModifyStyle( NULL , WS_CLIPCHILDREN , 0 );
...
}
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.
I still get flicker.
I have a single Picture Control that occupies the entire form view. The image is refreshed in OnSize:
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);
}
}
Any ideas?
Thanks
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.
-
September 14th, 2009, 08:36 AM
#9
Re: How to avoid flickering of controls on CFormview
Thanks for the response. I suspected that might be the issue.
-
September 14th, 2009, 12:34 PM
#10
Re: How to avoid flickering of controls on CFormview
At the beginning of your OnSize handler, call LockWindowUpdate(...), do your sizing and call UnlockWindowUpdate(...) before exiting the OnSize method.
-
September 15th, 2009, 10:40 AM
#11
Re: How to avoid flickering of controls on CFormview
Thanks for the suggestion. It works for the dialog. The image still flickers. I will double buffer the drawing in the ChartViewer class.
-
September 18th, 2009, 06:48 AM
#12
Re: How to avoid flickering of controls on CFormview
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|