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}