Sample with Clever ActiveX Downloader |
||
This tutorial explains how to add an entry into the standard context menus in Microsoft Internet Explorer that initiates the URL downloading process from the browsed web page. Often developers, making applications for browsing and viewing web-documents, want to extend the functionality of their program. The user interface will be more friendly and convenient if you add the ability to access your downloader program from different places when it is necessary, for instance, from the Internet Explorer context menu. To extend the functionality of the standard context menu you need basic knowledge of the Windows Registry and the Windows Shell Extension API. The main idea is to link a new menu item to the URL, which contains an executable script. Let us look at the implementation of the downloader program by using the ActiveX version of the CleverMultiDownLoader component from the Internet Components - Clever Internet ActiveX Suite library. The scripting host can access to the component's functions itself via instance of the clMultiDownLoader. In this case it can be used only in the synchronous mode. If this functionality is enough, you can skip the creating of the local com-server wrapper and go to creating the script and its linking to the standard context menu. The creation of the script The creation of the local com-serverIf you need an independent asynchronous mode of the download process you should create a simple local com-server. The following steps help you create such an application:
Next, add a new form to our project that allows us to visualize the downloading process. Also we place the ListBox component for displaying the URL list and next, write the showing of the form when our server starts, by using the sub Main (), for instance.
After that, we can write the body of the AddURL function:
The creation of the scriptNow the com-server is ready and its interface is accessible for the scripting host. Next, we should create an HTML document with executable script and link it to the explorer context menu. In the easiest case the script can look like this:
The instance of our com-server is created inside this script and then, it performs a loop through all links within the currently browsed document. While walking, each link is added to our facility to download. To link the script to the context menu, we should add new records into the HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\MenuExt registry key:
You can learn more about setup of the Microsoft Internet Explorer context menu from the MSDN Library and Microsoft online-resource - MSDN. After accomplishing all these steps, we will have flexible and convenient facility to operate remote resources. Your application will be used only it is really necessary. Finally we want to note that you should register the ActiveX server in your system in order that our test example should work properly. To do that you can just run it as a usual EXE application only once. The full version of this example can be downloaded here. Clever Components Support Team. |