I have a static derived class which I want to implement custom drawing in MM_ISOTROPIC mapping mode. For the life of me, I cannot figure out how to do this using a memory dc. I have reviewed and copied several "double buffering" routines, i.e. CMemDC but none of them work when I change the mapping mode.
The following code simply draws a line from the origin (low left corner) to 100,100. It is a simple test. If I use the CPaintDC all is fine, but using a memory dc, nothing shows up.
Any ideas to help me out?Code:void DrawCtrl::OnPaint()
{
CPaintDC dc(this);
PrepareDc(&dc);
CDC memDc;
memDc.CreateCompatibleDC(&dc);
PrepareDc(&memDc);
CRect rect;
dc.GetClipBox(&rect);
CBitmap bm;
bm.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
CBitmap* pOld = memDc.SelectObject(&bm);
CPen wht (PS_SOLID, 1, RGB(255,255,255));
memDc.SelectObject(&wht);
memDc.LineTo(100,100);
dc.BitBlt(rect.left, rect.bottom, rect.Width(), rect.Height(), &memDc, rect.left, rect.bottom, SRCCOPY);
memDc.SelectObject(pOld);
}
void DrawCtrl::PrepareDc(CDC* pDc)
{
CRect rect;
GetClientRect(&rect);
pDc->FillSolidRect(&rect, RGB(0,0,0));
pDc->SetMapMode(MM_ISOTROPIC);
pDc->SetWindowExt(rect.Size());
pDc->SetViewportExt(rect.Width(), -rect.Height());
pDc->SetViewportOrg(rect.left, rect.bottom);
}
Mike B

