Link to home
Start Free TrialLog in
Avatar of qualityhack
qualityhack

asked on

Problem Compiling IE BHO 'Expando' solution with IDispatchEx interface

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
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada 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 qualityhack
qualityhack

ASKER

Awesome! Thank you chensu.
A very simple solution but seemingly impossible for me since I couldn't find any reference to which header files to include anywhere.
I searched high and low for a reference on these interfaces. There's nothing on MSDN on which header files, libaries and service packs are needed.

Where do I learn this stuff so that I don't need to bother the experts with simple questions? :-)

Thanks
David Brooks
First step would be to look it up in the documentation. If you can't find it in the documentation, search all the header files for it to see which one has the definition.