In case anyone has the same problem in the future, the problem was that I hadn't implemented the nsIInterfaceRequestor interface. Specifically the code that handles updating the status during link hovering uses nsIInterfaceRequestor::GetInterface to find the nsIWebBrowserChrome interface.
BTW, careful perusal of the winEmbed source showed the way.
Cheers, Marty.
Martin Kenny wrote:
Hi,
I recently decided to put together a test embedding application (Win32, ATL) from scratch, using the "Gecko Embedding Basics" document as a guide.
I had something working in an hour or two, but what's been bugging me ever since is that I can't get any of the nsIWebBrowserChrome methods (notably SetStatus) to be called at all. This results in no status text when hovering the mouse over a link. When I implement BrowserChromeImpl, OnStateChange *is* called as the page loading state changes.
Nothing seems to even QueryInterface for nsIWebBrowserChrome.
The code to create the browser instance is shown below.
I've kept implementing other interfaces and calling extra methods (as seen in MfcEmbed) in the hope that something would make it start calling the SetStatus method, but no go.
If anyone has seen anything like this, or has a possible explanation, it would be really appreciated.
A zip of the source can be found at: http://www.kennymoy.com.au/mozilla/BlueBall.zip
Cheers, Marty.
//------------------------------------------------------------- nsresult rv; m_webBrowser = do_CreateInstance(NS_WEBBROWSER_CONTRACTID, &rv); if (NS_FAILED(rv)) return rv;
rv = NS_OK; m_webNavigation = do_QueryInterface(m_webBrowser, &rv); if (NS_FAILED(rv)) return rv;
m_browserChromeImpl = new BrowserChromeImpl(m_frameWnd); m_browserChromeImpl->AddRef();
rv = m_webBrowser->SetContainerWindow(static_cast<nsIWebBrowserChrome*>(m_browserChromeImpl));
if (NS_FAILED(rv)) return rv;
rv = NS_OK; m_baseWindow = do_QueryInterface(m_webBrowser, &rv); if (NS_FAILED(rv)) return rv;
rv = m_baseWindow->InitWindow(static_cast<HWND>(*this), nsnull, createStruct->x, createStruct->y, 1, 1);
if (NS_FAILED(rv))
return rv;
rv = m_baseWindow->Create(); if (NS_FAILED(rv)) return rv;
m_webBrowser->AddWebBrowserListener(NS_GetWeakReference(static_cast<nsIWebBrowserChrome*>(m_browserChromeImpl)), NS_GET_IID(nsIWebProgressListener));
rv = m_baseWindow->SetVisibility(PR_TRUE); if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsIWebBrowserFocus> focus(do_GetInterface(m_webBrowser)); focus->Activate();
rv = m_webNavigation->LoadURI(L"http://www.mozilla.org/", nsIWebNavigation::LOAD_FLAGS_NONE, nsnull, nsnull, nsnull);
