 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
James O'Brien Guest
|
Posted: Fri Jun 24, 2005 9:44 pm Post subject: TCppWebBrowser: Program Crash when OnNewWindow2 is used. |
|
|
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
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Sat Jun 25, 2005 12:30 am Post subject: Re: TCppWebBrowser: Program Crash when OnNewWindow2 is used. |
|
|
"James O'Brien" <obrien (AT) niscnet (DOT) com> wrote
| Quote: | 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?
| Quote: | 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
|
|
| Back to top |
|
 |
James O'Brien Guest
|
Posted: Sat Jun 25, 2005 5:12 am Post subject: Re: TCppWebBrowser: Program Crash when OnNewWindow2 is used. |
|
|
| Quote: | 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.
| Quote: | 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.
|
|
| Back to top |
|
 |
Remy Lebeau (TeamB) Guest
|
Posted: Mon Jun 27, 2005 6:55 am Post subject: Re: TCppWebBrowser: Program Crash when OnNewWindow2 is used. |
|
|
"James O'Brien" <obrien (AT) niscnet (DOT) com> wrote
| Quote: | 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.
| Quote: | There is no explicit freeing of this form in the source code
|
Doesn't matter. The form still gets freed at program termination
nontheless.
| Quote: | 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.
| Quote: | 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.
| Quote: | 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
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|