Customize Internet Explorer Interface

Source: Internet
Author: User
Customize Internet Explorer Interface
Author: Ling Hu Ye

This article only introduces the IE extension interface and does not involve kernel-level advanced extensions.
Most of the information in this article comes from msdn, and msdn provides more detailed information. This article is just a summary editor.

The basic shell programming in msdn starts with the shell programmers guide,
IE shell programming starts with Browser Extensions overview. (Jump with an index)

Related Resources: 1. The ATL wizard mentioned in this article can be downloaded from the ATL and shell programming pages on www.codetools.com and www.codeguru.com.

Required knowledge: Basic knowledge of COM, ATL, and shell programming.

The IE browser provides programmable external interfaces for interface interfaces that are used to add custom functions. Naturally, these interfaces are provided in the form of COM, that is, ie defines a series of COM interfaces, you implement these interfaces according to its interface regulations. ie calls these interfaces during runtime to complete your custom interface. In addition, you only need to add the registry key for some simple extensions.

There are several basic interface extensions:
1. Add custom menu items to IE context menus, such as NetAnts and falshget.
2. Add custom menu items to the <tools> menu, such as NetAnts, falshget, and MSN message service.
3. Add the Custom button to the Standard toolbar, such as NetAnts and falshget.
4. Add a customized browser bar and toolbar. For example, historical records and radio stations.
5. Capture browser clicks, such as NetAnts and falshget.

The following describes the implementation methods:

1. Add the custom menu item to the IE context menu (you only need to add the Registry item. Use flashget as an example)
① Add a subkey under hkey_current_usersoftwaremicrosoftinternet assumermenuext.
A. The sub-key name is the text displayed on the context menu, for example, <use Internet Express download (& D)>.
B. The default value of this Sub-key is the path of a webpage file, for example, crogram filesflashgetjc_link.htm. The file stores the script of the operation to be executed when the menu item command you wrote is triggered. Program . The script can use external. menuarguments to receive parameters in the current IE running status. For example: < Script Language = " VBScript " >
On   Error   Resume   Next
Set Jetcarcatch = Createobject ( " Jetcar. Netscape " )
If Err <> 0   Then
Msgbox ( " Flashget not properly installed! " + Vbcrlf + " Lease install flashget again " )
Else
Set Links = External.menuarguments.doc ument. Links
Redim Params (links. Length * 2 )
Params ( 0 ) = External.menuarguments.doc ument. url
For I =   0   To Links. Length - 1
Params (I * 2 + 1 ) = Links (I). href
Params (I * 2 + 2 ) = Links (I). innertext
Next  
Jetcarcatch. addurllist Params
End   If
</ Script >

C. if you want to control the display range of custom menu items on the webpage, you can add a context binary value under this sub-key, such as
0x00000022 of flashget, the custom menu item is displayed only when you click an image or an archor. The specific logic or bit settings are as follows:
context value
0x1 by default
image 0x2
Control 0x4
Table 0x8
selected text 0x10
0x20

2. add custom menu items to the menu (ie5.0 required)
. use guidgen to create a guid, and then use the guid as the name to create a subkey under hkey_local_machinesoftwaremicrosoftinternet assumerextensions.
B. then create a string value named CLSID under the subkey "{1fba04ee-3024-11d2-8f1f-440f87abd16}" (fixed value)
C. similarly, create a menu item display string named menutext, and create a help string named menustatusbar that is displayed in the status bar when the menu is highlighted. In addition, if you create the "help" string named menucustomize, the customized menu item is moved to the main menu.
D. There are three methods to implement the response menu command: EXE file, script file, and COM object.
1. to use an EXE file, you only need to add the path named Exec As the EXE file under the sub-key, such as crogram filesnetantsnetants.exe.
2. to use a script file, you only need to add the script value as the path of the script file.
3. The implementation of COM is the most complex. Add the string value clsidextension as the guid of the COM created for this extension.
your COM object must implement the iolecommandtarget interface.
iolecommandtarget is a common interface for Windows extension. I think that defining interfaces is actually defining the cooperation rules of the parties in a specific aspect. As the name suggests, iolecommandtarget defines a way to deliver commands between Ole iner and its inclusive objects.
iolecommandtarget is relatively simple. There are two methods you need to implement. exec is used to stimulate commands and execute custom functions. querystatus is used to pass the explanatory and stateful description strings of commands, function of the menustatusbar entry in the same registry. For specific passed parameters, each menu or button command in the COM object you implement is identified by an integer in an array, which has a unique guid, the operation is performed based on the integer ID of the command. For more specific parameter meanings, see msdn.

