Solved

Accelerate TWebBrowser loading (D5)

Posted on 2001-07-16
10
197 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
 
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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 200 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

757 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now