现在有一个小问题,
要给对话框加一背景图片,
要求:
    图片从文件中读取;
    对话框上的button,edit等控件不能被图片覆盖掉.
高手们指导一下,给出代码参考啊,
谢啦!

解决方案 »

  1.   

    在OnPaint或者OnCtrlColor中都应该可以吧,只是要把文件Load进来。
      

  2.   

    要加picture控件吗?
    我直接用picture控件load一幅图片,
    但是把其它的控件就覆盖掉了,
    现在的要求是不是覆盖掉其它的控件
      

  3.   

    可以参考这个帖子:
    http://topic.csdn.net/t/20040126/14/2681701.html
      

  4.   


    int   nBmpX;   
      int   nBmpY;   
      HDC   hDC;   
      CBitmap   hBitmap;
     hBitmap.LoadBitmap(IDB_BITMAP1);  
      BITMAP   bmp;   
      GetObject(hBitmap,sizeof(bmp),&bmp);   
      nBmpX=bmp.bmWidth;   
      nBmpY=bmp.bmHeight;   
      hDC=CreateCompatibleDC(NULL);   
      SelectObject(hDC,hBitmap);   
      CClientDC   dcc(this);   
      StretchBlt(dcc,0,0,nBmpX,nBmpY,hDC,0,0,nBmpX,nBmpY,SRCCOPY);
      

  5.   

    void CMyDlg::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
    {
    int   nBmpX;   
      int   nBmpY;   
      HDC   hDC;   
      CBitmap   hBitmap;
     hBitmap.LoadBitmap(IDB_BITMAP1);  
      BITMAP   bmp;   
      GetObject(hBitmap,sizeof(bmp),&bmp);   
      nBmpX=bmp.bmWidth;   
      nBmpY=bmp.bmHeight;   
      hDC=CreateCompatibleDC(NULL);   
      SelectObject(hDC,hBitmap);   
      CClientDC   dcc(this);   
      StretchBlt(dcc,0,0,nBmpX,nBmpY,hDC,0,0,nBmpX,nBmpY,SRCCOPY);   
    CDialog::OnPaint();
    }
    }