Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 279
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

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