有一个.bmp格式的图片.新建了一个基于对话框的MFC程序,怎么把这个图片作为对话框的背景显示?
很多项目的第一步就是这个东西,看项目实录书的时候,书上没怎么写啊,所以请教一下大家》》
最好带详细步骤.....3Q

解决方案 »

  1.   


    OnEraseBkgnd(CDC* pDC)
    {
    CBitmap   bitmap; 
    bitmap.LoadBitmap(IDB_BUS_BMP);  BITMAP   bmp;
    bitmap.GetBitmap(&bmp); CDC   dcCompatible;
    dcCompatible.CreateCompatibleDC(pDC);  dcCompatible.SelectObject(&bitmap);
    CRect   rect;
    //GetClientRect(&rect); 
    GetWindowRect(&rect);
    pDC-> StretchBlt(0,0,rect.Width(),rect.Height(),&dcCompatible,
    0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
    // return CDialog::OnEraseBkgnd(pDC);
    return TRUE;
    }添加OnEraseBkgnd消息
      

  2.   

    http://zhidao.baidu.com/question/65164880
    http://hi.baidu.com/%D4%C2%BD%FC%D0%C7%D4%B6/blog/item/2802d2fb37449d274e4aea36.html
      

  3.   

    CBitmap m_bmpBackground;
    m_bmpBackground.LoadBitmap(IDB_BITMAPBACKGROUND);在void C**Dlg::OnPaint() 中,
    if (IsIconic())
    {
    CPaintDC dc(this); // device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0); // Center icon in client rectangle
    int cxIcon = GetSystemMetrics(SM_CXICON);
    int cyIcon = GetSystemMetrics(SM_CYICON);
    CRect rect;
    GetClientRect(&rect);
    int x = (rect.Width() - cxIcon + 1) / 2;
    int y = (rect.Height() - cyIcon + 1) / 2; // Draw the icon
    dc.DrawIcon(x, y, m_hIcon);
    }
    else
    {
    // CDialog::OnPaint();
    CPaintDC dc(this);
    CRect rect;
    GetClientRect(&rect);
    CDC dcMem; 
    dcMem.CreateCompatibleDC(&dc); 
    BITMAP bitMap;
    m_bmpBackground.GetBitmap(&bitMap);
    CBitmap *pbmpOld=dcMem.SelectObject(&m_bmpBackground);
    dc.StretchBlt(0,0,rect.Width(),rect.Height(),&dcMem,0,0,bitMap.bmWidth,bitMap.bmHeight,SRCCOPY);
    }
      

  4.   

    怎么把在E盘根目录下的.bmp文件添加到resource view中,使其ID为IDB