Holy cow, I wrote a book!
everybody hates CS_PARENTDC!
Commenter kero claims that it's
"easy to fix"
the problem with
You just remove the CS_PARENTDC style temporarily,
then do the normal
then restore the
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.
Since the 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
While that's going on,
the other window gets a
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.)