[MFC] flickering/trials

Recommended Posts

Im haveing troubles with updating the window and flickering. A quick search and I found a solution that mentions overrideing the OnEraseBkgnd(). This worked... almost. I still have some flickering but now it leaves trails, scroll trails. Im using the OnPaint() method because I cant get OnDraw() to work :S BOOL MyView::OnEraseBkgnd(CDC* pDC) { //CScrollView::OnEraseBkgnd(pDC); return TRUE; } How do i avoid flickering / fix this!?

Share on other sites
You may want to try double-buffering without erasing the background each time. Use this code to redraw the window without erasing the background:

[window object].RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

Share on other sites
How exactly are you drawing it? Are you using BitBlt?

Share on other sites
thx cloud007 i will try it 1st thing in the morning.

@ DevLiquidKnight yes im using BitBlt to copy an image to screen. Is that good or bad?

Share on other sites
RedrawWindow() almost did it, the image is not flickering anymore but the rest (grid, lines ect that im drawing) are still flickering. Did I forget something!?

Share on other sites
Maybe the lines,grid and etc was not being draw on the backbuffer's DC.Checking that will help you.If you are using backbuffer,everything you draw must be draw on the backbuffer before copying it to the actual DC.

Share on other sites
If I am not drawing on the backbuffer then what do I need to do!?
Currently the flickering is gone, but I still have trails. Here are 2 screenshots to show the current state.

http://members.home.nl/skynet2097/Temp/screen1.PNG
http://members.home.nl/skynet2097/Temp/screen2.PNG

I have 2 image variables. original and copy. I copy the original to the copy-image, draw stuff onto the copy-image and than copy it to sceen.

CImage m_MainImage;CImage m_CopyImage;// get a pointer to the device component from the specified handleCDC* l_DC = CDC::FromHandle(m_CopyImage.GetDC());// Copy original imagem_MainImage.BitBlt((HDC)l_DC, 0, 0, l_iWidth, l_iHeight, 0, 0, SRCCOPY);DrawGrid(l_DC);DrawSomeMore(l_DC);// Copy the image to the current devicedc.BitBlt( 0, 0, l_iWidth, l_iHeight, l_DC, l_iHPos, l_iVPos, SRCCOPY);

any1?

Create an account

Register a new account

• Forum Statistics

• Total Topics
628401
• Total Posts
2982462

• 9
• 10
• 9
• 19
• 24