Link to home
Start Free TrialLog in
Avatar of Ruben1717
Ruben1717Flag for United States of America

asked on

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?



ASKER CERTIFIED SOLUTION
Avatar of mahesh1402
mahesh1402
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Ruben1717

ASKER

Thank you very much, it worked.
>>Thank you very much, it worked.

Then why Grade 'B' ????

MAHESH
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.