Board index » cppbuilder » Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)

Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)

Why/how do you delete the control? Usually the form takes care of
deleting all controls hosted in it.

.a

Quote
Marcus wrote:

[snip]
 

Re:Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)


Hello!
I use the TcppWebBrowser in C++ Builder 5 and this code to open a new window
when IE wants to.

void __fastcall TForm1::WebBrowserNewWindow2(TObject *Sender,
      LPDISPATCH *ppDisp, TOLEBOOL *Cancel)
{
    TForm1 *NewForm = new TForm1(Application);
    *ppDisp = NewForm->WebBrowser->DefaultDispatch;
    NewForm->Show();

Quote
}

This works fine until I delete the WebBrowser control (e.g. on application
exit). Then it throws an access violation followed by an abnormal program
termination message. This only occur when the new form is created with this
code. What's wrong?

Thannk you!

- Marcus

Re:Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)


Why: Because I wanted to see if the problem occurred when the control was
freeing and it did. How: In FormClose.

The AV come when I close the application if I don't delete the control.

- Marcus

"Alex Bakaev [TeamB]" <al...@jetsuite.com> wrote in message
news:3A14819F.69A509C@jetsuite.com...

Quote
> Why/how do you delete the control? Usually the form takes care of
> deleting all controls hosted in it.

Re:Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)


I'm confused, first you said you had an AV when deleting the control
yourself, now you are saying you get the AV when not deleting it?

.a

Quote
Marcus wrote:

> Why: Because I wanted to see if the problem occurred when the control was
> freeing and it did. How: In FormClose.

> The AV come when I close the application if I don't delete the control.

> - Marcus

> "Alex Bakaev [TeamB]" <al...@jetsuite.com> wrote in message
> news:3A14819F.69A509C@jetsuite.com...
> > Why/how do you delete the control? Usually the form takes care of
> > deleting all controls hosted in it.

Re:Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)


Sorry for the misunderstanding.

What I meant was "This works fine until the WebBrowser control is deleted.".
The application crash when I shutdown it or when I delete the control
manually with delete. It's no way to avoid the Access Violation.

Thanks

- Marcus

"Alex Bakaev [TeamB]" <al...@jetsuite.com> wrote in message
news:3A159DAE.91042D96@jetsuite.com...

Quote
> I'm confused, first you said you had an AV when deleting the control
> yourself, now you are saying you get the AV when not deleting it?

> .a

in it.

Re:Access violation on new form created in OnNewWindow2 event (TcppWebBrowser)


That is strange. Maybe the LPDISPATCH you are passing back to the IE is
used after you delete the form?

.a

Quote
Marcus wrote:

> Sorry for the misunderstanding.

> What I meant was "This works fine until the WebBrowser control is deleted.".
> The application crash when I shutdown it or when I delete the control
> manually with delete. It's no way to avoid the Access Violation.

> Thanks

> - Marcus

> "Alex Bakaev [TeamB]" <al...@jetsuite.com> wrote in message
> news:3A159DAE.91042D96@jetsuite.com...
> > I'm confused, first you said you had an AV when deleting the control
> > yourself, now you are saying you get the AV when not deleting it?

> > .a
> in it.

Other Threads