CXXX:OnTimer()
{
     CBitmap Bitmap,*pOldBitmap;
     Bitmap.LoadBitmap();
     CDC* pDC=this->GetDC();
     CDC memDC;
     memDC.CreateCompatibleDC(pDC);
     pOldBitmap=(CBitmap*)memDC.SelectObject(&Bitmap);
     pDC->BitBlt(....,&memDC,....);
     memDC.SelectObject(pOldBitmap);
     memDC.DeleteObject();     }不想写了,太乱了,你找本书看一下。

解决方案 »

  1.   

    这样写是不太好的!如果你是在View中作画,你可以
    1.在OnInit...()中开一个Timer.(SetTimer(...))。
    2.用一个成员变量CBitmap存你可画的图。
    3.在OnDraw()中把CBitmap画到View上。
    4.在OnTimer()中把CBitmap的图换一下。
      

  2.   

    在Ontimer成员函数里添加以下代码:
          m_hBitmap.LoadBitmap(IDB_BITMAP); 
          CDC* pDC=GetDC();
          BITMAP bmpInfo;
          m_hBitmap.GetBitmap(&bmpInfo);      // Create an in-memory DC compatible with the
          // display DC we're using to paint
          CDC dcMemory;
          dcMemory.CreateCompatibleDC(pDC);      // Select the bitmap into the in-memory DC
          CBitmap* pOldBitmap = dcMemory.SelectObject(&m_hBitmap);      // Find a centerpoint for the bitmap in the client area
          CRect rect1;
          GetClientRect(&rect1);
          int nX = rect1.left + (rect1.Width() - bmpInfo.bmWidth) / 2;
          int nY = rect1.top + (rect1.Height() - bmpInfo.bmHeight) / 2;      // Copy the bits from the in-memory DC into the on-
          // screen DC to actually do the painting. Use the centerpoint
          // we computed for the target offset.
          pDC->BitBlt(nX, nY, bmpInfo.bmWidth, bmpInfo.bmHeight, &dcMemory,0, 0, SRCCOPY);      dcMemory.SelectObject(pOldBitmap);*/