Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Netzwerke (https://www.delphipraxis.net/14-netzwerke/)
-   -   Delphi Problem with TEmbeddedWB (https://www.delphipraxis.net/69937-problem-tembeddedwb.html)

alpha1 22. Mai 2006 16:17


Problem with TEmbeddedWB
 
Hello!
I have webbrowser with TEmbeddedWB component and I have one problem:
I have written procedure, which must read options for webbrowser:
Delphi-Quellcode:
procedure TForm1.ReadWBOptions;
begin
 Ini := TIniFile.Create(ExtractFilePath(Paramstr(0)) + 'data.ini');
 try
  if Ini.ReadBool('Options', 'LoadPictures', True) = True
   then CurrentWB.DownloadOptions := [DLCTL_DLIMAGES];
 except
  CurrentWB.DownloadOptions := [DLCTL_DLIMAGES];
 end;
end;
But when I add this procedure somewhere, it doesnt work :( (my webbrowser doesnt load pictures, when "LoadPictures' boolean is true).
When I add somewhere this code(not procedure):
Delphi-Quellcode:
 Ini := TIniFile.Create(ExtractFilePath(Paramstr(0)) + 'data.ini');
 try
  if Ini.ReadBool('Options', 'LoadPictures', True) = True
   then CurrentWB.DownloadOptions := [DLCTL_DLIMAGES];
 except
  CurrentWB.DownloadOptions := [DLCTL_DLIMAGES];
 end;
all works great...
Where is the trouble?
Thank`s!

Klaus01 22. Mai 2006 16:31

Re: Problem with TEmbeddedWB
 
I do not see coding error in your code.
Might this be a problem with the visibility of the Browser
Component.

May you can try to give the Procedure the webbrowser
as parameter.

Good Luck
Klaus

Delphi-Quellcode:
procedure TForm1.ReadWBOptions(ABrowser:TEmbeddedWB);
begin
  Ini := TIniFile.Create(ExtractFilePath(Paramstr(0)) + 'data.ini');
  try
    if Ini.ReadBool('Options', 'LoadPictures', True) = True
      then ABrowser.DownloadOptions := [DLCTL_DLIMAGES];
  except
    ABrowser.DownloadOptions := [DLCTL_DLIMAGES];
  end;
end;

alpha1 22. Mai 2006 16:48

Re: Problem with TEmbeddedWB
 
It doesnt work :( :wall:

Klaus01 22. Mai 2006 16:55

Re: Problem with TEmbeddedWB
 
do you have any code that will set the option to not to load
the pictures?
I can see only code that sets the options to
Maybe the option will be overwritten somewhere:

Are you shure that the inifile is o.k.
and can be found?

Good luck
Klaus

alpha1 22. Mai 2006 17:21

Re: Problem with TEmbeddedWB
 
Zitat:

Zitat von Klaus01
do you have any code that will set the option to not to load
the pictures?
I can see only code that sets the options to
Maybe the option will be overwritten somewhere:

Are you shure that the inifile is o.k.
and can be found?

Good luck
Klaus

Ini file is ok...

Delphi-Quellcode:
procedure TForm1.ReadWBOptions;
begin
Ini := TIniFile.Create(ExtractFilePath(Paramstr(0)) + 'data.ini');
try
// if LoadPictures boolean true
  if Ini.ReadBool('Options', 'LoadPictures', True) = True
// then set options(set DLCTL_DLIMAGES true else DLCTL_DLIMAGES = false (by default))
   then CurrentWB.DownloadOptions := [DLCTL_DLIMAGES];
except
  CurrentWB.DownloadOptions := [DLCTL_DLIMAGES]; // if ini file not found
end;
end;

Klaus01 22. Mai 2006 18:36

Re: Problem with TEmbeddedWB
 
Sorry it' me again:

maybe there is problem with your inifile

[Options]
LoadPictures =1
means it will load the pictures

[Options]
LoadPictures =0
means it will not load the pictures

the following code works for me.

Delphi-Quellcode:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SHDocVw, EmbeddedWB, inifiles;

type
  TForm1 = class(TForm)
    EmbeddedWB1: TEmbeddedWB;
    Button1: TButton;
    CheckBox1: TCheckBox;
    procedure Button1Click(Sender: TObject);
  private
     procedure ReadWBOptions(ABrowser:TEmbeddedWB);
    { Private declarations }
  public

    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.ReadWBOptions(ABrowser:TEmbeddedWB);
var
  ini : TiniFile;
begin
  Ini := TIniFile.Create(ExtractFilePath(Paramstr(0)) + 'data.ini');

  if Ini.ReadBool('Options', 'LoadPictures', True) then
    ABrowser.DownloadOptions := [DLCTL_DLIMAGES];

  ini.free;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ReadWbOptions(EmbeddedWB1);
  EmbeddedWb1.Go('www.google.de');
end;

end.
May you want to check it.

Have fun
Klaus

[edit] ini.free added [/edit]

alpha1 22. Mai 2006 19:26

Re: Problem with TEmbeddedWB
 
Then how to set DLCTL_DLIMAGES to true or to false? It would be well to do this so: Browser.DoanloadOptions.DLCTL_DLIMAGES := True; , but such command not exist...


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:21 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz