Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
May 26, 1998

C++ (MFC)

Question:
I am a student learning to do C++ programming with MFC. I have used InvalidateRect to update a particular area in a program. I thought invalidating reduced the flickering of an area/graphics when you repaint it, but it doesn't really solve the problem. Is there any other way to reduce the flickering of an area/graphics when you repaint it?

Answer:
ValidateRect might be closer to what you want, because flickering is caused by repainting the same window several times. Calling InvalidateRect simply tells Windows that a portion of a window must be painted.

One way InvalidateRect can help is that you can create a single place in your code that paints your entire window. Then, if you make several changes to your data, you can invalidate the window, which will call this code. The result is that everything is painted at once rather in several pieces.

It's hard for me to get more specific without knowing what your code does, but my guess is that you should step through your code that paints the screen and see what causes the flicker. Try and design your code so that your window is updated all at once.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date