![]() |
WebBrowser1NewWindow2
Hello! Why this code doesn`t work? It opens new TabSheet but new page doesn`t load. Only old page on new TabSheet is visible!!... :(
Delphi-Quellcode:
And how can make, that different TWebbrowser`s TabSheet`s would be controlled with "Back, Forward, Home, ..." buttons individually? Please help me :wall:
procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
var ppDisp: IDispatch; var Cancel: WordBool); var TabSheet: TTabSheet; Web: TWebbrowser; begin TabSheet := TTabSheet.Create(Form1.PageControl1); with TabSheet do begin PageControl := Form1.PageControl1; end; Web := TWebbrowser.CreateParented(TabSheet.Handle); TabSheet.InsertControl(Web); TWinControl(Web).Align := alClient; ppDisp := (PageControl1.ActivePage.Controls[0] as TWebBrowser).DefaultDispatch; Web.OnNewWindow2 := Webbrowser1NewWindow2; PageControl1.ActivePageIndex := PageControl1.PageCount-1; end; |
Re: WebBrowser1NewWindow2
|
Re: WebBrowser1NewWindow2
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:
Happy New Year from marabu
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; |
Re: WebBrowser1NewWindow2
I have already seen your browser. It`s very cool :thumb: but also enough intricate for me :oops: ...
I would be very grateful to you if you could paste here only those functions which I need, because your code in your browser is confused and i can`t to pick that I exactly need... Thank`s yet again! :cyclops: |
Re: WebBrowser1NewWindow2
Thank`s marabu for your answer but your corrected cose also won`t work :( :?
Please help me somebody because I have tried all codes in this cool(! :thumb: ) forum and I haven`t found working code :roll: |
Re: WebBrowser1NewWindow2
Alpha1, you have investigated your code well. Besides that one mistake you made there is nothing in it to point fingers to. In fact I just ran the corrected code in a tiny test project and it does what you would expect. If the code fails in your project, chance is you are doing evil things elsewhere. Try to isolate the corrected code I gave you in a test project and see for yourself.
marabu |
Re: WebBrowser1NewWindow2
Ohh shit (sorry :mrgreen: ) There was so stupid error!! Now browser works great! :angel: Thank`s guys! :dancer2:
|
Re: WebBrowser1NewWindow2
I have new one question :) . This code opens new TabSheet but why there doesn`t create any TWebbrowser in this TabSheet?
Delphi-Quellcode:
procedure TForm1.NewTab;
var ts: TTabSheet; WB: TWebbrowser; begin // Create a new TabSheet ts := TsuiTabSheet.Create(suiPageControl1); try // Assign TTabSheet Properties ts.PageControl := PageControl1; ts.Parent := PageControl1; ts.PageIndex := PageControl1.ActivePageIndex + 1; // Create a TWebbrowser instance WB := TWebbrowser.Create(ts); // put TWebbrowser on TTabSheet TControl(WB).Parent := ts; // Assign Webbrowser Properties WB.Align := alClient; WB.Silent := True; WB.Visible := True; PageControl1.ActivePage := ts; // Assign Webbrowser Events WB.OnStatusTextChange := WebBrowser1StatusTextChange; WB.OnTitleChange := WebBrowser1TitleChange; WB.OnNewWindow2 := WebBrowser1NewWindow2; WB.OnCommandStateChange := WebBrowser1CommandStateChange; ImageButton1.Enabled := False; ImageButton2.Enabled := False; except ts.Free; end; end; |
Re: WebBrowser1NewWindow2
I have found new good:
Delphi-Quellcode:
It works great :)
procedure TForm1.NewTab;
var Tab: TTabSheet; Browser: TWebBrowser; begin Tab:= TTabSheet.Create(PageControl1); Tab.PageControl := PageControl1; Tab.Caption := 'about:blank'; Browser:= TWebBrowser.Create(Tab); TControl(Browser).Parent := Tab; Browser.Align := alClient; Browser.Navigate('about:blank'); end; |
Re: WebBrowser1NewWindow2
Liste der Anhänge anzeigen (Anzahl: 1)
The code works fine for me (look at the compiled demo + source in the attachment)
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:17 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz