here is a snippet of code that I used in a program I wrote a while ago:
-
//get the rectangle of the active window
-
RECT clientRec;
-
GetClientRect(_platformInfo->hWindow, &clientRec);
-
-
//create the buffer image
-
_buffer = new Gdiplus::Bitmap(clientRec.right - clientRec.left, clientRec.bottom - clientRec.top, _currentGraphics);
-
-
//create the graphics object to draw on the buffer
-
Gdiplus::Graphics *bufferGraphics = Gdiplus::Graphics::FromImage(_buffer);
-
-
/*Draw a bunch of stuff*/
-
_currentGraphics->DrawImage(_buffer, 0, 0);
-
-
Obviously, this isn't complete code, but the basic idea is still there. I create a new image to act as the buffer (line 6). Using that particular constructor creates a bitmap that is compatible with the "real" graphics object and is the size of the entire client area of the window. In order to draw on a bitmap with GDI+ you need a Graphics object for that particular bitmap (line 9). Then draw as usual with the buffer Graphics object. The final step is to draw the buffer image with the real graphics object.
Well, I suppose the
final step would be to clean up my _buffer and bufferGraphics objects.
There may be other, better, ways to do this, but this was all that I could find when I was searching. Hope it helps.