Why Doesn't I get 'IOleWindow*' (in Explorer Bar)
Why Doesn't I get 'IOleWindow*' (in Explorer Bar)
Hi. I'm making an Explorer Bar.
I'm trying to show the bar always.
So I use ShowBrowserBar funciton (in SetSite).
But on a IExplorer, in case the bar isn't checked (to active), I can't
get 'IOleWindow*'.
So I can't use ShowBrowserBar.
STDMETHODIMP CMyBar::SetSite(IUnknown* pUnkSite)
//If a site is being held, release it.
if(m_pSite)
{
m_pSite->Release();
m_pSite = NULL;
}
//If punkSite is not NULL, a new site is being set.
if(pUnkSite)
{
//IExplore.exe =EC=B2=B4=ED=81=AC
TCHAR pszLoader[MAX_PATH];
GetModuleFileName(NULL, pszLoader, MAX_PATH);
_tcslwr(pszLoader);
if (_tcsstr(pszLoader, L"\\iexplore.exe") == NULL) {
return E_FAIL;
}
//Get the parent window.
IOleWindow *pOleWindow = NULL;
m_hWndParent = NULL;
if(SUCCEEDED(pUnkSite->QueryInterface(IID_IOleWindow,
(LPVOID*)&pOleWindow)))
{
pOleWindow->GetWindow(&m_hWndParent);
pOleWindow->Release();
}
if(!::IsWindow(m_hWndParent))
return E_FAIL;
if(!RegisterAndCreateWindow())
return E_FAIL;
IWebBrowser2 *pBrowser = NULL;
// Ensure that our site is an browser window
HRESULT hr = pUnkSite->QueryInterface(IID_IWebBrowser2, (void **)
&pBrowser);
if (SUCCEEDED(hr))
{
VARIANT vtBandGUID, vtShow;
vtBandGUID.vt = VT_BSTR;
vtBandGUID.bstrVal =
SysAllocString(OLESTR("{26EF6040-D3F8-43AA-972A-2F8A80AEF6A3}"));
vtShow.vt = VT_BOOL;
vtShow.boolVal = true;
hr = pBrowser->ShowBrowserBar(&vtBandGUID, &vtShow, 0);
SysFreeString(vtBandGUID.bstrVal);
m_pWebBrowser = pBrowser;
pBrowser->Release();
}
//Get and keep the IInputObjectSite pointer.
if(SUCCEEDED(pUnkSite->QueryInterface(IID_IInputObjectSite,
(LPVOID*)&m_pSite)))
{
return S_OK;
}
return E_FAIL;
}
return S_OK;
}