//在内存DC中画图
    m_dcMem.FillSolidRect(0,0,m_nWidth,m_nHeight,m_dwBgColor);
    CPen pen;
    pen.CreatePen(PS_SOLID,2,m_dwLineColor);
    CPen *old=m_dcMem.SelectObject(&pen);
    
    m_dcMem.MoveTo(m_nCenterX,m_nCenterY-m_nY);
    m_dcMem.LineTo(m_nCenterX,m_nCenterY);
    m_dcMem.LineTo(m_nCenterX+m_nX,m_nCenterY);    m_dcMem.SelectObject(old);
    DeleteObject(pen);
第一行的背景色m_dwBgColor和第三行的线颜色m_dwLineColor怎么改都只出现黑白两色 ,而在pDC中画就 正常OnDraw
pDC->BitBlt(0,0,m_nWidth,m_nHeight,&m_dcMem,0,0,SRCCOPY);//OnInitialUpdate()中
    CDC *pDC;
    pDC=GetDC();
    m_dcMem.CreateCompatibleDC(pDC);
    bitMap.CreateCompatibleBitmap(&m_dcMem,1024,768);
    m_dcMem.SelectObject(bitMap);
    ReleaseDC(pDC);以下界面显示为黑
FillSolidRect(0,0,m_nWidth,m_nHeight,RGB(0,0,255));
FillSolidRect(0,0,m_nWidth,m_nHeight,RGB(0,0,0));
FillSolidRect(0,0,m_nWidth,m_nHeight,RGB(255,0,0));
以下为白
FillSolidRect(0,0,m_nWidth,m_nHeight,RGB(255,255,255));
FillSolidRect(0,0,m_nWidth,m_nHeight,RGB(255,255,0)); 
FillSolidRect(0,0,m_nWidth,m_nHeight,RGB(255,0,255));后来发现更见鬼的是
把m_dwBgColor射程RGB(255,255,255)
把m_dwLineColor设成RGB(255,0,0)
背景显示的是白  线是黑
把m_dwBgColor射程RGB(0,0,255),dwLineColor不变
背景变黑,线变白了

解决方案 »

  1.   

     bitMap.CreateCompatibleBitmap(&m_dcMem,1024,768);//创建的是单色位图
    //改成 如下试试    CDC *pDC;
        pDC=GetDC();
        m_dcMem.CreateCompatibleDC(pDC);
        bitMap.CreateCompatibleBitmap(pDC,1024,768);//不要用内存DC
        m_dcMem.SelectObject(bitMap);
        ReleaseDC(pDC);
      

  2.   

    有道理,msdn上如是说:When a memory device context is created, GDI automatically selects a monochrome stock bitmap for it.Because a color memory device context can have color or monochrome bitmaps selected, the format of the bitmap returned by the CreateCompatibleBitmap function is not always the same; however, the format of a compatible bitmap for a nonmemory device context is always in the format of the device.