• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Delphi 6 TWebBrowser question

How to create a new Web Page from the OnNewWindow2 event?
0
sepknow
Asked:
sepknow
  • 3
  • 3
2 Solutions
 
BdLmCommented:
do you know that link :  http://www.cryer.co.uk/brian/delphi/
0
 
BdLmCommented:
does this help ?

function TDemoForm.NewBrowserTab(pc: TPageControl): TTabSheet;
var
  wb: TWebBrowser;
begin
  Result := TTabSheet.Create(pc);
  Result.PageControl := pc;
  wb := TWebBrowser.Create(Result);
  wb.Align := alClient;
  Result.InsertControl(wb);
  wb.OnNewWindow2 := NewWindow2;
  wb.OnBeforeNavigate2 := BeforeNavigate2;
end;

Open in new window

0
 
sepknowAuthor Commented:
Thanks, BdLm.
I did this, but the new web page was not displayed in the new tabsheet. Instead a new IE was launched with the new web page.
Could you help?
Thank you in advance.

procedure TForm3.IE6NewWindow2(Sender: TObject; var ppDisp: IDispatch; var Cancel: WordBool);
var
  mTabSheet: TTabSheet;
  mWebBrowser: TWebBrowser;
begin
  mTabSheet := TTabSheet.Create(PageControl1);
  mTabSheet.Caption := 'blank';
  mTabSheet.Name := 'tsNewPage_' + FormatDateTime('yyyymmddhhnnsszzz', now); // just a unique name
  mTabSheet.PageControl := PageControl1;
  mTabSheet.Parent := PageControl1;
  PageControl1.ActivePage := mTabSheet;
  mWebBrowser := TWebBrowser.Create(mTabSheet);
  mTabSheet.InsertControl(mWebBrowser);
  TWinControl(mWebBrowser).Name := 'WB_' + FormatDateTime('yyyymmddhhnnsszzz', now); // just a unique name
  TWinControl(mWebBrowser).Parent := mTabSheet;
  mWebBrowser.Align := alClient;
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
Eddie ShipmanAll-around developerCommented:
You have to set the ppDisp to point to the new webbrowser.
Something like this...
ppDisp := mwebBrowser.ControlInterface;
0
 
Eddie ShipmanAll-around developerCommented:
Don't forget to add this line, too, so the new window will do the same thing:
  mWebBrowser.OnNewWindow2 := IE6NewWindow2;
0
 
Eddie ShipmanAll-around developerCommented:
Oh, and another thing, make sure you destroy the new webbrowser instances and TTabSheets
when closing your form.
0
 
BdLmCommented:
may be you can use a oblectlist for that administrative job  -->  http://www.howtodothings.com/computers/a1110-using-tobjectlist.html

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now