3. Add the Custom button to the Standard toolbar
You can
Create a text tag with the buttontext string value as the button.
Create a file path where the hoticon string value is a color icon
Create the file path of the gray icon with the icon string value
Create a default visible parameter to indicate whether the default value is visible. The value is "yes" and "no ".
Its command excitation mechanism is consistent with the custom menu items above, and also added a function to open the assumerbar, change the fixed value of clisd item above 2 to {E0DD6CAB-2D10-11D2-8F1A-0000F87ABD16 }, when you add a bandclsid string value as the CLSID of the browsing bar to be opened, The Menu customization will be gone.

4. Add a customized browser bar and toolbar
The above three types of customization are relatively simple. Basically, you do not need to implement COM objects. to customize the browsing bar, the toolbar must implement COM objects containing necessary interfaces.
There are four customizable columns: horizontal, vertical, desktop, and IE. Their com implementations are basically the same, the difference is that they are registered in the registry. In addition to registration of the same necessary COM object classes, you must register their respective component category (Component category). Windows or IE determine their location based on the registered category, register as follows: the vertical bar catid_infoband, the horizontal bar catid_commband, and the desktop bar catid_deskband. The toolbar is registered in another way.
It is very easy to implement classification registration in ATL, using macros:
Begin_category_map (your com class name)
Implemented_category (group guid, such as catid_infoband)
End_category_map ()

