We help IT Professionals succeed at work.
Get Started

Problem Compiling IE BHO 'Expando' solution with IDispatchEx interface

qualityhack
qualityhack asked
on
2,399 Views
Last Modified: 2013-12-03
Hello All,
I am having a problem getting the sample given by Igor to compile.
http://groups.google.ca/groups?q=igor+javascript+bho&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OgXvZkltCHA.1844%40TK2MSFTNGP09&rnum=2

I put the following code in the Invoke() method of my Toolbar...

      case DISPID_NAVIGATECOMPLETE2:
      {
// toolbar to sink NavigateComplete2 event and install an IDispatch pointer to
// some object it implements as a property of window object.
//
// This code is adapted from...
// http://groups.google.ca/groups?q=bho+javascript+igor&hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=OUSLCdyJBHA.1952%40tkmsftngp02&rnum=4
// which was written by Igor Tandetnik (the BHO/Toolbar Guru)
//
// This will allow me to script the following on a web page ...
// window.TickerToolbar.foo();
//
            IDispatch *frame;
            m_webBrowserPtr->get_Document( &frame );

            IHTMLDocument2Ptr docPtr( frame );
            
            IHTMLWindow2 *pWindow;
            
            docPtr->get_parentWindow( &pWindow );
            
            IDispatchExPtr wndExPtr( pWindow );
            IDispatchEx *pWndEx;

            DISPID dispid;

            wndExPtr->GetDispID( "TickerToolbar", fdexNameEnsure, &dispid);
            
            DISPPARAMS dispparamsNoArgs = {NULL, NULL, 0, 0};
            pWndEx->InvokeEx( dispid,  LOCALE_USER_DEFAULT , DISPATCH_PROPERTYPUTREF,
                  this , NULL , NULL , NULL );
            break;
      }

///////////////////////////////////////////////////////////////////
I can send anybody a sample VC6 project that creates an IE Toolbar and has this compile error.

The compile errors I get are as follows:

C:\expando\CTBImplCOM.Cpp(501) : error C2027: use of undefined type 'IDispatchEx'
        C:\Program Files\Microsoft SDK\Include\comdef.h(476) : see declaration of 'IDispatchEx'
C:\expando\CTBImplCOM.Cpp(501) : error C2039: 'GetDispID' : is not a member of '_com_ptr_t<class _com_IIID<struct IDispatchEx,&struct __s_GUID _GUID_a6ef9860_c720_11d0_9337_00a0c90dcaa9> >'
C:\expando\CTBImplCOM.Cpp(501) : error C2065: 'fdexNameEnsure' : undeclared identifier
C:\expando\CTBImplCOM.Cpp(504) : error C2027: use of undefined type 'IDispatchEx'
        C:\Program Files\Microsoft SDK\Include\comdef.h(476) : see declaration of 'IDispatchEx'
C:\expando\CTBImplCOM.Cpp(504) : error C2227: left of '->InvokeEx' must point to class/struct/union

It seems that the declaration of IDispatchEx *pWndEx; is OK since the compiler doesn't complain there.
So IDispatchEx is included in a header file.
But when I used it at wndExPtr->GetDispID(  it says it is an undefined type.

Help! I'm assume this is an easy problem but I can't see it.

Thanks
David Brooks
Comment
Watch Question
Commented:
This problem has been solved!
Unlock 1 Answer and 3 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE