How do I pass a CImage object to a control that accepts a LPDISPATCH parameter?

I am having problems loading a picture into a control.
I need to load files into the control at run time.
The IDispatch wrapper class for the control looks like this:

class aPictReaderctrl : public CWnd {
   ...
    void SetPicture(LPDISPATCH propVal) {....}
}

I am using  CImage to load a picure like this:
   aPictReaderctrl     cPicureCtl;

   CString   strPicture = "SomePicture.tif";
   CImage  ciPicure;
   HRESULT hResult = ciPicure.Load(strPicture );

  cPicureCtl.SetPicture(??????);

I could pass the CImage into a picure control.

  CStatic m_PictureBx;
   m_PictureBx.SetBitmap((HBITMAP)ciPicure);

   cPicureCtl.SetPicture(m_PictureBx.GetDispatchIID( ?????  ));

but then, what do I use in the parameter to GetDispatchIID( IID *pIID )?

I don't know if there is an easier approach.
Could someone help me?



Ruben1717Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mahesh1402Commented:
You may use 'CPictureHolder' class for this....

e.g.

CPictureHolder pic;

pic.CreateFromBitmap(ciPicure.m_hBitmap); //bitmap handle of CImage::m_hBitmap

cPicureCtl.SetPicture(pic.GetPictureDispatch()); //Attach to IDispatch



MAHESH
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ruben1717Author Commented:
Thank you very much, it worked.
0
mahesh1402Commented:
>>Thank you very much, it worked.

Then why Grade 'B' ????

MAHESH
0
Ruben1717Author Commented:
I am so sorry, I had selected "A",  I think you deserve an "A". I must have accidently clicked on "B". I got a popup window from my test program, just before I clicked submit, and I must have selected the wrong  grade when I reenactivated the screen.  My apologies.  
I am trying to correct the grade now.

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.