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?
Asked
Active
Viewed 403 times
3
-
You need to post repro code that demonstrates the issue. – Hans Passant Apr 11 '14 at 00:31
-
9It means "don't need to paint anything". Just call EndPaint. Empty rectangles are sent for compatibility reasons, and you can explicitly request them with RDW_INTERNALPAINT. – Raymond Chen Apr 11 '14 at 01:23
1 Answers
5
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.

david.pfx
- 10,520
- 3
- 30
- 63