Click here to Skip to main content
15,892,643 members
Articles / Desktop Programming / MFC

Trouble with area fixing using ValidateRect(). The best way to optimize the code

Rate me:
Please Sign up or sign in to vote.
4.00/5 (1 vote)
9 Oct 2012CPOL 5.5K  
Hello everyoneI'm trying to resolve the problem with image blinking and I almost get it ,but I got some problems.I want to redraw all the rest of the window except only the image. I'm trying to throw the Image's rectangle(i.e.coordinates) into ValidateRect and perform rendering but...

Alternatives

Members may post updates or alternatives to this current article in order to show different approaches or add new features.

Please Sign up or sign in to vote.
9 Oct 2012JackDingler
Allocate an empty bitmap the size of your display area.Make a memdc for this image.Call CDC::FillSolidRect(&ClientRect, 0x00FFFFFF); to clear it to the back ground color.BitBlt your bitmap to this DC.Bitblt this DC to your window.
Please Sign up or sign in to vote.
8 Oct 2012michaelmel
I don't think you can avoid flicker without double buffering. The flicker occurs because memory associated with the image on the display is updated at the same time as the hardware pushes pixels to the screen. Have a look at:Don't Flicker! Double Buffer![^]
Please Sign up or sign in to vote.
9 Oct 2012CPallini
Well, loading again and again the CImage doesn't help the overall performance, in my opinion.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Cocos (Keeling) Islands Cocos (Keeling) Islands
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions