Thanks for the hint, unfortunately it still doesn't work.

WStaticContents seems to be exactly what I want to avoid while WNoAutoErase sounds like a solution. But it still looks the same:

The original painter output:



Window shrinked:



Window enlarged again:



Window repainted due to putting another window in front of it:




Do you have any other ideas?