Sample with Clever VCL 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 TclMultiDownloader component from the Internet Components - Clever Internet Suite library. To allow the scripting host access to the component's functions we must create a simple local com-server application. The following steps help you create such an application:
To implement our interface, let us write the following code:
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, place and setup the TclMultiDownloader component. After that, we can write the body of the AddURL function:
In this case, to make things easier, we assume the form is created automatically and we can use it via the global variable, Form1. Now 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. |