Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

open download window

Post Reply
ericktux
Posts: 40
Joined: Thu Oct 29, 2020 10:11 am

open download window

Post by ericktux »

Hello everyone, is there a way to open the download box? I have noticed that it appears when a file is finished downloading and gives options to open the location and run the downloaded file.
In WebView4Delphi I do it like this:

Code: Select all

WVBrowser1.OpenDefaultDownloadDialog;
PS: Is there a way to manage the progress of the downloads like Google Chrome or should I implement it myself?
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: open download window

Post by salvadordf »

Hi,

If you want to use the user interface of Chromium then you can call TChromiumCore.ExecuteChromeCommand(IDC_SHOW_DOWNLOADS, CEF_WOD_CURRENT_TAB); or navigate to chrome://downloads/ to show all the downloads.

If you prefer to use a custom interface and to control each download then use the following methods, properties and events :
  • TChromiumCore.DownloadBubble : Disable this property to hide the download notification.
  • TChromiumCore.OnCanDownload
  • TChromiumCore.OnBeforeDownload
  • TChromiumCore.OnDownloadUpdated
  • TChromiumCore.StartDownload
  • TChromiumCore.DownloadImage
  • TChromiumCore.OnDownloadImageFinished
Read the code comments for all of them and see the MiniBrowser demo :
https://github.com/salvadordf/CEF4Delphi/blob/cfba87c4d0964f6ccf943b2f5633217684733c11/demos/Delphi_VCL/MiniBrowser/uMiniBrowser.pas#L494
ericktux
Posts: 40
Joined: Thu Oct 29, 2020 10:11 am

Re: open download window

Post by ericktux »

Thank you very much Salvador for your help, it works.
One question: I'm using the "MiniBrowser" demo, how can I open an independent window pointing to chrome://downloads/ when starting a download?
Thank you very much for your time and help
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: open download window

Post by salvadordf »

The MiniBrowser demo sets Chromium1.MultiBrowserMode to True in order to handle all popup windows with one TChromium component.

Try calling TChromiumCore.ExecuteChromeCommand(IDC_SHOW_DOWNLOADS, CEF_WOD_NEW_POPUP) in the TChromiumCore.OnBeforeDownload event

Enabling the MultiBrowserMode property will show all popup windows with the Chromium user interface. If you want to use Delphi forms then set Chromium1.MultiBrowserMode to False and use the code in the PopupBrowser2 demo to handle popup windows with Delphi forms.
ericktux
Posts: 40
Joined: Thu Oct 29, 2020 10:11 am

Re: open download window

Post by ericktux »

Thank you very much, I will try it
Post Reply