如题。

解决方案 »

  1.   

    http://www.codeguru.com/cpp/w-d/dislog/bitmapsimages/article.php/c1877/
      

  2.   

    在对话框OnPaint()中
    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
    {
    CBitmap* oldBitmap;
    CDC MemDC;
    BITMAP mBitmapInfo;
    CPaintDC dc(this);
    MemDC.CreateCompatibleDC(&dc);
    oldBitmap = MemDC.SelectObject(&m_Bitmap);
                                              //在头文件中定义CBitmap m_Bitmap;
    //在构造函数中m_Bitmap.LoadBitmap(IDB_*);
    m_Bitmap.GetBitmap(&mBitmapInfo);
    CRect rc;
    GetClientRect(&rc);
    dc.StretchBlt(0,0,rc.Width(),rc.Height(),        &MemDC,0,0,mBitmapInfo.bmWidth,mBitmapInfo.bmHeight,SRCCOPY);
    MemDC.SelectObject(oldBitmap);
    MemDC.DeleteDC(); CDialog::OnPaint();
    }
    }
      

  3.   

    OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
    重载这个比较好,
      

  4.   

    使用Static控件,直接在资源里编辑好。
      

  5.   

    将BMP添加到资源里,改资源名为 IDB_BMP_BACKBOOL CDialog::OnEraseBkgnd(CDC* pDC)
    {
        // 重画对话框背景    CBitmap hBitmap;
        hBitmap.LoadBitmap(IDB_BMP_BACK);    CBrush hBursh(&hBitmap);    pDC->FillRect(&rcClient,&hBursh);    return TRUE;
    //  return CDialog::OnEraseBkgnd(pDC);
    }