TWebBrowser OnNewWindow2 (Open URL in another form with webbrowser)

667 views
Skip to first unread message

Wayne & Carr

unread,
Apr 23, 2002, 4:17:27 AM4/23/02
to
Hello all;
I have a little problem here, and hopefully someone can assist, me with it.
I am using a code to open a url in another form with a TWebBrowser on it
This other form, is the same exact form as the MainBrowserForm, that I have
as the MainForm. I just saved to Repository and then added the mainForm back
into
the project again. This way the form the new form will have the same
properties and methods
of the MainForm's WebBrowser as well.

The code below works great if you | Right Click | Open in New Window |
BUT if you simply click on a link that has been imbedded with the HTML tag
of Target="_blank" to open in a new window.
I receive an error.
Please help someone.

----Code used in the OnNewWindow2-----
//BrowserNewWindow
var
NewApp : TNewBrowserForm;
begin
NewApp := TNewBrowserForm.Create(Owner);
NewApp.Visible := true;
ppdisp := NewApp.Browser2.Application;
end;

--
The following code is in the newBrowserForm History.
Like I said atop, it works great, only when | Right Click | On in New
Window|
But now clicked on as a link that is embedded with the tag
Target="_blank" (for those that do not know, this tag is used to open the
link in a new window)

---Lines that get the error, are marked with {***} beside them--
-------------Reference Code in error------------
------Code TForm2.OnBeforeNavigate------
procedure TForm2.Browser1BeforeNavigate(Sender: TObject;
const pDisp: IDispatch; var URL, Flags, TargetFrameName, PostData,
Headers: OleVariant; var Cancel: WordBool);
var
NewIndex: Integer;
begin
URLCombo1.Text := URL;
{***}NewIndex := HistoryList.IndexOf(URL);
if NewIndex = -1 then
begin
{ Remove entries in HistoryList between last address and current
address }
if (HistoryIndex >= 0) and (HistoryIndex < HistoryList.Count - 1) then
while HistoryList.Count > HistoryIndex do
HistoryList.Delete(HistoryIndex);
HistoryIndex := HistoryList.Add(URL);
end
else
HistoryIndex := NewIndex;
if UpdateCombo then
begin
UpdateCombo := False;
NewIndex := URLCombo1.Items.IndexOf(URL);
if NewIndex = -1 then
URLCombo1.Items.Insert(0, URL)
else
URLCombo1.Items.Move(NewIndex, 0);
end;
{***}StatusBar1.Panels.Items[0].Text := URL;
end;
-----End OnBeforeNavigate------
________This is the Error that I receive_________

---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EAccessViolation with message
'Access violation at address 004D20C8 in module 'Project1.exe'. Read of
address 00000000'. Process stopped. Use Step or Run to continue.
---------------------------
OK Help
---------------------------


When I Step Over the code hitting the 1st line and then the last, I get this
error

----Second Error-------
---------------------------
ProjectBrowser
---------------------------
Access violation at address 004D20C8 in module 'Project1.exe'. Read of
address 00000000.
---------------------------
OK
---------------------------

________End of Error Received_______________

After Clicking out of the last error, the page does in fact load in the New
Browser Form.
Any Idea's on how to get rid of the errors??

Wayne


Carrz-Fox-Fire Promotions
Delphi 6 Pro SP2 | Win2k SP2|
http://www.carrz-fox-fire.com/Delphi/Delphi_Fire_Security/Main.asp
//Delphi Components and Source Code page, For members only, Sign up today
[Free for now]
http://www.carrz-fox-fire.com/Delphi/Delphi_Fire_Security/EmailList/Confirm.
asp
//Delphi TWebBrowser & TEmbeddeedWB Mailing List, Join Today


Wayne & Carr

unread,
Apr 27, 2002, 7:44:57 PM4/27/02
to
This has been resolved

Wayne
"Wayne & Carr" <delphi...@carrz-fox-fire.com> wrote in message
news:3cc59698$2_2@dnews...

raghu...@gmail.com

unread,
Jan 11, 2018, 12:54:11 PM1/11/18
to
Wayne,

What was the fix?. Can you please help to provide the details?.
Reply all
Reply to author
Forward
0 new messages