Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Accelerate TWebBrowser loading (D5)

Posted on 2001-07-16
10
Medium Priority
?
209 Views
Last Modified: 2010-04-04
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
Comment
Question by:mhervais
  • 5
  • 4
10 Comments
 
LVL 13

Expert Comment

by:Epsylon
ID: 6286647
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
 
LVL 17

Expert Comment

by:inthe
ID: 6286671
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
 
LVL 4

Author Comment

by:mhervais
ID: 6286776
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 13

Expert Comment

by:Epsylon
ID: 6286846
Hmmm... I'm afraid I don't know how to solve this...

Btw, are you talking about this ui-less parser?
0
 
LVL 13

Expert Comment

by:Epsylon
ID: 6286847
0
 
LVL 4

Author Comment

by:mhervais
ID: 6287484
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
 
LVL 13

Expert Comment

by:Epsylon
ID: 6287712
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
 
LVL 4

Author Comment

by:mhervais
ID: 6287773
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
 
LVL 13

Accepted Solution

by:
Epsylon earned 600 total points
ID: 6289386
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
 
LVL 4

Author Comment

by:mhervais
ID: 6304049
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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question