Click to See Complete Forum and Search --> : Help: How to get a flicker free view ?


MeierD
July 5th, 1999, 05:58 AM
Hi,
Could you help me about flicker free objects ?
I recently filled a view with a standard color.
Each time, when i resize the window, contents
of view is flickering.

Thanks for your help.

Regards,
Daniel

Gerd Mayer
July 5th, 1999, 05:54 PM
Hello,
you have detected one of the great Microsoft problems - but don't worry.
Here is a raw solution:

1) add a CBitmap and a CDC member variable in your View class.

2) create the bitmap and the DC (e.g. in CMyView::OnCreate() )
like this

CClientDC dc(this);
CDC m_DC.CreateCompatibleDC(&dc);
m_Bmp.CreateCompatibleBitmap(&dc, 2048, 2048); // make it as big as your screen can be
m_DC.SelectObject(&m_Bmp);




3) Now do all your drawing into the m_DC
4) In OnDraw, OnPaint or OnEraseBkGnd just call a BitBlt

CRect r;
GetClientRect(r);
pDC->BitBlt(0,0,r.right,r.bottom,&m_DC,0,0,SRCCOPY);




I hope this will help you.

If not, and you want it, i can send you a whole example.

Good luck
Gerd

MeierD
July 7th, 1999, 04:09 AM
Thanks for your help !
But sorry, at my view it doesn't work !
Now, I will provide detailed information
about my application:

1) In the desktop properties of Windows NT4.0
"Show window contents while dragging" is on.

2) I tried as simple as I could. The following
project: SDI - application with a simple CMyFormView that includes only three buttons.

3) In OnCreate of CFormView derived class CMyFormView, the following code is included:
-------------------------------------------------
CClientDC dc(this);
m_DC.CreateCompatibleDC(&dc);
m_Bmp.CreateCompatibleBitmap(&dc, 2048, 2048);
m_DC.SelectObject(&m_Bmp);
(In header declaration: CDC m_DC; CBitmap m_Bmp)
...like your example !

4) In OnDraw, the following code is included:
CRect rcOverview;
GetClientRect(rcOverview);
pDC->BitBlt0,0,rcOverview.right,
rcOverview.bottom,&m_DC,0,0,SRCCOPY);
...like your example !

If I resize the window, the formview contents incl. buttons are flickering tremendous!

Could you help me about this problem again ?

Thank you very much indeed.

Best Regards,
Daniel