Alternatively (to solve the original problem directly), don't specify CS_HREDRAW or CS_VREDRAW in your window class style.
However you would still lose everything (unless you specify CS_SAVEBITS, I think; I've never used this) if some other window appeared in front of yours.
So Shabbir's answer is the best; draw everything in the WM_PAINT response function, and if you do any drawing outside that for some reason, make sure the WM_PAINT code will also draw that same stuff should it be called on.
Drawing everything in WM_PAINT is really advantageous because you can make use of Windows' clipping functionality automatically; it's more or less transparent. If you want to make a small change in the display, update the data that the drawing depends on, then InvalidateRect just the rectangle that contains the change. Then call UpdateWindow, specifying bErase=FALSE, will then invoke WM_PAINT with the invalidated rectangle specified in the clipping region, and any drawing that occurs in WM_PAINT will be clipped to that rectangle, so the update will occur really quickly.
Calling UpdateWindow with bErase=TRUE should be avoided wherever possible. Blanking everything before you start means you're guaranteed to get screen flicker. It may be valid in some cases, but instead of using bErase=TRUE use double buffering, where you draw everything to an initially blank memory bitmap, then blat that straight onto the screen.
For an example of extremely crappy erase-before-redraw, have a look at FreeCommander (a Windows Commander clone, an otherwise quite good program); go to a directory with lots of files in, then use Shift-cursor keys to select a whole bunch of files; watch it flicker like a bad 1960's B-movie. Repeat the same selection in Windows Explorer and you'll see it's stacks nicer, because they don't erase the whole rectangle first.