If you have the device context of the window (for instance inside the OnPaint handler), namely
dc
:
CDC dcMem;
CBitmap bmp;
CRect rc;
CImage img;
dcMem.CreateCompatibleDC(&dc);
GetWindowRect(&rc);
bmp.CreateCompatibleBitmap( &dcMem, rc.Width(), rc.Height());
dcMem.SelectObject(&bmp);
dcMem.BitBlt(0,0,rc.Width(), rc.Height(), &dc, 0,0, SRCCOPY);
img.Attach(bmp);
img.Save(_T("MyBitmap.bmp"), Gdiplus::ImageFormatBMP);