I am using WS_EX_COMPOSITED style in my application but its running the CPU to 100%, is there way to stop my application drawing for a while and to resume only when i need ? Some people are suggesting to use Sleep's but where exactly in WndProc do i put sleeps ?
Thanks in advance.
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 yourWM_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 useWS_EX_COMPOSITED
.As regards the right way to do double buffering,
BeginBufferedPaint
is the modern way to do this, on Vista and up.