why my class derived from CHtmlView cannot show the 'Search' bar
-
i write a class derived from CHtmlView, and write the code as below, when it run, no bar appear, and a messageBox show a string '0x80040100', what is the reason? how can i make it work. any suggestion or help are appreciated
void CXxView::OnShowBar()
{
IWebBrowser2 *pBrowser = NULL;
// Ensure that our site is an browser window
HRESULT hr = m_pBrowserApp->QueryInterface(IID_IWebBrowser2, (void **) &pBrowser);
if (SUCCEEDED(hr))
{
// Display the band object (the Search bar in this case)
VARIANT vtBandGUID, vtShow;
vtBandGUID.vt = VT_BSTR;
//change the CLSID as your bar CLSID
vtBandGUID.bstrVal = SysAllocString(OLESTR("{30D02401-6A81-11d0-8274-00C04FD5AE38}"));
vtShow.vt = VT_BOOL;
vtShow.boolVal = TRUE;
HRESULT hrx = pBrowser->ShowBrowserBar(&vtBandGUID, &vtShow, 0);
if (FAILED(hrx))
{
CString _str;
_str.Format("0x%x", hrx);
AfxMessageBox(_str);
}SysFreeString(vtBandGUID.bstrVal); pBrowser->Release(); }
}