How to pass a bitmap parameter to a COM object?

A

aruizdeinfante

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top