Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Intermediate
Oct 9, 2001



Building the Right Environment to Support AI, Machine Learning and Deep Learning

Efficient Window Client Area Painting in VC++

Everybody knows that the WM_PAINT message is passed to a window whenever it needs to be painted. Usually, we code all of our painting instruction in the handler of WM_PAINT, including the background of our painting items. What actually happens is that a WM_ERASEBKGND is also passed prior to sending WM_PAINT. The default implementation of this message erases the client area of the window with white screen. To improve the efficiency of the overall painting of your window's client area, identify the items that never change on your screen. These items should effectively be the background of your screen. Put the painting code of these items from your WM_PAINT handler to WM_ERASEBKGND handler and return a nonzero value to indicate to the windows that no further erasing is required. Doing this will speed up the complex windows painting and remove the flickering that happens when a window is resized or constantly refreshed.
Asad Ather
Comment and Contribute






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



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