A default winAPI application does not have double-buffering. Instead, it does a very, very good job of ensuring that only what needs to be drawn is drawn, and that gives it a seamless appearance. However, when you resize the window, the entire thing needs to be redrawn, and this causes flickering between the controls, the background on the tab, and sometimes the white of the tab.
So my question is, what is the easiest way to support double buffering in my application?
Create a bitmap the size of the window, render into that bitmap, and blit that back into the window when you're done.
You can do a pretty straight-forward in-place replacement in your existing code. Instead of using a device context that renders into the window, use one that renders into the bitmap, and only use the original DC to blit the bitmap back.
Be sure to keep the bitmap around - don't create it in every paint call. You just need to recreate it when the window is resized.
Take a look at the following article: Flicker-Free Displays Using an Off-Screen DC.
This article describes a technique for drawing to a window device context (DC) in such a way that the screen does not flicker. The technique is very simple and easy to implement.
I learnt how to prevent flickering from this tutorial several years ago.
来源:https://stackoverflow.com/questions/3895305/winapi-double-buffering