void CTestView::OnDraw(CDC* pDC)
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc); static int m_nMark = 0;
if (m_nMark == 0)
{
int x, y;
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);
m_nMark = 1;
}
pMemDC->FillSolidRect(0,0,nWidth,-nHeight,RGB(168,168,168));
OnTimer(1);
pDC->BitBlt(0,0,nWidth,nHeight,pMemDC,0,0,SRCCOPY);}这两句无法正常设置坐标模式和坐标原点:
pMemDC->SetMapMode(MM_LOMETRIC); //就是这句
pMemDC->SetViewportOrg(x,y); //还有这句
{
CTestDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc); static int m_nMark = 0;
if (m_nMark == 0)
{
int x, y;
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);
m_nMark = 1;
}
pMemDC->FillSolidRect(0,0,nWidth,-nHeight,RGB(168,168,168));
OnTimer(1);
pDC->BitBlt(0,0,nWidth,nHeight,pMemDC,0,0,SRCCOPY);}这两句无法正常设置坐标模式和坐标原点:
pMemDC->SetMapMode(MM_LOMETRIC); //就是这句
pMemDC->SetViewportOrg(x,y); //还有这句
我觉得是不是因为你上边得到x,y是pixel
而下边的SetMapMode()与上边的不一样的,换一个mode
pMemDC->SetMapMode(MM_LOMETRIC); //就是这句
这里改变了memdc,显然,后面的操作是意想不到的。这不是坐标是否为象素的问题。
可能一些函数都不可用,或不能成功。
我看到的现象好像正如你所说的,
那么应该怎么样才能够改变绘图模式和坐标原点呢?