Joseph M. Newcomer wrote:
Yes, that is ugly, and it would much easier to do
CBitmap Bmp;
bmp.Attach((HBITMAP)::LoadImage(NULL, _T("test.bmp"), IMAGE_BITMAP,
0,0, LR_LOADFROMFILE);
if((HBITMAP)bmp != NULL)
m_ImageList.Add(&Bmp, RGB(0,0,0));
Bmp.DestroyObject();
or better still
BOOL AddImage(LPCTSTR filename, CImageList & imagelist)
{
CBitmap Bmp;
Bmp.Attach( (HBITMAP)::LoadImage(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
if((HBITMAP)Bmp == NULL)
return FALSE;
imagelist.Add(&Bmp, RGB(0,0,0));
}
which makes it easy:
AddImage(_T("test1.bmp"), imagelist);
AddImage(_T("test2.bmp"), imagelist);
CString name = ... name of bitmap file
AddImage(name, imagelist);
joe
On Wed, 29 Aug 2007 15:14:25 -0500, "AliR \(VC++ MVP\)" <AliR@online.nospam> wrote:
This looks ugly but seems to be the only way.
CImage image;
image.Load("test.bmp");
CBitmap Bmp;
Bmp.Attach(image.Detach();
m_ImageList.Add(&Bmp,RGB(0,0,0));
Bmp.DestroyObject();
image.Load("test2.bmp");
Bmp.Attach(image.Detach();
m_ImageList.Add(&Bmp,RGB(0,0,0));
Bmp.DestroyObject();
...
AliR.
"Frank S" <JazzedApps@community.nospam> wrote in message
news:uRIAUYn6HHA.4584@TK2MSFTNGP03.phx.gbl...
I want to use an image list with a list control. I am using CImage to load
a bitmap file (actually several files) like:
CImage image;
image.Load("test.bmp");
How do I add this image to a CImageList, which can then be used by the
list control?
--
Regards,
Frank
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm