Hello alpha1,
your code will perform better if you take care of the time you advance the ActivePageIndex. You might as well use the Web variable to retrieve the correct browser interface to return:
Delphi-Quellcode:
procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool);
var
TabSheet: TTabSheet;
Web: TWebbrowser;
begin
TabSheet := TTabSheet.Create(PageControl1);
TabSheet.PageControl := PageControl1;
Web := TWebBrowser.Create(TabSheet);
// Web := TWebbrowser.CreateParented(TabSheet.Handle);
TabSheet.InsertControl(Web); // this declares TabSheet Parent
TWinControl(Web).Align := alClient;
Web.OnNewWindow2 := Webbrowser1NewWindow2;
PageControl1.ActivePageIndex := PageControl1.PageCount-1;
ppDisp := Web.DefaultDispatch;
end;
Happy New Year from marabu