|You have three opportunities to reduce flicker:
1. Draw the image in the
OnEraseBkgnd() handler and return TRUE.
2. Do other drawing in the
OnPaint() handler. Use
CMemDC to double buffer the dc. Since the entire background (I assume) is being covered with the image, there is no need to do a "fill" in
OnPaint(); in fact, doing do would wipe out the image that was just drawn in
3. In the
OnSize() handler, tell Windows to defer re-positioning your controls until you are finished, You do this by using the DeferWindowPos() function (there are two other functions you will need, they are explained at that link).
The way Windows works, anything that obscures your window causes a
WM_ERASEBKGND message to be sent to your window. This means that your window has to be redrawn when it is uncovered. Examples: moving another window on top of your window, or minimizing/restoring your window. So to answer your question, there is no way to "permanently" paint the background, because it is constantly being redrawn due to normal window operations.
It is also somewhat customary to do background stuff in
OnEraseBkgnd() and foreground stuff in
OnPaint(), although this is not a hard rule you have to follow; you can be sure that every
WM_ERASEBKGND message will be followed by a