How to show/Hide IE browser tool window

Source: Internet
Author: User
Tags continue

This article describes how to control the display/hide all the IE browser tool windows in the program, such as "collection", "History", "search" and so on to the left window.

Implementation process:

At the same time, there may be N shell windows (including IE windows and file browser windows) in the system, you need to traverse each shell window and exclude the File browser window (because we only handle the IE window) and then get IWebBrowser2, Call the Showbrowserbar function, which is described in MSDN as follows:

HRESULT ShowBrowserBar(VARIANT *pvaClsid,
  VARIANT *pvarShow,
  VARIANT *pvarSize
);

Reusable code as follows (has been tested and cannot be compiled by the compiler please check your own questions or consult Ccrun):

#pragma link "bcbie.lib"
#include "shdocvw_ocx.h"
//---------------------------------------------------------------------------
void __fastcall Myshowiebrowserbar (LPSTR lpclsid, bool bshow)
{
Variant v1, v2, v3;
String Strclsid (LPCLSID);
V1 = Strclsid.c_str (); Tool window CLSID to show/hide
v2 = bshow; Whether to display
V3 = 0; Slightly
//---------------------------------------------------------------------------
Sorry, this hint again, in order to prevent irresponsible reprint, had to leave some information here.
by Ccrun (old demon) info@ccrun.com
Welcome to C++builder Research-http://www.ccrun.com
//---------------------------------------------------------------------------
Tcppshellwindows *pshellwin = new Tcppshellwindows (NULL);
Iterate through each shell window
for (int i=0; i<pshellwin->count; i++)
{
IDispatch *pdisp = (IDispatch *) Pshellwin->item (Variant (i));
if (pdisp = NULL)
Continue
Get IWebBrowser2 interface
IWebBrowser2 *pbrowser;
HRESULT hr = Pdisp->queryinterface (Iid_iwebbrowser2, (void**) &pbrowser);
Pdisp->release ();
if (SUCCEEDED (HR))
{
String strURL = String (Pbrowser->get_locationurl ()); Get browser address
if (Strurl.lowercase (). SubString (1, 5) = = "File:")//Excluding Files Manager
Continue
Pbrowser->showbrowserbar (v1, V2, v3); Show or hide the Browse tool window
}
}
Delete Pshellwin;
}
Myshowiebrowserbar ("{efa24e61-b078-11d0-89e4-00c04fc9e26e}", 1); Show Favorites
Myshowiebrowserbar ("{30d02401-6a81-11d0-8274-00c04fd5ae38}", 0); Hide Search Bar
Other IE tool window CLSID reference:
Favorites {efa24e61-b078-11d0-89e4-00c04fc9e26e}
Folders {efa24e64-b078-11d0-89e4-00c04fc9e26e}
History {efa24e62-b078-11d0-89e4-00c04fc9e26e}
Search {30d02401-6a81-11d0-8274-00c04fd5ae38}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.