I'm afraid I don't understand this CDC jazz too much. There are
certain parts that seem unnecessarily complicated. For instance, I
have to call CreateCompatibleDC(). Subsequent calls are either to the
CDC pointer returned by it, and others are to the pointer in the
function header.
Anyway, the only thing written to the view is a true colour bitmap
with a halftone brush. I was wondering if you could tell me if any of
the following code need not be executed on each OnDraw() call, but
only when there is a new design on the view. Here's an abstraction:
CDC dcMemory;
HBITMAP hBmp = CreateDIBitmap(pDC->m_hDC, &m_BMPHeader, CBM_INIT,
&m_BMPInit, &m_BMPColour,DIB_RGB_COLORS);
dcMemory.CreateCompatibleDC(pDC);
CBitmap *ptheirbitmap = CBitmap::FromHandle(hBmp);
dcMemory.SelectObject(ptheirbitmap);
DeleteObject(hBmp);
int nSavedStretchMode = pDC->SetStretchBltMode(STRETCH_HALFTONE);
::SetBrushOrgEx(dcMemory.m_hDC, 0, 0, NULL));
pDC->StretchBlt (0, 0, m_nRealWidth, m_nRealHeight, &dcMemory, 0,
0,
m_nFakeWidth, m_nFakeHeight, SRCCOPY));
pDC->SetStretchBltMode(nSavedStretchMode);
dcMemory.DeleteDC();
I don't understand a lot of it. It was a great deal of trial and
error. I imagine there are things I'm doing less than optimally.
However, all that code seems to be based on pDC, so I don't see how I
could do any of it outside of OnDraw()'s scope.