我在对话框里使用了一个图片控件,但如何设置它的背景颜色呢?

解决方案 »

  1.   

    CWnd * pWnd=AfxGetMainWnd()->GetDlgItem )(IDC_DRAWPLAN);
    WINDOWPLACEMENT RedrawWndPlace;
           pWnd->GetWindowPlacement(&RedrawWndPlace);
            CRect WndRect(RedrawWndPlace.rcNormalPosition);
    ////////////
    CPoint topleftpt;
                  topleftpt=WndRect.TopLeft();
                    int   left=topleftpt.x;
           int   top=topleftpt.y;
       int   nwidth=WndRect.Width();
       int   nheight=WndRect.Height();
             CDC* pDC;
             pDC=GetDC();
         CDC MemDC; //首先定义一个显示设备对象
                 CBitmap MemBitmap;//定义一个位图对象
                 MemDC.CreateCompatibleDC(NULL);
                 MemBitmap.CreateCompatibleBitmap(pDC,nwidth,nheight);
                 CBitmap *pOldBit=MemDC.SelectObject(&MemBitmap);
     MemDC.FillSolidRect(0,0,nwidth,nheight,RGB(0,0,0));//背景设为黑色
    pDC->BitBlt(left,top,nwidth,nheight,&MemDC,0,0,SRCCOPY);