Solved

Delphi 6 TWebBrowser question

Posted on 2009-05-06
7
264 Views
Last Modified: 2012-05-06
How to create a new Web Page from the OnNewWindow2 event?
0
Comment
Question by:sepknow
  • 3
  • 3
7 Comments
 
LVL 8

Expert Comment

by:BdLm
Comment Utility
do you know that link :  http://www.cryer.co.uk/brian/delphi/
0
 
LVL 8

Accepted Solution

by:
BdLm earned 250 total points
Comment Utility
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
 

Author Comment

by:sepknow
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
You have to set the ppDisp to point to the new webbrowser.
Something like this...
ppDisp := mwebBrowser.ControlInterface;
0
 
LVL 26

Assisted Solution

by:EddieShipman
EddieShipman earned 250 total points
Comment Utility
Don't forget to add this line, too, so the new window will do the same thing:
  mWebBrowser.OnNewWindow2 := IE6NewWindow2;
0
 
LVL 26

Expert Comment

by:EddieShipman
Comment Utility
Oh, and another thing, make sure you destroy the new webbrowser instances and TTabSheets
when closing your form.
0
 
LVL 8

Expert Comment

by:BdLm
Comment Utility
may be you can use a oblectlist for that administrative job  -->  http://www.howtodothings.com/computers/a1110-using-tobjectlist.html

0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now