I would like to use the windows Ellipse API to draw a few circles to a back buffer and then copy the device context of the back buffer back to my main window.

I've read quite a lot on how to do this and how it works however all the examples I can find involve copying bitmaps or using DirectX whereas I don't want to use any bitmaps for this program. You may have seen in another recent post I made the following code:

invoke GetDC,hWin
mov hDC,eax
invoke CreateCompatibleDC,hDC
mov hMemDC,eax
invoke Ellipse,hMemDC,100,100,120,120
invoke GetClientRect,hWin,addr rect
invoke BitBlt,hDC,0,0,rect.right,rect.bottom,hMemDC,0,0,SRCCOPY
invoke DeleteDC,hMemDC

hWin contains the handle to my main dialog.

For some reason this code doesn't work. I tried the same code in Visual Basic too and the only way I could get it to work was if I used the Device Context of a picture box whose Autoredraw property was set to true instead of creating my own CompatibleDC. Unfortunatly I don't really know what the Autoredraw property does (one of the downsides to using a high level language - ie too much abstraction! :)) so I don't know what else I need to do to get this back buffer to work. Any ideas?
Posted on 2004-06-05 19:26:58 by DeX
Its been awile since I did any graphics. If I remember right, you have to have a
bitmap. A DC is just that, a context. It (for the most part) has no physical
pieces on which to do the drawing. Your drawing in empty space and blitting
back nothing.

Create a compatible DC
Create a compatible Bitmap
Select the Bitmap into the DC (dont forget to save the old one!)
Release all

Like I said its been awile, but I think this is the way it should go...
Posted on 2004-06-05 20:45:21 by Graebel
That's right, you need at least one bitmap, which can act as the backbuffer.
Posted on 2004-06-06 04:29:24 by Scali