zoukankan      html  css  js  c++  java
  • 利用画面保存设备上下文

    今天搞了下画图。。。。

    没有实现自己想要的结果。。。

    总有闪烁的问题。。。。明天来解决了。。。要熄灯了


    BOOL CDBufferDlg::OnEraseBkgnd( CDC* pDC )
    {
     CDC MemDc;
     CRect rt;
     this->GetClientRect(&rt);
     MemDc.CreateCompatibleDC(pDC);
     MemDc.SelectObject(&m_Bitmap[0]);
    // pDC->BitBlt(0,0,m_hBitmap[0].bmWidth,m_hBitmap[0].bmHeight,&MemDc,0,0,SRCCOPY);
     pDC->StretchBlt(0,0,rt.Width(),rt.Height(),&MemDc,0,0,m_hBitmap[0].bmWidth,m_hBitmap[0].bmHeight,SRCCOPY);
     return FALSE;
    }

    void CDBufferDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
    {
     // TODO: Add your message handler code here and/or call default
     CRect rt;
     GetClientRect(&rt);
     switch(nChar)
     {
     case 'W':
      {
       if (y>rt.top&&y<rt.bottom)
       {
        y = y-m_Speed;
       }
       m_Mode = UP;
       SetBitmap(UP);
      }
      break;
     case 'S':
      {
       if (y<rt.bottom-40&&y>=rt.top)
       {
        y = y+m_Speed;
       }
       m_Mode = DOWN;
       SetBitmap(DOWN);
      }
      break;
     case 'A':
      {
       if (x>rt.left&&x<=rt.right)
       {
        x = x-m_Speed;
       }
       m_Mode = LEFT;
       SetBitmap(LEFT);
      }
      break;
     case 'D':
      {
       if (x>=rt.left&&x<rt.right-40)
       {
        x = x+m_Speed;
       }
       m_Mode = RIGHT;
       SetBitmap(RIGHT);
      }
      break;
     default:
      break;
     }
    // InvalidateRect(&rt,TRUE);
     CDialog::OnKeyDown(nChar, nRepCnt, nFlags);
    }

    void CDBufferDlg::SetBitmap(Mode mode)
    {
     CRect rt;
     GetClientRect(&rt);
     CDC memDC;
     CDC *pDC = GetDC();
     memDC.CreateCompatibleDC(pDC);
     memDC.SelectObject(&m_Bitmap[mode]);
     int i = pDC->SaveDC();
     CRgn rgn;
     rgn.CreateRectRgn(0,0,m_hBitmap[mode].bmWidth,m_hBitmap[mode].bmHeight);
     pDC->SelectClipRgn(&rgn);
     pDC->BitBlt(x,y,m_hBitmap[mode].bmWidth,m_hBitmap[mode].bmHeight,&memDC,0,0,SRCCOPY);
     pDC->RestoreDC(i);
     pDC->BitBlt(x,y,m_hBitmap[mode].bmWidth,m_hBitmap[mode].bmHeight,&memDC,0,0,SRCCOPY);
     
    }

  • 相关阅读:
    Excel Rendering Limitations
    Output Caching and VaryByParam, VaryByCustom
    ajaxToolkit:AutoCompleteExtender 使用键值对
    Sql Server 2005 存储过程分页
    WEB前端优化
    processModel Element in Machine.config
    如何监测虚拟内存
    MemoryLimit Tuning (ASP.NET v1.1)
    缓存之SqlDependency
    SQL产生随机字符串
  • 原文地址:https://www.cnblogs.com/ccmfc/p/1717662.html
Copyright © 2011-2022 走看看