2 回答

TA貢獻(xiàn)1803條經(jīng)驗(yàn) 獲得超6個(gè)贊
mfc里導(dǎo)入 圖片資源,自動(dòng)生成一個(gè)資源id(自己改名也可以)比如IDB_BITMAP1
然后
CBitmap bitmap;
bitmap.LoadBitmap(IDB_BITMAP1);
顯示出來的話再接著用dc就可以了
-------------
那試試這樣
m_bitmap.m_hObject = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),
_T("對(duì)應(yīng)路徑...\\bitmap1.bmp"),
IMAGE_BITMAP,
0, 0,
LR_LOADFROMFILE | LR_CREATEDIBSECTION);

TA貢獻(xiàn)1799條經(jīng)驗(yàn) 獲得超9個(gè)贊
CString path=L"c:\\1.bmp";
HBITMAP hbitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),path, IMAGE_BITMAP,0,0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
pictureControlID 為圖像控件ID
CStatic *pStatic=(CStatic *)GetDlgItem(pictureControlID);
HBITMAP hbitmap=(HBITMAP)::LoadImage(AfxGetInstanceHandle(),path, IMAGE_BITMAP,0,0, LR_CREATEDIBSECTION|LR_LOADFROMFILE);
if(hbitmap!=NULL)
{
CBitmap m_bitmap;
m_bitmap.Attach(hbitmap);
pStatic->ModifyStyle(0xF,SS_BITMAP|SS_CENTERIMAGE);
pStatic->SetBitmap(hbitmap);
}
- 2 回答
- 0 關(guān)注
- 1609 瀏覽
添加回答
舉報(bào)