How to force window to have rounded corners?

I’m using the code from this post to make the titlebar transparent. But then, I got the effect from this post : the round corners of the window become angular again when I got canvas in my window or when using the Paint Event of the window.

How to force rounded corners?