Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 317
  • Last Modified:

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
0
likhita
Asked:
likhita
1 Solution
 
Amritpal SinghCommented:
call the following api from InitInstance

SystemParametersInfo(SPI_SETDRAGFULLWINDOWS, false, NULL, 0);

for more info visit the link
http://www.esri.com/devsupport/devconn/mapobjects/techdocs/tutorials/mfc/cguide21.htm
0
 
KurtVonCommented:
I found you can minimize flickering by overriding OnSize in the form view and adding

if (m_bInitialized)
{
    SetRedraw(FALSE);
    CFormView::OnSize(nType, cx, cy);
    SetRedraw(TRUE);
    Invalidate();
}
else
    CFormView::OnSize(nType, cx, cy);

But there isn't really a way to eliminate it completely that I've located.

m_bInitialized is set in OnInitialUpdate.
0
 
nabehsCommented:
// try the following:
// override OnEraseBkgnd of the form view and write the following code:
// it should reduce the flickering dramatically

BOOL CMyFormView::OnEraseBkgnd(CDC* pDC)
{
      CRect rcBounds;
      GetClientRect(&rcBounds);

      // loop all the child windows and collect their regions
      CWnd* pwndChild = GetWindow(GW_CHILD);
      CRgn rgnResult, rgn1;
      rgnResult.CreateRectRgn(rcBounds.left, rcBounds.top, rcBounds.right, rcBounds.bottom);
      CRect rcChild;
      while (pwndChild)
      {
            pwndChild->GetClientRect(&rcChild);
            pwndChild->ClientToScreen(&rcChild);
            ScreenToClient(&rcChild);

            // subtract the control region from the dialog region
            rgn1.CreateRectRgn(rcChild.left, rcChild.top, rcChild.right, rcChild.bottom);
            rgnResult.CombineRgn(&rgnResult, &rgn1, RGN_DIFF);
            pwndChild = pwndChild->GetNextWindow();

            rgn1.DeleteObject();
      }


      // limit refresh to the resulting region
      pDC->SelectClipRgn(&rgnResult, RGN_COPY);

      BOOL bRet = CFormView::OnEraseBkgnd(pDC);

      pDC->SelectClipRgn(NULL, RGN_COPY);

      return bRet;
}
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
MasudkhanCommented:
Hello Madhavi,
Wake up. People have suggested some answers & awaiting a reply from you !!!!!!!!!!
0
 
nabehsCommented:
I am using the method I have provided in my personal work and it is working fine, but I am open to any objections
0
 
Amritpal SinghCommented:
i'm stuck in a way that i can't even say for a point split keeping in view the points of the question :))
0
 
moduloCommented:
PAQed with points refunded (20)

modulo
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now