Solved

Using two TWebBrowsers ?

Posted on 2008-10-03
2
155 Views
Last Modified: 2010-04-21
I currently build some HTML text and then laod it into a TWebBrowser. The user can click on a link and it will go to another page (in the current TWebBrowser1).

Is it possible to build a link to tell it that when the user clicks the link, the page will load into a second TWebBrowser (TWebBrowser2)?

If so, How?

Thanks
0
Comment
Question by:geocoins-software
2 Comments
 
LVL 21

Accepted Solution

by:
ziolko earned 250 total points
ID: 22635985
yup, this sould do the trick:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, OleCtrls, SHDocVw;

type
  TForm1 = class(TForm)
    WebBrowser1: TWebBrowser;
    WebBrowser2: TWebBrowser;
    Button1: TButton;
    procedure WebBrowser1BeforeNavigate2(Sender: TObject;
      const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
      Headers: OleVariant; var Cancel: WordBool);
    procedure Button1Click(Sender: TObject);
  private
    FRedirect: Boolean;
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.WebBrowser1BeforeNavigate2(Sender: TObject;
  const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
  Headers: OleVariant; var Cancel: WordBool);
begin
  if FRedirect then begin
    WebBrowser2.Navigate(URL);
    Cancel := True;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  FRedirect := False;
  WebBrowser1.Navigate('www.experts-exchange.com');
  FRedirect := True;
end;

end.

ziolko.
0
 

Author Closing Comment

by:geocoins-software
ID: 31502841
That will do it. It works great!  Thanks!
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

713 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