Also damit ertslle ich eine neue Instanz:
Delphi-Quellcode:
procedure TARowser.WebBrowser1NewWindow2(Sender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool);
begin
TabSheet := TTabSheet.Create(ARowser.pagecontrol1);
with TabSheet do
begin
PageControl := ARowser.pagecontrol1;
end;
Web := TWebbrowser.CreateParented(TabSheet.Handle);
TabSheet.InsertControl(Web);
TWinControl(Web).align := alClient;
ppDisp := Web.DefaultDispatch;
Web.OnNewWindow2 := Webbrowser1NewWindow2;
Web.OnCommandStateChange := Webbrowser1CommandStateChange;
web.OnDocumentComplete := Webbrowser1documentcomplete;
Web.OnNavigateComplete2 := Webbrowser1NavigateComplete2;
Web.OnProgressChange := Webbrowser1ProgressChange;
Web.OnstatusTextChange := Webbrowser1StatusTextChange;
Pagecontrol1.Pages[pagecontrol1.PageCount - 1].caption := 'Lade...';
PageControl1.ActivePage:=PageControl1.Pages[pagecontrol1.PageCount - 1];
end;
so will ich auf dem aktuellen Tabsheet den Webbrowser ansprechen:
Delphi-Quellcode:
procedure TARowser.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN
then begin
if PageControl1.ActivePageIndex <= 0
then begin
WebBrowser1.Navigate(ComboBox1.Text);
WebBrowser1.SetFocus;
end
else with PageControl1.ActivePage do
begin
Web.Navigate(ComboBox1.Text);
end;
end
end;