What is the cost of WS_CLIPSIBLINGS if the sibling windows don't overlap?

Raymond Chen

Commenter Robert May asks via the Suggestion Box whether there is a penalty to pay for using WS_CLIP­SIBLINGS when the sibling windows are not overlapping. When you use the WS_CLIP­SIBLINGS style, the window manager clips out the portion of the client rectangle that is covered by sibling windows. This is usually desirable behavior; otherwise you end up with two windows trying to paint at the same location, and somebody is likely to get hurt. (The One notable exception is in dialog boxes, where some controls like the group box were designed to have other controls drawn on top of them.)

The cost of this flag is that when it comes time to calculate the visible region for a window, the space occupied by sibling windows higher in the z-order are clipped out. This happens even if the sibling windows don’t overlap; after all, the only way to find out whether there are any overlapping sibling windows is to enumerate the sibling windows looking for them! Of course, if there is in fact no overlapping, then the calculations are trivial. The only cost was the loop which determines that there are no applicable siblings to be clipped out.