We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


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

Ruben1717 asked
Medium Priority
Last Modified: 2013-11-20
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 );


I could pass the CImage into a picure control.

  CStatic m_PictureBx;

   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?

Watch Question

IT Professional
Top Expert 2005
You may use 'CPictureHolder' class for this....


CPictureHolder pic;

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

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


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Thank you very much, it worked.
mahesh1402IT Professional
Top Expert 2005

>>Thank you very much, it worked.

Then why Grade 'B' ????



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.

Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.