Flicker in Windows can sometimes be tricky, I have been dealing with it quite a lot at work latly, when we decided to eliminate all flicker in an app. The key is to never paint the same pixel twice during one WM_PAINT (yes, double buffering is a common solution for this). If you can describe in more detail what kind of flicker you ar experiencing, maybe I can help.
Remove your WM_PAINT handler entirely, and we'll work from there.
Since I'm lying here with a broken leg and nothing better to do, I pasted your code into VS. I think I know whar is causing the flicker. I'll be back after some tests.