The ActiveX download control displays the URL of the file to download, and the local download
destination. The ActiveX control can be used from Internet Explorer or Visual Basic,
and includes an accurate progress indicator that allows the user to monitor the progress
of the download. To download with XFile's ActiveX download control, create an instance of the AXFFileDownload object. Exercise: Downloading with the ActiveX Control in Internet ExplorerWe will script a simple, two-file download, using XFile's ActiveX download control and its progress indicator. We will create two scripts: AXFFile_download.htm and AXFFileProgress.htm. The first will create an instance of the ActiveX download object (AXFFileDownload), and the second will create an instance of the progress indicator object(AXFFileProgress). |
|
<!-- Create a function that will open the progress indicator window. --><SCRIPT>
function StartDownload() {
winstyle="height=300,width=400,status=no,toolbar=no,menubar=no,location=no";
window.open("AXFFileProgress.htm",null,winstyle);
}
</SCRIPT>
<!-- Create an instance of the ActiveX download control (the AXFFileDownload object),
and assign values to its properties. -->
<OBJECT classid="CLSID:B82FA17C-F3A9-11D2-B5DD-0050041B7FF6" codebase="/SAXFileSamples/saxfile.cab"
height="200" id="AXFFileDownload" style="HEIGHT: 200px; LEFT: 0px; TOP: 0px; WIDTH: 400px"
width="400" VIEWASTEXT>
<PARAM NAME="_cx" VALUE="10583">
<PARAM NAME="_cy" VALUE="5292">
<PARAM NAME="Appearance" VALUE="0">
<PARAM NAME="BackColor" VALUE="16777215">
<PARAM NAME="ForeColor" VALUE="0">
</OBJECT>
<!-- Create a download button that will call the StartDownload() function when clicked. --><INPUT id=button1 name=button1 type=button value="Start Download" onclick = "startdownload()">
<script language="vbs">
'--- Create an instance of the XFRequest object.
set xfile = AXFFileDownload.XFRequest
'--- Set files to download. AXFFileDownload.AddFile takes two parameters: the first is the download
'--- destination path and file name, and the second is the URL of the file to download.
AXFFileDownload.AddFile "c:\testone.txt", "http://localhost/saxfilesamples/vb/download/readme.txt"
AXFFileDownload.AddFile "c:\testone.htm", "http://localhost/saxfilesamples/default.htm"
</script>
<!-- Create a CallBack procedure that will execute when AXFFileProgress.htm is loaded. The CallBack
procedure synchronizes the ActiveX control and its progress indicator, and initiates both. -->
<SCRIPT language="VBS">
Sub Callback()
'--- Assign the value of AXFFileDownload's XFRequestStream property to AXFFileProgress's
'--- XFRequestStream property. The AXFFileDownload object represents the ActiveX control,
'--- and the AXFFileProgress object represents the progress indicator.
document.all("AXFFileProgress").XFRequestStream = opener.document.all("AXFFileDownload").XFRequestStream
'--- Start the progress indicator.
document.all("AXFFileProgress").ShowProgress
'--- Start the file transfer.
opener.document.all("AXFFileDownload").Start
'--- Close the progress window when the transfer is complete (that is, when the Start method
'--- stops executing).
window.close
End Sub
</SCRIPT>
<!-- Execute the Callback procedure when AXFFileProgress.htm loads.--><BODY onload="Callback()">
<!-- Create an instance of the AXFFileProgress object (the ActiveX control's
progress indicator). -->
<OBJECT ID="AXFFileProgress" CLASSID="CLSID:C3EAF164-E06A-11D2-B5C9-0050041B7FF6"></OBJECT>
<!-- Display a message box when the transfer is complete. This will not work in Javascript. --><SCRIPT language = vbs>
'This will not work in Javascript
sub AXFFileProgress_TransferComplete()
MsgBox "Transfer completed"
end sub
</SCRIPT>
StartDownload()
function executes when the user click the "Start Download" button.StartDownload()
winstyle="height=300,width=400,status=no,toolbar=no,menubar=no,location=no"
window.open("AXFFileProgress.htm",null,winstyle)
OBJECT
tag creates an instance of the AXFFileDownload object and gives it the ID
"AXFFileDownload" for future reference. Any reference to AXFFileDownload will be referring to the
instance of the AXFFileDownload object created by this tag.
The objects of XFileSE and XFileEE have different classid
s. When setting an
object's classid
, be careful to set the classid
for the
version of XFile that you are using. Select the appropriate AXFFileDownload classid
for the version of XFile that you are using:
AXFFileDownload Classids | |
---|---|
XFileSE | B82FA17C-F3A9-11D2-B5DD-0050041B7FF6 |
XFileEE | AD58C149-8AE2-4878-99DC-3A164E32F814 |
PARAM
tags define the appearance of the ActiveX control.Button1
triggers the StartDownload()
function, when clicked.Set xfile = AXFFileDownload.XFRequest
creates an instance of the XFRequest object.
XFRequest is XFile's non-visual file-transfer engine. It is the XFRequest object that submits
the HTTP request (Post, Get, or Put) from client to server. AXFFileDownload.AddFile
sets a file to download. AXFFileDownload.AddFile takes two
parameters: Local File and URL. The first specifies the download's local destination path and file name,
and the second specifies the URL of the file to download.
CallBack
procedure executes when AXFFileProgress.htm is loaded.CallBack
document.all("AXFFileProgress").XFRequestStream = opener.document.all("AXFFileDownload").XFRequestStream
document.all("AXFFileProgress").ShowProgress
opener.document.all("AXFFileDownload").Start
window.close
Document
refers to the current window object (AXFFileProgress.htm), and document.opener
refers to its parent window (AXFFileDownload.htm).OBJECT
tag creates an instance of the AXFFileProgress object (the progress indicator).AXFFileProgress_TransferComplete()
displays a message box when the transfer is complete.
The objects of XFileSE and XFileEE have different classid
s. When setting an
object's classid
, be careful to set the classid
for the
version of XFile that you are using. Select the appropriate AXFFileProgress classid
for the version of XFile that you are using:
AXFFileProgress Classids | |
---|---|
XFileSE | C3EAF164-E06A-11D2-B5C9-0050041B7FF6 |
XFileEE | 9C6E12BB-F8AE-44aa-9694-9912396B6033 |