당신은 소중한 사람이 있나요? | 바람전설
http://blog.naver.com/pkl95/40008086966
http://blog.naver.com/pkl95/40008086966
void GetImageFromList(CImageList *lstImages, int nImage, CBitmap *destBitmap)
{
//First we want to create a temporary image list we can manipulate
CImageList tmpList;
tmpList.Create(lstImages);
//Then swap the requested image to the first spot in the list
tmpList.Copy( 0, nImage, ILCF_SWAP );
//Now we need to get som information about the image
IMAGEINFO lastImage;
tmpList.GetImageInfo(0,&lastImage);
//Heres where it gets fun
//Create a Compatible Device Context using
//the valid DC of your calling window
CDC dcMem; dcMem.CreateCompatibleDC (GetWindowDC());
//This rect simply stored the size of the image we need
CRect rect (lastImage.rcImage);
//Using the bitmap passed in, Create a bitmap
//compatible with the window DC
//We also know that the bitmap needs to be a certain size.
destBitmap->CreateCompatibleBitmap (this->GetWindowDC(),
rect.Width (), rect.Height ());
//Select the new destination bitmap into the DC we created above
CBitmap* pBmpOld = dcMem.SelectObject (destBitmap);
//This call apparently "draws" the bitmap from the list,
//onto the new destination bitmap
tmpList.DrawIndirect (&dcMem, 0, CPoint (0, 0),
CSize (rect.Width (), rect.Height ()), CPoint (0, 0));
//cleanup by reselecting the old bitmap object into the DC
dcMem.SelectObject (pBmpOld);
}
- 예제 소스 -
CImageList m_ImageTree;
CBitmap m_SigleBitmap1;
CStatic m_ColorStatic;
CBitmap bmp;
m_ImageTree.Create(16, 16, ILC_COLOR24 | ILC_MASK, 7, 1);
bmp.LoadBitmap(IDB_TREE);
m_ImageTree.Add( &bmp, RGB(255,255,255));
bmp.DeleteObject();
//이미지 리스트의 첫번째 그림
GetImageFromList(&m_ImageTree, 0, &m_SigleBitmap1);
m_ColorStatic.ModifyStyle(SS_CENTER, SS_BITMAP,0);
m_ColorStatic.SetBitmap((HBITMAP)m_SigleBitmap1);
댓글
댓글 쓰기