## WebBrowser & PageControl tabs

Please discuss general Delphi programming topics here.

### WebBrowser & PageControl tabs

Hi everyone =) I've got a little problem here. I've created my own browser based on TWebBrowser component. My browser uses tabs instead of new windows, but I have a little problem now. Everything works fine except when document is fully loaded I'd like to change Tab caption to loaded website's title. I've tried may ways but nothing works well. For example if I change the tab while site is loading, when it's done, caption is changing in tab where I'm currently in. I don't know how to get webbrowser's parent tab. I've tried parent, owner, getparentname and lots of other ways but I still can't get result I'd be satisfied. Of course all tabs are created at run-time.

That was one problem, and here is another one: Location URL. I've put it into TPageControl onChanging procedure. It also works half-fine. My address field changes after I change the tab, but it changes to previous tab URL. To make it simply:

Here are tabs:

I'm in Yahoo tab, but when I change it to e.g. Lycos then address field is changing to http://www.yahoo.com/ and then I click on Google and then I receive http://www.lycos.com address. I don't know how to fix it.

Here's the code:

Code: Select all
procedure TMainform.WebBrowserTabsChanging(Sender: TObject;  var AllowChange: Boolean);beginWebAddress.Text := (WebBrowserTabs.ActivePage.Controls[1] as TWebBrowser).LocationURL;end;
Coruscant
Member

Posts: 2
Joined: October 9th, 2006, 4:14 pm

1. Use TWebBrowser.OnTitleChange event
2. TPageControl.OnChanging occurs before changing the tab, use TPageControl.OnChange event
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Thanks m8, but how to find out what is the tab that contains WebBrowser?

P.S. That onChange works well so only 1 problem left
Coruscant
Member

Posts: 2
Joined: October 9th, 2006, 4:14 pm

When you create a new tab, you can assign its index to Tag property of the related WebBrowser.
Kambiz

Kambiz