The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ofg on January 21, 2005, 10:43:20 PM

Title: erased drawings
Post by: ofg on January 21, 2005, 10:43:20 PM
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.
Title: Re: erased drawings
Post by: Relvinian on January 21, 2005, 11:10:10 PM
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
Title: Re: erased drawings
Post by: petezl on January 21, 2005, 11:22:45 PM
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.
Title: Re: erased drawings
Post by: petezl on January 22, 2005, 01:09:51 AM
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.
Title: Re: erased drawings
Post by: hutch-- on January 22, 2005, 01:43:47 PM
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.