Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

Accelerate TWebBrowser loading (D5)

Hi, In my app, I intended to add in several forms a TWebBrowser component.

the problem is that to avoid using too many resources, I destroy each
form when I don't need it.

Now each time I navigate, the component apparently needs to be
instanciated at the moment the navigation occurs, and this can take
some time

What I would like ideally is to instanciate the component in a thread
after my app starts, and to be able to reuse it from the forms where
the tembeddedwb is dropped.

any clues ?

thanks for your help

0
mhervais
Asked:
mhervais
  • 5
  • 4
1 Solution
 
EpsylonCommented:
I'm afraid you can't poke around to much with TWebBrowser since it intend to live its own life. E.g. when TWebBrowser is invisible, its events won't work.

Maybe you can move one instance to another form by changing its parent to the new form.
0
 
intheCommented:
i never used threads properly so im kinda "listening in" but you can create and destroy the browsers at runtime if needed.(have example if needed dont know how stable but no crashes here)
also you can navigate to embeddedwb1.go('about:blank') to get it going..
navigating to a site on formcreate event seems to take forever ;-) ( i noticed when testing for your other q)
0
 
mhervaisAuthor Commented:
Well Epsilon, I know an example of UILess parser that works on top of a TWebbrowser.

I hope some ideas would come up

however, my problem is less about trying to bring up a browser in a thread and more about avoiding to reload it all the time

cheers, Marc
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
EpsylonCommented:
Hmmm... I'm afraid I don't know how to solve this...

Btw, are you talking about this ui-less parser?
0
 
EpsylonCommented:
0
 
mhervaisAuthor Commented:
yes this one.
of course you can always simulate an ui les webbrowser by making it flat and with no size.

Might be an idea to see if I could have the same webbrowser opened and change owner each time I need it.
do you have a snippet for that?  
0
 
EpsylonCommented:
This does not change the owner. It changes the parent. If it is useable, I don't know  :o)
Here are the snippets:


------- Unit1 --------

var
  wb: TWebBrowser;

implementation

uses Unit2;

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
  wb := TWebBrowser.Create(Self);
end;

procedure TForm1.FormActivate(Sender: TObject);
begin
  wb.ParentWindow := Handle;
end;





------- Unit2 --------

implementation

uses Unit1;

{$R *.DFM}

procedure TForm2.FormActivate(Sender: TObject);
begin
  wb.ParentWindow := handle;
end;
0
 
mhervaisAuthor Commented:
will try it tomorrow.
is changing the parent sufficient to redraw the component at the right place?

I suppose I will have to set the position and ask a redraw of the window. but what happens in case of resizing of the form?
0
 
EpsylonCommented:
If you change the parentwindow property, all other properties remain what they are. On startup (or when you switch), you can set the boundaries or whatever:

procedure TForm1.FormCreate(Sender: TObject);
begin
  wb := TWebBrowser.Create(Self);
  wb.ParentWindow := Handle;
  wb.SetBounds(10, 10, 400, 300);
end;
0
 
mhervaisAuthor Commented:
I did not do it exactly like that but it works.
however, I have exceptions upon closing the form with a web browser on it. I guess the component is a bit touchy.

regards, Marc
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now