// just a demo
// this example tell you how to load 
// bmp file and display on view
   HBITMAP bitmap;
   /////读取位图文件SAMPLE.BMP
   bitmap=(HBITMAP)LoadImage(AfxGetInstanceHandle(),"SAMPLE.BMP",IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);
   ASSERT(bitmap);
   HBITMAP OldBitmap;
   CDC MemDC;CRect rect;
   MemDC.CreateCompatibleDC(&dc);
   GetClientRect(rect);
   OldBitmap=(HBITMAP)MemDC.SelectObject(bitmap);
   ///显示它
   dc.BitBlt(20,20,rect.Width()-20,rect.Height()-20,&MemDC,0,0,SRCCOPY);
   MemDC.SelectObject(OldBitmap);

解决方案 »

  1.   

    http://www.codeguru.com/bitmap/draw_bmp.shtml
      

  2.   

    or:
    1:Create your own CBitmap derived class (say, CMyBitmap) 
    2:add a "load from bitmap" method as listed below BOOL CMyBitmap::LoadBitmap(LPCTSTR szFilename) 

    ASSERT(szFilename);
    DeleteObject();
    HBITMAP hBitmap = NULL; 
    hBitmap = (HBITMAP)LoadImage(NULL, szFilename, IMAGE_BITMAP, 0, 0, 
    LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE); 
    return Attach(hBitmap); 
    }