hi,
I draw several polygons on a child window.
When I open another application e.g.Calculator,the portions of
the polygons blocked by the application are erased.I process
WM_PAINT message and redraw the polygons,but afterwards
when I move the Calculator along the screen my drawings
flicker.What can I do to avoid both of these problems.
thanks.
To erase flickering, you will need to "double-buffer" your drawing and then handle the WM_ERASEBKGRND message and just return TRUE.
To create a double buffer before actually drawing it in your WM_PAINT handler, create a bitmap the size you want to draw with and draw everything there first, then just bitblt the bitmap image onto the screen DC.
As for losing your polygons when another application window is on top, this is the correct behavior. If you want your window to ALWAYS remain on top, make sure you create your window with the WS_EX_TOPMOST style.
Relvinian
If another program is erasing your window by moving over it you will have to call InvalidateRect,hWnd,0,0 in the appropriate place.
Peter.
Oops! What I should have said is that it's probably an error in your code that is causing this.
InvalidateRect is only needed when you need to force a repaint.
Peter.
Back bffering is the way to go as you get no flicker doing it but if you have the windows without animation and another windows overlaps it, then you can reblit the last back buffer to the display area to solve that problem.