开发者

Open new pages also in TWebBrowser

开发者 https://www.devze.com 2023-03-20 06:34 出处:网络
I have created an app with a twebBrowser in it. Problem is when i click on some link, in say gmail, it opens in a new window of my default browser( which is IE). how do i make it work like firefox or

I have created an app with a twebBrowser in it. Problem is when i click on some link, in say gmail, it opens in a new window of my default browser( which is IE). how do i make it work like firefox or chrome etc. which opens the clicked links in their windows. The url's should open in the TWebBrowser's window. Must i create a new Form at runtime with TWebBrowser in it at runtime for that? Code not needed as such, ideas will do

Thanks in Advance.

P.S. My org blocks Gmail, Facebook etc. , However through my TWebBrowser, i can open them. Can my QA ppl see that in their log? My guess will be no, since then they would block it. 开发者_JS百科What is your comment on this


TWebBrowser has an OnNewWindow2 event. Assuming the form holding the TWebBrowser is named Form1 and the web-control itself is named WebBrowser1, write a handler like this:

procedure TForm1.WebBrowser1NewWindow2(ASender: TObject; var ppDisp: IDispatch; var Cancel: WordBool);
var NF: TForm1;
begin
  NF := TForm1.Create(Application);
  NF.Visible := True;
  NF.WebBrowser1.RegisterAsBrowser;
  ppDisp := NF.WebBrowser1.DefaultInterface;
end;

This will create a new window, with a new TWebBrowser when the "click" is supposed to lead to a new window.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号