Hello
I'm using a COM control in VC++, and the way to pass a picture to the
control is throught this function
void SetObjImage(LPDISPATCH ObjImage);
I have found the way to pass this parameter creating an image throught
CBitmap and CPictureHolder classes:
CPictureHolder pictholder ;
CBitmap bmpAux ;
bmpAux.LoadBitmap (IDB_BITMAP1) ;
pictholder.CreateFromBitmap((HBITMAP)bmpAux.Detach (), NULL, TRUE);
m_obj.SetObjImage (pictholder.GetPictureDispatch ()) ;
but now I want to get the images from a CImageList
// now IDB_BITMAP2 has more than a image
COLORREF crMask = ::GetSysColor (COLOR_HIGHLIGHT) ;
CImageList *ImgLst = new CImageList () ;
ImgLst->Create (IDB_BITMAP2, 16, 100, crMask) ;
IMAGEINFO imgInfo ;
// Get the first image from the list
if (ImgLst->GetImageInfo (0, &imgInfo)) {
HBITMAP hbm = (HBITMAP)imgInfo.hbmImage ;
pictholder.CreateFromBitmap (hbm, NULL, TRUE) ;
m_obj.SetObjImage (pictholder.GetPictureDispatch ()) ;
} ;
delete ImgLst ;
This code doesn't works. It seems that anything is added to the
control, but I can't see the image.
Somebody knows why? How can I do this?
Thank you in advance.