for the toolbar, create a string value in the name of CLSID of the COM class under hkey_local_machinesoftwaremicrosoftinternet assumertoolbar. You can manually write RGS, for example,
HKLM
{< br> noremove software
{< br> noremove Microsoft
{< br> noremove 'Internet explorer '
{< BR> noremove toolbar
{< br> Val '{758c84ff-78fd-11d5-91a0-b4078a11df77}' = B '00'
}< BR >}< br> >}

Band com implementation:
Each band object must implement three basic interfaces: ideskband, iobjectwithsite, and ipersiststream. However, all interface methods are not required and the basic implementations are the same.

Ipersiststream has the simplest requirements. You only need to implement the getclassid of the basic interface ipersist and return the CLSID of your band object. The rest can be directly returned.

Iobjectwithsite is also a common interface in Ole. A site is an object between a package container and an inclusive object. Through it, the package container can control the details of the contained object, the contained object can execute its own functions, while the iobjectwithsite is the site object interface connecting the two. Take the IE Toolbar as an example. The package container is the rebar of IE. The site indicates the detailed location information provided in the rebar. The site can obtain the information of the package container, then your COM object will deal with the site, which is communicated through iobjectwithsite.
Iobjectwithsite contains two methods:
Setsite is the most important link between your bar window and IE. You need to do the following:
1. first declare a class variable of the iinputobjectsite pointer to obtain information about the current site. When your column window is placed on a new site, setsite is called, if an iinputobjectsite application has been retained before setsite execution, release the reference first.
2. If the input iunknown is empty, it indicates that the bar window is removed and you can return it directly.
3. if the input iunknown is not empty, it indicates that your bar window will be placed in a new site. In this case, you need to create an iolewindow from iunknown, use the getwindow method of iolewindow to obtain the parent window handle. Use this handle to create a child window for your window bar, and finally ask for an iinputobjectsite object from iunknown, and keep the class variables referenced above.
Getsite is to use the saved iinputobjectsite pointer to obtain the interface pointer required by the caller.

The last interface to be implemented is ideskband, which has only one getbandinfo method. However, since ideskband is extended to the idockingwindow interface and the idockingwindow is extended to the iolewindow interface, its interfaces must also be implemented. But it is also very simple.

Iolewindow has two methods: return the handle of the bar window you created in getwindow, and return s_ OK directly for contextsensitivehelp.
Idockingwindow has three methods: show or hide your window bar in showdw, destroy the window bar in closedw, and return e_notimpl in resizeborderdw.
Getbandinfo of ideskband is assigned to corresponding information values based on the information mask of the incoming registrant bandinfo structure.
In addition, if you want to implement the context menu on the bar window, you must implement the icontextmenu interface,
We recommend that you use the rbdeskband Wizard of radbytes to handle the above interface details. You don't have to worry about its implementation at all. What you do is to implement your window class. If you use MFC, your window bar can be directly derived from cwnd or ctoolbar. If you do not use MFC, you can use the ATL csf-wimpl class to derive window classes, it would be easier to use radbytes's cwindowimpl wizard, so that what you do is no different from that in MFC, which is really useful.

5. Capture browser clicks,
This technology involves a very powerful Object Browser Helper Objects (BHO ).
BHO is a customizable control object provided by IE. With BHO, You can monitor various events of IE, such as moving forward, opening a URL, and downloading; you can obtain the IE menu, toolbar, and customize it. You can customize the Additional Information Window of the current display page, which is almost omnipotent.

Of course, this object is also provided by you in the form of COM, and every time an IE process instance runs, one of your BHO instances is generated and associated with it.

In addition to normal com registration, you only need to create a subkey under hklmsoftwaremicrosoftwindowscurrentversionjavaserbrowser helper objects with your com class guid as the name (the registered item can be found here when flashget is installed ).

The Browser Helper Objects object only has the iobjectwithsite interface. The basic principle is the same as the above, but the implemented functions are different.
In setsite, you receive a very modest iunknown. Through this, you can ask for the iwebbrowser2 interface of the IE instance where BHO is located. Using this interface, you can obtain all information about IE, in particular, get_document can obtain the page content.

To intercept an event, you can use the iwebbrowser2 interface to request the iconnectionpointercontainer interface, and then findconnectionpoint to find the connection point object of the outbound interface corresponding to an event, then, use the pointer of your COM object to call advice registration. From this perspective, your com is a receiver external image, so you need to implement the idispatch interface (automatically implement dual in the ATL Project), reload invoke, and respond to the events sent to you by IE. For example:
Ccomqiptr <iwebbrowser2, & iid_iwebbrowser2> m_spwebbrowser2;
Ccomqiptr <iconnectionpointcontainer, & iid_iconnectionpointcontainer> m_spcpc;
Ccomptr <iconnectionpoint> SPCP;

M_spwebbrowser2 = punksite; // punksite is input by setsite
M_spcpc = m_spwebbrowser2; // when a smart pointer is assigned a value, the corresponding variable type interface is automatically requested.
M_spcpc-> findconnectionpoint (diid_dwebbrowserevents2, & SPCP); // dwebbrowserevents2 is the output interface
SPCP-> advise (reinterpret_cast <idispatch *> (this), & m_dwcookie); // This: Implemented BHO object

In oninvoke of idispatch:
If (dispidmember = dispid_beforenavigate2) // input the start jump event doyourjob ();
For specific parameters, see the msdn index dwebbrowserevents2.

You can use the ATL Internet Explorer Object Wizard to easily generate the basic implementation framework. You only need to reload the required functions. More detailed information andCodeSee the msdn index Browser Helper Objects, iwebbrowser2.

Related Article

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.