Site Map Contact Us Home
E-mail Newsletter
Subscribe to get informed about
Clever Components news.

Your Name:
Your Email:
 
SUBSCRIBE
 
Previous Newsletters
 




Products Articles Downloads Order Support
Customer Portal     

Sample with Clever ActiveX Downloader

Return to contents

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-server

If 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:

  • Create a new Visual Basic ActiveX EXE project.
  • Add to project the description of the class of the local server to be, which declares one simple function, AddURL. This function has one parameter, URL which will be downloaded.

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.

Sub Main()
   MainForm.Show
End Sub

After that, we can write the body of the AddURL function:

Private Downloader As clMultiDownLoader

Private Function GetDownLoader() As clMultiDownLoader
   If Downloader Is Nothing Then
      Set Downloader = New clMultiDownLoader
      Downloader.LocalFolder = "c:\temp\"
   End If
   Set GetDownLoader = Downloader
End Function

Public Sub AddURL(AURL As String)
   Dim Item As IclDownLoaderItem
   Set Item = GetDownLoader.Items.Add
   On Error Resume Next
   Item.URL = AURL
   MainForm.DownloadList.AddItem Item.URL & " - " & Item.LocalFile
End Sub

The creation of the script

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:

<script language="VBScript">
   Set cl_popup = CreateObject("popupdownload.popupdownloadclass")
   Set links = external.menuArguments.document.links
   For i = 0 to links.length - 1
      cl_popup.AddURL links(i).href
   next
</script>

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:

Key: Download &All using Clever ActiveX Downloader
Default value: file://c:\samples\ popupadd_link.htm
DWORD value contexts: 000000f3

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.
Please feel free to Contact Us
We are always glad to help you.

    Copyright © 2000-2019