Drawing to a Bitmap
Hello all,
I have what I hope to be a simple question, but one that Google is
failing me on. Everything seems to describe the opposite of the
process, but I know that the information is out there somewhere.
I have an mfc application that with multiple CViews that I have draw
code set up for and everything works wonderfully when drawing to the
screen. Now, what I want to do, is create a bitmap, tell each of the
CViews to draw to that, and then saving it out to disk as a screen
capture. I want to go this route for several reasons, the biggest
being that I want to save these CViews even if they are ocluded by
other windows, though if this proves to be too difficult, a screenshot
would suffice I suppose.
My CView has draw code that looks like the following:
void CGraphicsView::OnDraw(CDC* pDCWnd)
{
CGraphicsDoc* pModelDoc = GetModelDocument();
ASSERT_VALID(pModelDoc);
CDC *pDC = pDCWnd;
OnPrepareDC(pDC);
theApp.m_mtxDrawInProgress.Lock();
CRect rectClient;
GetClientRect(&rectClient);
CRect rectClip;
pDCWnd->GetClipBox(rectClip);
if (EqualRect(&rectClient, &rectClip))
{
if (m_bWasCovered)
{
m_bWasCovered = false;
this->Invalidate(true);
}
}
else
{
m_bWasCovered = true;
}
if (!pDC->IsPrinting())
pDC->FillSolidRect(rectClip, RGB(204, 204, 204));
if (pModelDoc->Model()->IsValid())
pModelDoc->Model()->Draw(pDC, rectClip);