/Demos/Various Demos/07 - IEDownload_Demo/IEDownload_Multiple Files_Simultaneous_Downloading/DownloadMgrDemo_U.pas

http://github.com/ghquant/Delphi-EmbeddedWB · Pascal · 107 lines · 57 code · 15 blank · 35 comment · 1 complexity · 52da7c7312c79b731f169a63734e487c MD5 · raw file

  1. //*************************************************************************
  2. // *
  3. // IE Downloag Mgr *
  4. // For Delphi *
  5. // *
  6. // Freeware Demo *
  7. // by: *
  8. // Eran Bodankin -bsalsa(bsalsa@gmail.com) *
  9. // *
  10. // *
  11. // Updated versions: *
  12. // http://www.bsalsa.com *
  13. //*************************************************************************
  14. {LICENSE:
  15. THIS SOFTWARE IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND,
  16. EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE APPLIED
  17. WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
  18. YOU ASSUME THE ENTIRE RISK AS TO THE ACCURACY AND THE USE OF THE SOFTWARE
  19. AND ALL OTHER RISK ARISING OUT OF THE USE OR PERFORMANCE OF THIS SOFTWARE
  20. AND DOCUMENTATION. BSALSA PRODUCTIONS DOES NOT WARRANT THAT THE SOFTWARE IS ERROR-FREE
  21. OR WILL OPERATE WITHOUT INTERRUPTION. THE SOFTWARE IS NOT DESIGNED, INTENDED
  22. OR LICENSED FOR USE IN HAZARDOUS ENVIRONMENTS REQUIRING FAIL-SAFE CONTROLS,
  23. INCLUDING WITHOUT LIMITATION, THE DESIGN, CONSTRUCTION, MAINTENANCE OR
  24. OPERATION OF NUCLEAR FACILITIES, AIRCRAFT NAVIGATION OR COMMUNICATION SYSTEMS,
  25. AIR TRAFFIC CONTROL, AND LIFE SUPPORT OR WEAPONS SYSTEMS. BSALSA PRODUCTIONS SPECIFICALLY
  26. DISCLAIMS ANY EXPRESS OR IMPLIED WARRANTY OF FITNESS FOR SUCH PURPOSE.
  27. You may use, change or modify the component under 4 conditions:
  28. 1. In your website, add a link to "http://www.bsalsa.com"
  29. 2. In your application, add credits to "Embedded Web Browser"
  30. 3. Mail me (bsalsa@gmail.com) any code change in the unit
  31. for the benefit of the other users.
  32. 4. Please, consider donation in our web site!
  33. {*******************************************************************************}
  34. unit DownloadMgrDemo_U;
  35. interface
  36. uses
  37. dialogs, ActiveX, IEConst, Windows, Classes, Forms, StdCtrls, EmbeddedWB, UrlMon,
  38. IEAddress, ExtCtrls, EwbCore, Controls, OleCtrls, SHDocVw_EWB;
  39. type
  40. TForm1 = class(TForm)
  41. EmbeddedWB1: TEmbeddedWB;
  42. Panel1: TPanel;
  43. Button1: TButton;
  44. IEAddress1: TIEAddress;
  45. procedure EmbeddedWB1FileDownload(Sender: TCustomEmbeddedWB; pmk: IMoniker;
  46. pbc: IBindCtx; dwBindVerb, grfBINDF: Cardinal; pBindInfo: PBindInfo;
  47. pszHeaders, pszRedir: PWideChar; uiCP: Cardinal; var Rezult: HRESULT);
  48. procedure Button1Click(Sender: TObject);
  49. procedure EmbeddedWB1DownloadComplete(Sender: TObject);
  50. procedure EmbeddedWB1BeforeNavigate2(ASender: TObject;
  51. const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  52. Headers: OleVariant; var Cancel: WordBool);
  53. procedure FormShow(Sender: TObject);
  54. private
  55. dlUrl: WideString;
  56. end;
  57. var
  58. Form1: TForm1;
  59. implementation
  60. {$R *.dfm}
  61. uses
  62. DownloadForm_U;
  63. procedure TForm1.Button1Click(Sender: TObject);
  64. begin
  65. Embeddedwb1.Go(IEAddress1.Text);
  66. end;
  67. procedure TForm1.EmbeddedWB1BeforeNavigate2(ASender: TObject;
  68. const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  69. Headers: OleVariant; var Cancel: WordBool);
  70. begin
  71. dlUrl := URL;
  72. end;
  73. procedure TForm1.EmbeddedWB1DownloadComplete(Sender: TObject);
  74. begin
  75. IEAddress1.Text := EmbeddedWB1.LocationURL;
  76. end;
  77. procedure TForm1.EmbeddedWB1FileDownload(Sender: TCustomEmbeddedWB;
  78. pmk: IMoniker; pbc: IBindCtx; dwBindVerb, grfBINDF: Cardinal;
  79. pBindInfo: PBindInfo; pszHeaders, pszRedir: PWideChar; uiCP: Cardinal;
  80. var Rezult: HRESULT);
  81. begin
  82. Rezult := S_OK;
  83. if pszRedir <> '' then
  84. dlUrl := pszRedir;
  85. DownloadForm.FileDownload(dlUrl, pmk, pbc);
  86. end;
  87. procedure TForm1.FormShow(Sender: TObject);
  88. begin
  89. EmbeddedWb1.Go(IEAddress1.Text);
  90. end;
  91. end.