PDA

View Full Version : Getitng the browser instance from ActiveQt



baluvasudev
18th April 2010, 08:42
Hello,

I have created an active X control using Active Qt framework which is loaded inside an IE browser. Now i want to retrieve the URL from the browser.

My active X code will look something like this


class ActiveX : public QObject, public QAxBindable
{
...
}

class ObjectSafetyImpl : public QAxAggregated,
public IObjectSafety
{
public:
ObjectSafetyImpl() {}

long queryInterface( const QUuid &iid, void **iface )
{
*iface = 0;
if ( iid == IID_IObjectSafety )
*iface = (IObjectSafety*)this;
else
return E_NOINTERFACE;

AddRef();
return S_OK;
}

QAXAGG_IUNKNOWN;

HRESULT WINAPI GetInterfaceSafetyOptions( REFIID riid, DWORD *pdwSupportedOptions, DWORD *pdwEnabledOptions )
{
*pdwSupportedOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER;
*pdwEnabledOptions = INTERFACESAFE_FOR_UNTRUSTED_DATA | INTERFACESAFE_FOR_UNTRUSTED_CALLER;
return S_OK;
}
HRESULT WINAPI SetInterfaceSafetyOptions( REFIID riid, DWORD pdwSupportedOptions, DWORD pdwEnabledOptions )
{
return S_OK;
}
};

QAxAggregated *ActiveX::createAggregate()
{
return new ObjectSafetyImpl();
}

Now it try to get the browser instance using the following piece of code


IWebBrowser2 *webBrowser = 0;
clientSite()->QueryInterface(IID_IWebBrowser2, (void **)&webBrowser);
BSTR* strHostURL = 0;
if(webBrowser)
webBrowser->get_LocationURL(strHostURL);

But the webBrowser object always turns out to be NULL. Any help???


Thanks,
Vasudev, Balu