HI!
i have a problem i want to loadd a bitmap from .bmp file to the views of MDI how to do this.
Thanks
Printable View
HI!
i have a problem i want to loadd a bitmap from .bmp file to the views of MDI how to do this.
Thanks
Hi
i am giving u the sample code to load a bitmap from .bmp file and display it in a CView derived view class.u can put this code in OnDraw() function for test.
//load the bitmap directly from file
HBITMAP hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(),
"C:\\winnt\\winnt.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
//attach it to a CBitmap object
CBitmap bmp;
if(hBitmap)
{
bmp.Attach(hBitmap);
}
//get the bitmap header info
BITMAP bm;
bmp.GetBitmap(&bm);
//create a temporary memory DC
CDC mdc;
mdc.CreateCompatibleDC(pDC);
mdc.SelectObject(&bmp);
//Use CDC::BitBlt() or StretchBlt(); here i have used BitBlt() here
pDC->BitBlt(0,0,bm.bmWidth,bm.bmHeight,&mdc,0,0,SRCCOPY);
//delete the temp DC when finished
mdc.DeleteDC();
Regards
S.K.Pradhan
Be sure to rate answers if it helped, to encourage them.