🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
4 messages
4 total messages Started by James O'Brien Fri, 24 Jun 2005 21:44
TCppWebBrowser: Program Crash when OnNewWindow2 is used.
#1179
Author: James O'Brien
Date: Fri, 24 Jun 2005 21:44
30 lines
2093 bytes
Hello All,

I'm using OnNewWindow2 event to  force clicked URL to be displayed in 
secondary TCppWebBrowser window, rather than allow the URL to be displayed 
in a new default browser window.  All is working fine, but when the main 
program exits, it crashes during call to destructor of  form containing 
secondary TCppWebBrowser control.  I haven't added code to form's 
descructor.

This only happens after I assign the ppDisp propery of OnNewWindow2 event 
handler.  If I explicitly navigate to a URL using this secondary 
TCppWebBrowser control, when the program exits, there is no crash.

Below is the OnNewWindow2 event handler.


void __fastcall TMainWnd::BROWSE_DisplayNewWindow2(TObject *Sender,
      LPDISPATCH *ppDisp, VARIANT_BOOL *Cancel)
{
   A = "about:blank";  //force display of blank page.
   BrowseWin->ShowHTMLPage(&A, 0, 0);  //function to make form visible and 
display supplied URL
   *ppDisp = BrowseWin->BrowseCtrl->ControlInterface;
}
//---------------------------------------------------------------------------



Thanks for any assistance,
James O'Brien
Re: TCppWebBrowser: Program Crash when OnNewWindow2 is used.
#1180
Author: Remy Lebeau (TeamB)
Date: Sat, 25 Jun 2005 00:30
20 lines
1502 bytes
"James O'Brien" <obrien@niscnet.com> wrote in message
news:42bc7eb3$1@newsgroups.borland.com...

> when the main program exits, it crashes during call to
> destructor of form containing secondary TCppWebBrowser
> control.

Is the secondary form being freed before or after the form that contains the
main TCppWebBrowser?

>    BrowseWin->ShowHTMLPage(&A, 0, 0);

You are not supposed to be navigating the new browser window inside the
OnNewWindow2 event.  TCppWebBrowser handles that internally after the event
handler exits.  You should be providing a fresh interface to the ppDisp
parameter.


Gambit
Re: TCppWebBrowser: Program Crash when OnNewWindow2 is used.
#1181
Author: James O'Brien
Date: Sat, 25 Jun 2005 05:12
29 lines
2040 bytes
> Is the secondary form being freed before or after the form that contains
the
> main TCppWebBrowser?
>

The form containing secondary TCppWebBrowser control  is a design-time form
which is created
automatically with  the following call:

                 Application->CreateForm(__classid(TBrowseWin), &BrowseWin);

There is no explicit freeing of this form in the source code; at least
nothing I've written.  It occurs in what ever default
order is applied do design-time forms.


> >    BrowseWin->ShowHTMLPage(&A, 0, 0);
>
> You are not supposed to be navigating the new browser window inside the
> OnNewWindow2 event.  TCppWebBrowser handles that internally after the
event
> handler exits.  You should be providing a fresh interface to the ppDisp
> parameter.

I'm only navigating to a blank screen ("about:blank") so when the form
becomes visible, it doesn't show the previous contents.
Anyway, whether I navigate to "about:blank" or not the same crash occurs
when the program exits.
Re: TCppWebBrowser: Program Crash when OnNewWindow2 is used.
#1183
Author: Remy Lebeau (TeamB)
Date: Mon, 27 Jun 2005 06:55
35 lines
2317 bytes
"James O'Brien" <obrien@niscnet.com> wrote in message
news:42bce7c4$1@newsgroups.borland.com...

> The form containing secondary TCppWebBrowser control
> is a design-time form which is created automatically

That is not what I asked you.  Just because the form's are auto-created does
not stop you from determining the order in which they are being freed.

> There is no explicit freeing of this form in the source code

Doesn't matter.  The form still gets freed at program termination
nontheless.

> I'm only navigating to a blank screen ("about:blank")

It doesn't matter.  DO NOT navigate at all which you are inside the
OnNewWindow2 event handler.  TCppWebBrowser will navigate the interface
automatically AFTER the event handler exits.  It is not the event handler's
responsibility to provide a pre-navigated interface.

> so when the form becomes visible, it doesn't show the previous contents.

Then don't display the form at all until the navigate is complete.  You can
use the OnDocumentComplete or OnNavigateComplete2 event for that instead.

> Anyway, whether I navigate to "about:blank" or not the same crash
> occurs when the program exits.

You did not answer my question about the order of the forms being freed.
You are probably freeing something that other code is still dependant on.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads