Don't use Sleep
. It is the solution to almost no problems.
It's true that WS_EX_COMPOSITED
can hog CPU but mostly on XP in my experience. There is a much less significant performance hit on Vista and up. However, if your app is idle then it won't be repainting. If your CPU is 100% and the app is idle then you are doing something wrong in your WM_PAINT
handling. What you describe sounds like an endless loop of paint cycles. If you do things right, that won't happen, even if you use WS_EX_COMPOSITED
.
As regards the right way to do double buffering, BeginBufferedPaint
is the modern way to do this, on Vista and up.