Help and Support
 

powered byLive Search

How to programmatically activate a band object

Retired KB ArticleThis article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
Article ID:255920
Last Review:July 15, 2004
Revision:2.3
This article was previously published under Q255920

SUMMARY

The only supported way to programmatically show and hide a band object (such as an Explorer Bar, CommBand, or ToolBand) in Internet Explorer is to use the IWebBrowser2::ShowBrowserBar method.

Back to the top

MORE INFORMATION

In many cases, developers of band objects want to be able to automatically display their band object when the user starts a new instance of Internet Explorer. The best way to achieve this functionality is to use a Browser Helper Object (BHO) in conjunction with the band object. In this way, the BHO can decide whether or not to programmatically activate the band object based on registry keys or other settings persisted by the band object itself.

To build a minimal BHO that can programmatically activate a band object (the Search bar, in this example), you can create a new ATL/COM AppWizard project and add a new Internet Explorer object. Then, override IObjectWithSite::SetSite to achieve the desired functionality. The new SetSite implementation should look as follows:
STDMETHODIMP CShowBarObj::SetSite(IUnknown *pUnkSite)
{
   if (NULL != pUnkSite)
   {
      IWebBrowser2 *pBrowser = NULL;
      // Ensure that our site is an browser window
      HRESULT hr = pUnkSite->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;
         vtBandGUID.bstrVal = SysAllocString(OLESTR("{30D02401-6A81-11D0-8274-00C04FD5AE38}"));
         vtShow.vt = VT_BOOL;
         vtShow.boolVal = true;
         pBrowser->ShowBrowserBar(&vtBandGUID, &vtShow, 0);
         SysFreeString(vtBandGUID.bstrVal);
         pBrowser->Release();
      }
   }
   return S_OK;
}
Also, you must include the header file ExDisp.h in the code and append the following code to the RGS file used for DLL self-registration. Note that you must replace "{77D54ACE-09A9-11D4-8ACE-00C04F542830}" with the CLSID of your BHO:
HKLM { 
   SOFTWARE { 
      Microsoft { 
         Windows { 
            CurrentVersion { 
               Explorer { 
                  'Browser Helper Objects' {
                         {77D54ACE-09A9-11D4-8ACE-00C04F542830}
                            } 
                        } 
                    } 
                } 
            } 
        } 
    }

Back to the top

REFERENCES

Browser Helper Objects: The Browser the Way You Want It
http://msdn.microsoft.com/library/techart/bho.htm (http://msdn.microsoft.com/library/techart/bho.htm)

IWebBrowser2::ShowBrowserBar Method
http://msdn.microsoft.com/workshop/browser/webbrowser/reference/IFaces/IWebBrowser2/ShowBrowserBar.asp (http://msdn.microsoft.com/workshop/browser/webbrowser/reference/IFaces/IWebBrowser2/ShowBrowserBar.asp)

Back to the top


APPLIES TO
Microsoft Internet Explorer 4.0 128-Bit Edition
Microsoft Internet Explorer 4.01 Service Pack 2
Microsoft Internet Explorer 4.01 Service Pack 1
Microsoft Internet Explorer 5.0
Microsoft Internet Explorer 5.01
Microsoft Internet Explorer 5.5

Back to the top

Keywords: 
kbbandobjs kbhowto KB255920

Back to the top

Article Translations

 

Other Support Options

  • Need More Help?
    Contact a Support professional by Email, Online or Phone.
  • Customer Service
    For non-technical assistance with product purchases, subscriptions, online services, events, training courses, corporate sales, piracy issues, and more.
  • Newsgroups
    Pose a question to other users. Discussion groups and Forums about specific Microsoft products, technologies, and services.