我要为我的对话框添加背景图片(注:图片是在一个文件下,不在资源里,可以通过路径取得文件名)
应该怎么做??假如图片在"c\123.bmp";代码完整点

解决方案 »

  1.   

    如果图片是在应用程序同一个目录下可以这样取
    char szFilename[255] = {0};
    ::GetModuleFileName(NULL, szFilename, 255);
    ::GetCurrentDirectory(256 ,szFilename);
    strcat(szFilename,"\\123.bmp");
    szFilename就是完整的路径啦
      

  2.   

    BOOL StretchBlt(
      HDC hdcDest,      // handle to destination DC
      int nXOriginDest, // x-coord of destination upper-left corner
      int nYOriginDest, // y-coord of destination upper-left corner
      int nWidthDest,   // width of destination rectangle
      int nHeightDest,  // height of destination rectangle
      HDC hdcSrc,       // handle to source DC
      int nXOriginSrc,  // x-coord of source upper-left corner
      int nYOriginSrc,  // y-coord of source upper-left corner
      int nWidthSrc,    // width of source rectangle
      int nHeightSrc,   // height of source rectangle
      DWORD dwRop       // raster operation code
    );
    在画图时用它就OK了 !
      

  3.   

    用StretchBlt()就可以了实现了
    但是我想明白,你的要覆盖的位置大小是否为“像素0,0 到 像素 500,500 之间”,就是当图覆盖上去之后是否为原来的图的比例,而不用伸展或放缩什么的
      

  4.   

    不是吧,不知道你的贴图上去那一块具体是怎么做的,可以贴代码出来看一下
    int nXOriginSrc,  // 0
      int nYOriginSrc,  // 0
      int nWidthSrc,    //500
      int nHeightSrc,   // 500
      

  5.   

    我是这样做的RECT rect;
      CDC *mdc=new CDC;
      CDC * dc = GetDC();  HBITMAP h_bitmap;
      GetClientRect(&rect); 
      h_bitmap = (HBITMAP)::LoadImage(NULL,"D:\\op4-2004-7-10  \\Bin\\Skin\\skin.bmp",IMAGE_BITMAP,rect.right,rect.bottom,LR_LOADFROMFILE);
      mdc->CreateCompatibleDC(dc);
      mdc->SelectObject(h_bitmap);   
     StretchBlt(dc->m_hDC,0,0,rect.right,rect.bottom,mdc-      >m_hDC,0,0,rect.right,rect.bottom,SRCCOPY);
      if(mdc) delete mdc;
      if(dc) ReleaseDC(dc);
      UpdateData(FALSE);
      

  6.   

    不用拉伸,缩放,可以用BitBlt(),
      

  7.   

    jmlt1983(Harper) ( ) 信誉:100 
    你QQ或MSN是多少?加你QQ或MSN说吧