DownloadOptions

 

DownloadOptions let you control what the webbrowser control can download and execute. The implementation of Idispatch makes it possible to take control when Idispatch.Invoke is called with dispid=DISPID_AMBIENT_DLCONTROL. VarResult parameter is set to a combination of flags that indicate what can be executed and downloaded.

 

DLCTL_BGSOUNDS The browsing component will play background sounds associated with the document.
DLCTL_DLIMAGES The browsing component will download images from the server.
DLCTL_DOWNLOADONLY The browsing component will download the page but not display it.
DLCTL_FORCEOFFLINE The browsing component will always operate in offline mode. This causes the BINDF_OFFLINEOPERATION flag to be set even if the computer is connected to the Internet when making requests through URLMON.
DLCTL_NO_BEHAVIORS The browsing component will not execute any behaviors.
DLCTL_NO_CLIENTPULL The browsing component will not perform any client pull operations.
DLCTL_NO_DLACTIVEXCTLS The browsing component will not download any ActiveX Controls in the document.
DLCTL_NO_FRAMEDOWNLOAD The browsing component will not download frames but will download and parse the frameset page. The browsing component will also ignore the frameset and render no frame tags.
DLCTL_NO_JAVA The browsing component will not execute any Java applets.
DLCTL_NO_METACHARSET The browsing component will suppress HTML characters set reflected by META elements in the document.
DLCTL_NO_RUNACTIVEXCTLS The browsing component will not execute any ActiveX Controls in the document.
DLCTL_NO_SCRIPTS The browsing component will not execute any scripts.
DLCTL_OFFLINE Same as DLCTL_OFFLINEIFNOTCONNECTED.
DLCTL_OFFLINEIFNOTCONNECTED The browsing component will operate in offline mode if not connected to the Internet. This causes the BINDF_GETFROMCACHE_IF_NET_FAIL flag to be set if the computer is connected to the Internet when making requests through URLMON.
DLCTL_PRAGMA_NO_CACHE The browsing component will force the request through to the server and ignore the proxy, even if the proxy indicates that the data is up to date. This causes the BINDF_PRAGMA_NO_CACHE flag to be set when making requests through URLMON.
DLCTL_RESYNCHRONIZE The browsing component will ignore what is in the cache and ask the server for updated information. The cached information will be used if the server indicates that the cached information is up to date. This causes the BINDF_RESYNCHRONIZE flag to be set when making requests through URLMON.
DLCTL_SILENT The browsing component will not display any user interface. This causes the BINDF_SILENTOPERATION flag to be set when making requests through URLMON.
DLCTL_URL_ENCODING_DISABLE_UTF8 The browsing component will disable UTF-8 encoding.
DLCTL_URL_ENCODING_ENABLE_UTF8 The browsing component will enable UTF-8 encoding.
DLCTL_VIDEOS The browsing component will play any video clips that are contained in the document.

 

The following sample demonstrates the use of DownloadOptions.
Button1 starts a normal download of 'www.microsoft.com'. Button2 downloads the same page, but without images and scripts. Removing DLCTL_DLIMAGES does not tell webbrowser not to display images, but not to download them. Thats why we add DLCTL_PRAGMA_NO_CACHE, so also the cache is ignored.

 


procedure TForm1.Button1Click(Sender: TObject);
begin
  //Using default settings: DLCTL_DLIMAGES, DLCTL_BGSOUNDS,DLCTL_VIDEOS
Embeddedwb1.Go('http://www.microsoft.com');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
EmbeddedWb1.DownloadOptions:=EmbeddedWb1.DownloadOptions
- [DLCTL_DLIMAGES]
+ [DLCTL_PRAGMA_NO_CACHE, DLCTL_NO_SCRIPTS];
Embeddedwb1.Go('http://www.microsoft.com');
end;

The following procedure shows a different way to change the DownloadOptions:

procedure TForm1.Button2Click(Sender: TObject);
var
NewOptions: TDlOptions;
begin
  NewOptions := EmbeddedWb1.DownloadOptions;
  Exclude(NewOptions, DLCTL_DLIMAGES);
  Include(NewOptions, DLCTL_PRAGMA_NO_CACHE);
  Include(NewOptions, DLCTL_NO_SCRIPTS);
  Embeddedwb1.DownloadOptions := NewOptions;
  Embeddedwb1.Go('http://www.microsoft.com');
end;