Question

I'm dealing a lot with drawing. Currently I'm using WM_TIMER to schedule painting using InvalidateRect. For some reason WM_PAINT is then very often called with region (0,0,0,0), so basically an empty rectangle. I tried to interpret this as "the whole window", but then it seemed to cause quite some performance decrease. Why is Windows sending it then?

Was it helpful?

Solution

Your question is quite well answered in the standard documentation: http://msdn.microsoft.com/en-us/library/windows/desktop/dd145213%28v=vs.85%29.aspx.

Basically, the system sends WM_PAINT messages when the message queue is empty and by default it does so on occasion regardless of whether there is anything to paint or not. Many older applications depended on WM_PAINT (for example to do idle time processing) and keeping this behaviour ensures compatibility.

No, you must not assume it means the whole screen. If the region is empty you should avoid calling BeginPaint/EndPaint and just pass it through to the default window procedure.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top