To reduce flicker add a WM_ERASEBKGND handler that just returns TRUE (indicating the msg was processed).

You are getting flicker because you are trying to do a lot of drawing, GDI creation, etc...