zoukankan      html  css  js  c++  java
  • MFC中View显示框架

    //View类
        int m_nDCHeight;
        int m_nDCWidth;
        HBITMAP m_hBmp;
        HBITMAP m_hOldBmp;
        CDC m_memDC;
        
        BYTE *m_pFrontBuffer;         // 内存buffer
    ===============================
    //OnSize()
        if (cx < 1 || cy < 1)
        {
            return;
        }
        
        m_nDCHeight = cy;
        m_nDCWidth = cx;
        m_nDCWidth = ((m_nDCWidth + 3) / 4) * 4;
    
        BITMAPINFO bmpInfo;
        bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
        bmpInfo.bmiHeader.biWidth = m_nDCWidth;
        bmpInfo.bmiHeader.biHeight = m_nDCHeight;
        bmpInfo.bmiHeader.biPlanes = 1;
        bmpInfo.bmiHeader.biBitCount = 24;
        bmpInfo.bmiHeader.biCompression = BI_RGB;
        bmpInfo.bmiHeader.biSizeImage = 0;
        bmpInfo.bmiHeader.biXPelsPerMeter = 0;
        bmpInfo.bmiHeader.biYPelsPerMeter = 0;
        bmpInfo.bmiHeader.biClrUsed = 0;
        bmpInfo.bmiHeader.biClrImportant = 0;
    
        if (m_hBmp)
        {
            SelectObject(m_memDC.m_hDC, m_hOldBmp);
            m_hOldBmp = NULL;
            DeleteObject(m_hBmp);
            m_hBmp = NULL;
        }
        m_hBmp = CreateDIBSection(m_memDC.m_hDC, &bmpInfo, DIB_RGB_COLORS, (void **) &m_pFrontBuffer, NULL, 0);
        m_hOldBmp = (HBITMAP)::SelectObject(m_memDC.m_hDC, m_hBmp);
    ===============================
    //OnCreate()
        CDC *pDC = GetDC();
        m_memDC.CreateCompatibleDC(pDC);
        ReleaseDC(pDC);
    ===============================
    //OnDraw()
    BitBlt(pDC->m_hDC, m_scrollStaPos.cx, m_scrollStaPos.cy, m_nDCWidth, m_nDCHeight, m_memDC.m_hDC, 0, 0, SRCCOPY);
    
    //OnMouseMove()
    //一般在这里进行数据读写
    memset(m_pFrontBuffer, 0, m_nDCWidth * m_nDCHeight * 3);
    Invalidate(FALSE);
    ===============================
  • 相关阅读:
    Python练习题 016:猴子吃桃
    Date() 及其 如何验证用户输入的日期是合法的
    关于事件触发的一个小tips
    KVO监听导航栏
    使用CoreText动态下载更换字体
    UICollectionView 的使用
    echarts散点图搭配时间轴
    使用百度echarts画图表的步骤
    canvas画图中drawImage使用
    html5canvas简单画图
  • 原文地址:https://www.cnblogs.com/autumoonchina/p/5755750.html
Copyright © 2011-2022 走看看