|
发表于 2020-11-25 12:30:01
|
显示全部楼层
void CDBDCView::MemDraw(CDC* pDC)
{
CRect rect;
GetClientRect(rect);
CDC memDC;
CBitmap temBmp;
memDC.CreateCompatibleDC(pDC);
>>>temBmp.CreateCompatibleBitmap(&memDC,rect.Width(),rect.Height());
CBitmap* pOldBmp=memDC.SelectObject(&temBmp);
CBrush brush(RGB(0,255,255));
CBrush* pOldBrush=memDC.SelectObject(&brush);
memDC.Rectangle(rect);
COLORREF oldColor;
oldColor=memDC.SetBkColor(RGB(255,0,0));
memDC.TextOut(100,100,"verysource");
pDC->BitBlt(rect.left,rect.top,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
memDC.SelectObject(pOldBmp);
>>>memDC.SelectObject(pOldBrush);
memDC.SetBkColor(oldColor);
}
FROM MSDN:
A memory DC exists only in memory. When the memory DC is created, its display surface is exactly one monochrome pixel wide and one monochrome pixel high. Before an application can use a memory DC for drawing operations, it must select a bitmap of the correct width and height into the DC. |
|