为了实现动画而载入bitmap后应该如何设置坐标原点和MapMode?比如如下的代码添加后如何实现加注部分的功能?void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
x = pDC->GetDeviceCaps(HORZRES) / 2;
y = pDC->GetDeviceCaps(VERTRES) / 2;
pMemDC->CreateCompatibleDC(pDC);
pMemBitmap->CreateCompatibleBitmap(pDC, nWidth, nHeight);
pMemDC->SetMapMode(MM_LOMETRIC); //这句若是这样添加无法正常运作
pMemDC->SetViewportOrg(x,y); //还有这句
CBitmap *pOldBit = pMemDC->SelectObject(pMemBitmap);
pMemDC->FillSolidRect(0,0,nWidth,-nHeight,RGB(168,168,168));
OnTimer(1);
pDC->BitBlt(0,0,nWidth,nHeight,pMemDC,0,0,SRCCOPY);
}
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
x = pDC->GetDeviceCaps(HORZRES) / 2;
y = pDC->GetDeviceCaps(VERTRES) / 2;
pMemDC->CreateCompatibleDC(pDC);
pMemBitmap->CreateCompatibleBitmap(pDC, nWidth, nHeight);
pMemDC->SetMapMode(MM_LOMETRIC); //这句若是这样添加无法正常运作
pMemDC->SetViewportOrg(x,y); //还有这句
CBitmap *pOldBit = pMemDC->SelectObject(pMemBitmap);
pMemDC->FillSolidRect(0,0,nWidth,-nHeight,RGB(168,168,168));
OnTimer(1);
pDC->BitBlt(0,0,nWidth,nHeight,pMemDC,0,0,SRCCOPY);
}
2) Where is pMemDC/pMemBitmap declared? It's never deleted?
3) Why do not need to call SetMapMode and SetViewportOrg on the memory DC?
4) Why creating a bitmap and then fill it with solid color and BitBlt to pDC, why not directly fill the solid color directly to pDC?
5) Why call OnTimer here?Feng Yuan [MSFT]
int x, y; CDC* pMemDC; CBitmap* pMemBitmap;定义在头文件里,并且在view 的构造函数里面被new 了。
我这里是为了要实现动画而在内存理面描画图形,所以我要先设置绘图模式。
而描绘语句添加在OnTimer里面,并且由OnTimer来刷新画面
http://lianwm.nease.net/base7.htm
ocean69