I've been tracking down a window painting problem and I think that I know whats happening but I'd like to get some opinions on the 'right' way to fix it.
The symptom is that (in some cases) any change to a window will cause the entire window to be repainted. For instance, using the mouse to select a single character causes the whole window to update rather than just the small region which needs to be highlighted. This doesn't happen on most applications. In fact, the only one where i've seen this effect is RoAClient (a really good MUD client). Even so, its really annoying and makes the window flash so much that the app is effectively useless.
The problem appears to be in BeginPaint. There is a test which checks to see if the window has the CS_PARENTDC flag set. If so then then the update region is discarded and the window is painted. This has the side effect of making the whole window repaint every time anything in the window changes.
According to the windows docs that i've looked at, the CS_PARENTDC should just make the window paint using its parent's device context. There isn't any mention of also removing the invalid region clipping so i'm pretty sure that what BeginPaint is doing isn't right.
In my hacking around, I disabled the branch of the test which removes the clipping region and things appear to work a lot better. The screen updating is definitely smoother. What I'm not sure of is whether this is good enough or whether the CS_PARENTDC case really should be slightly different. Normally the clipping region is offset relative to the window thats being drawn but with CS_PARENTDC should the offset be done relative to the parent window instead? Are there any other subtle things that CS_PARENTDC affects?
Any insight would be appreciated...
Thanks much,
G. Schrader