Why does PrintWindow hate CS_PARENTDC? redux
CS_PARENTDC? Because everybody hates
Commenter kero claims that it’s “easy to fix” the problem with
CS_PARENTDC. You just remove the
CS_PARENTDC style temporarily, then do the normal
PrintWindow, then restore the
CS_PARENTDC style. The question is then why
PrintWindow simply doesn’t do this.
The question assumes that the described workaround actually works. It may work in limited situations, but it certainly doesn’t work in general.
CS_PARENTDC style is a class style, removing the style affects all windows of that class, not merely the window you are trying to print. Suppose there are two windows of the class running on different threads, and you remove the
CS_PARENTDC style in anticipation of doing a
PrintWindow. While that’s going on, the other window gets a
WM_PAINT message. Since the
CS_PARENTDC style was temporarily removed, that window will be painting with an incorrectly-clipped DC. Result: Incorrect pixels on the screen.
The proposed workaround doesn’t actually work reliably, which means that it probably shouldn’t be done at all. (Random reinforcement breeds superstition.)