Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 527
  • Last Modified:

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?



0
Ruben1717
Asked:
Ruben1717
  • 2
  • 2
1 Solution
 
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
 
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now