情况是:m_bmp是CBitmap的对象 ,m_picture是对话框上的图形控件对应的变量,该BMP图存放在D:\hanjie\picture1上:代码是这样的:在OnInitDlg()中:m_bmp.LoadBitmap("D:\hanjie\picture1");
m_picture.SetBitmap(m_bmp);

解决方案 »

  1.   

    BOOL CAboutDlg::OnInitDialog() 
    {
       CDialog::OnInitDialog();
       HBITMAP m_hBmp = (HBITMAP)::LoadImage(0,
          "D:\\\\bitmap.bmp",
          IMAGE_BITMAP,
          0,
          0,
          LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
       _ASSERT(m_hBmp!=NULL);
       m_pBmp = CBitmap::FromHandle(m_hBmp);
       return TRUE;
    }void CAboutDlg::OnPaint() 
    {
       CPaintDC dc(this);
       BITMAP bm;
       CDC dcMem;
       VERIFY(m_pBmp->GetObject(sizeof(bm),(LPVOID)&bm));
       dcMem.CreateCompatibleDC(&dc);
       CBitmap *pOldBMP=(CBitmap *)dcMem.SelectObject(m_pBmp);
       BitBlt(dc.m_hDC,0, 0, bm.bmWidth, bm.bmHeight, dcMem.m_hDC, 0, 0, SRCCOPY);
       dcMem.SelectObject(pOldBMP);
       // Do not call CDialog::OnPaint() for painting messages
    }
      

  2.   

    运行时该函数返回空值:
    HBITMAP m_hBmp = (HBITMAP)::LoadImage(0,
          "D:\\\\bitmap.bmp",
          IMAGE_BITMAP,
          0,
          0,
          LR_LOADFROMFILE | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
    不知是什么原因?
     皮皮0714:您讲的是从资源中获得位图,我的意图是从硬盘上读取位图,因为我的位图是放在数据库中的一个字段上,该字段的内容是存放该位图的地址。
      

  3.   

    m_hBmpNew =  (HBITMAP) LoadImage(
    AfxGetInstanceHandle(),   // handle to instance
    file,  // name or identifier of the image (root is where project is)
    IMAGE_BITMAP,        // image types
    0,     // desired width
    0,     // desired height
    LR_LOADFROMFILE); 
      

  4.   

    在VCKBASE网站有例子源代码可以下载
      

  5.   

    CBitmap不能直接从文件中加装位图,只能从资源中加装..得用::LoadImage把位图装载进内存后装得到的位图句柄Attach到CBitmap对象上