From: Sascha on
Hello

I am trying to find a Win32 function/way that can allow me to erase a
HRGN from a HDC.

What I am doing is double buffering; so I copy the window HDC to a
buffer HDC, then I delete/erase a specific area of the buffer HDC,
then draw what I need to.

But I dont know how to erase a specific area of a HDC?. I cant use
InvalidateRgn(NULL, ObjRegion, true) (because this function only
erases the window HDC) or can I? Can I use
FillRgn( hdc, ObjRegion, (HBRUSH)GetStockObject(NULL_BRUSH) ); ? If I
can, do I use it in the message WM_ERASEBKGND or in WM_PAINT?

To give an idea of what I am trying to do:

I am trying to make my own simple 2d drawing engine (animation?) :P.
So what I do is at each drawing_clock_interval I have a drawing
controller object that copies the window HDC in a buffer HDC(STEP 1),
erases an objects HRGN (from the buffer HDC) (erase the old position
of an object), then I draw the objects new position (FillRegion) onto
the bufferHDC, then I copy the buffer HDC to the main window HDC.

I dont want to use InvalidateRgn() before STEP 1, because I think it
may cause the flicker affect that you get without double
buffering(Because of the delay between, erasing the region, copying
the HDC, drawing on the HDC, then copying it back) . Am I right?

Hope this makes sense :)

From: John H. on
Sascha wrote:
> I am trying to make my own simple 2d drawing engine (animation?) :P.
> So what I do is at each drawing_clock_interval I have a drawing

Not too sure about this, but you could try at each interval,
invalidating the region you want to repaint, via InvalidateRgn. Then
look for the WM_PAINT message. When it comes, see if there is an
update area, via GetUpdateRect. If there is, BeginPaint, do your
painting, and EndPaint.