Programming Delphi How to open a new web page in your custom window with TWebBrowser in Delphi
Notice: Undefined variable: relatedArticlesCount in /home/wwwroot/codeback.net/plugins/content/tags.php on line 149

Usually when we open a new URL in our program using TWebBrowser, it runs  the Internet Explorer(or the program which has been registered to be the default browser) and navigate to the new url. This is always not what we want. Following codes shows how to open the new window by ourself's custom window.

proceduer TForm1.FormShow(Sender :TObject);
begin
  WebBrowser1.Navigate('http://codeback.net');
end;

procedure TForm1.WebBrowser1NewWindow2(Sender: TObject;
  var ppDisp: IDispatch; var Cancel: WordBool);
var
  NewWindow: TForm1;
begin
  // a new instance of the form will be created
  NewWindow := TForm1.Create(self);
  NewWindow.Show;

  ppDisp := NewWindow.Webbrowser1.DefaultDispatch;
end;

If you are using C++Builder instead of Delphi, check here for the solusion Open new url in my custom window usging TCppWebBrowser in C-Builder .


Add comment


Security code
Refresh

Programming - Delphi