Yaniv C

Hi

I'm new to BHO development and to the ATL sink concept. I'm currently developing BHO on top of IE7 using VS 2005.

The problem I'm facing is that whenever the BeforeNavigate2 event is fired and the handler method is being called, all the VARIANT* parameters are bad ( meaning they are either NULL value or contain bad addresses). this happens for all the URL I've browsed to so far. e.g. www.hotmail.com

I have created the following ATL object to handle the browser events:

Code Block

class ATL_NO_VTABLE CBHOExtension :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CBHOExtension, &CLSID_BHOExtension>,
public IObjectWithSiteImpl<CBHOExtension>,
public IDispatchImpl<IBHOExtension, &IID_IBHOExtension, &LIBID_BHOExtensionBHOLib, /*wMajor =*/ 1, /*wMinor =*/ 0>,
public IDispEventImpl<1, CBHOExtension, &DIID_DWebBrowserEvents2, &LIBID_SHDocVw, 1, 1>

in order to handle the BeforeNavigate2 event I used the follwing well known ATL macro:

Code Block

BEGIN_SINK_MAP(CBHOExtension )

SINK_ENTRY_EX(1, DIID_DWebBrowserEvents2, DISPID_BEFORENAVIGATE2, BeforeNavigate2)

END_SINK_MAP()

The method that handles the BeforeNavigate2 event is declared as following in the object:

Code Block

void STDMETHODCALLTYPE BeforeNavigate2(IDispatch *pDisp,

VARIANT *&url,

VARIANT *&Flags,

VARIANT *&TargetFrameName,

VARIANT *&PostData,

VARIANT *&Headers,

VARIANT_BOOL *&Cancel);

Can anyone advise

Many Thanks

Yaniv



Re: Internet Explorer Extension Development BeforeNavigate2 gets bad parameter values

Yaniv C

Hi All

It seems that I was able to bypass the problem. I implemented the Invoke method and was able to extract the value from the raw parameters.

Something must be wrong with the marshaling implementation provided by the SINK macro provided by microsoft mentioned in my previous post above.

Yaniv





Re: Internet Explorer Extension Development BeforeNavigate2 gets bad parameter values

intargent

The declaration of BeforeNavigate2 should be :

Code Block

void STDMETHODCALLTYPE BeforeNavigate2(IDispatch *pDisp,
VARIANT *url,
VARIANT *Flags,
VARIANT *TargetFrameName,
VARIANT *PostData,
VARIANT *Headers,
VARIANT_BOOL *Cancel
);