1.在view里显示文字,很简单:
(1)pDC->DrawText("DrawText",strlen("DrawText"),CRect(30,30,100,100),DT_CENTER);
(2)pDC->TextOut(0,0,_T("测试"));
2.显示位图
CDC mem;
CBitmap ditu;
BITMAP bm;
mem.CreateCompatibleDC(NULL);
ditu.LoadBitmap(IDB_MAP);//注意不要写成 ditu = LoadBitmap(IDB_MAP);
ditu.GetBitmap(&bm);
SelectObject(mem,ditu);
(1)StretchBlt(pDC->GetSafeHdc(),0,0,bm.bmWidth,bm.bmHeight,mem,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY);
(2)pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&mem,0,0,SRCCOPY);
3.双缓冲防止闪烁
CDC mem;
CBitmap bitmap;
CPen pen(PS_SOLID,3,RGB(0,0,255));
CBrush brush(RGB(255,0,0));
mem.CreateCompatibleDC(NULL);
bitmap.CreateCompatibleBitmap(pDC,scaleRect.Width(),scaleRect.Height());
mem.SelectObject(&pen);
mem.SelectObject(&brush);
mem.SelectObject(&bitmap);
//mem.SetBkMode(TRANSPARENT);
mem.FillSolidRect(0,0,scaleRect.Width(),scaleRect.Height(),RGB(111,111,111));
mem.Rectangle(&Rt);
pDC->BitBlt(0,0,Rt.Width(),Rt.Height(),&mem,0,0,SRCCOPY);