|
发表于 2020-11-25 13:15:01
|
显示全部楼层
以下代码运行结果为红色。
CDC dc;
CDC* pDrawDC = pDC;
CBitmap bitmap;
CBitmap* pOldBitmap;
CRect rect;
GetClientRect(&rect);
//========================================================
if (dc.CreateCompatibleDC(pDC))
{
if (bitmap.CreateCompatibleBitmap(pDC,
rect.Width(),
rect.Height()))
{
OnPrepareDC(&dc,NULL);
pDrawDC = &dc;
pOldBitmap = dc.SelectObject(&bitmap);
}
}
//========================================================
//pDoc->Draw(pDrawDC,ViewID);
>>>>>>>>>pDrawDC->FillSolidRect(0,0, 100,100, RGB(255,0,0));
pDrawDC->TextOut(1,1,_T("ABC"));
dc.DPtoLP(&rect);
//========================================================
if ( 1)//pDrawDC != pDC )
{
pDC->BitBlt( 0, 0,rect.Width(), rect.Height(),
&dc, 0, 0, SRCCOPY);
dc.SelectObject(pOldBitmap);
bitmap.DeleteObject();
}
|
|