🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.web
10 messages
10 total messages Started by Tom Sun, 18 Feb 2007 13:22
TCPPWebBrowser causing an AV
#282
Author: Tom
Date: Sun, 18 Feb 2007 13:22
40 lines
2352 bytes
Any reason the code below would cause the application to
have an AV when the application is closed? It only occurs when
the movie is played at all. If the play button isn't pressed,
no error.

Place a TCPPWebBrowser on a form and this in the constructor
to reproduce.

    AnsiString HTML = "\
  <html><body bgcolor=#8ca9c6>\
    <table width=95% border=0 align=center bgcolor=#000000 
style='font-size:14px'>\
      <tr bgcolor=#FFFFFF><td style='padding:5px;text-align:center;'><object 
width=\"425\" height=\"350\"><param name=\"movie\" 
value=\"http://www.youtube.com/v/MEIWM91WZTA\"></param><param name=\"wmode\" 
value=\"transparent\"></param><embed 
src=\"http://www.youtube.com/v/MEIWM91WZTA\" 
type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"425\" 
height=\"350\"></embed></object></td></tr>\
    </table>\
  </body></html>";

    this->CppWebBrowser1->Navigate(L"about:blank");
    while(this->CppWebBrowser1->Busy)
      Application->ProcessMessages();

    TMemoryStream* mstm=new TMemoryStream();
    mstm->Write(HTML.c_str(), HTML.Length());
    mstm->Seek(0, soFromBeginning);
    IPersistStreamInit* pPersistStreamInit = NULL;
    TStreamAdapter *IStr=new TStreamAdapter(mstm,soReference);
    this->CppWebBrowser1->Document->QueryInterface(IID_IPersistStreamInit,(void**)&pPersistStreamInit);
    pPersistStreamInit->Load(*IStr);
    pPersistStreamInit->Release();
    pPersistStreamInit=NULL;
    delete mstm;

Thanks,

Tom 
Re: TCPPWebBrowser causing an AV
#284
Author: Remy Lebeau (TeamB)
Date: Tue, 20 Feb 2007 18:52
21 lines
1463 bytes
"Tom" <tom@nospam.net> wrote in message
news:45d852e5$1@newsgroups.borland.com...

>     while(this->CppWebBrowser1->Busy)
>       Application->ProcessMessages();

You need to use the ReadyState property instead of the Busy property

    while(this->CppWebBrowser1->ReadyState != READYSTATE_COMPLETE)
        Application->ProcessMessages();

A safer and better approach would be to use the OnNavigateComplete
event instead.

>     TStreamAdapter *IStr=new TStreamAdapter(mstm,soReference);

You are not freeing the TStreamAdapter anywhere.


Gambit
Re: TCPPWebBrowser causing an AV
#287
Author: Tom
Date: Tue, 20 Feb 2007 21:11
13 lines
1152 bytes
> You are not freeing the TStreamAdapter anywhere.
I tried simply deleting it and that didn't work. So I used
Adapter->_Release();
Adapter = NULL;

Is that correct?

With that in place it still causes an access violation
when  the application is closed.

Thanks,

Tom
Re: TCPPWebBrowser causing an AV
#288
Author: Eduardo Jauch
Date: Tue, 20 Feb 2007 22:18
45 lines
2268 bytes
In yor code, you used this form to acess the TCppWebBrowser:

this->CppWebBrowser1->...

Your code don't show, but the pointer "this" is unecessary, unless you 
have another variable named "CppWebBrowser1" :)


Tom escreveu:

>> You are not freeing the TStreamAdapter anywhere.

> I tried simply deleting it and that didn't work. So I used
> Adapter->_Release();
> Adapter = NULL;
> 
> Is that correct?
> 
Where is "Adapter" in your code?

> With that in place it still causes an access violation
> when  the application is closed.
> 

TStreamAdapter *IStr=new TStreamAdapter(mstm,soReference);

This MUST be freed with "delete", because you used the operator "new".
I think that are objects that can free itself, etc, but this don't seens 
the case...

So, use:

delete IStr;


For the access violation, if it continues after you delete IStr, so the 
problem problably are on another portion of your program... ;)

Sometimes this can happen when you try to delete an object previously 
deleted... Or you are trying to access an empty object...

Take a look on the rest of your code... :)

If this is the ONLY piece of code... Well... I can't figure what is 
wrong but the ausence of delete IStr...
Re: TCPPWebBrowser causing an AV
#290
Author: Tom
Date: Wed, 21 Feb 2007 01:41
15 lines
1405 bytes
Thanks Eduardo,

However, as I stated (though I didn't state why), delete IStr fails. It 
actually causes another access violation, which is why I went to releasing 
and nulling it.

That is the only piece of code in the entire application, so the problem is 
there.

Also, the this-> point is there because the code was copied out of another 
project where it is required.

Regards,

Tom
Re: TCPPWebBrowser causing an AV
#291
Author: Eduardo Jauch
Date: Wed, 21 Feb 2007 04:50
34 lines
2156 bytes
Tom escreveu:
> Thanks Eduardo,
> 
> However, as I stated (though I didn't state why), delete IStr fails. It 
> actually causes another access violation, which is why I went to releasing 
> and nulling it.
> 

I tested the code with the suggestion of Remy.

while(this->CppWebBrowser1->ReadyState != 4)
         Application->ProcessMessages();

Got an error because ambiguity with READYSTATE_COMPLETE, so i used 
insted the number 4 (value on the help).

I try to put delete IStr. Fails like you said.

> Also, the this-> point is there because the code was copied out of another 
> project where it is required.
> 

Unfortunate the "this" is the problem. Without the this->, the error 
when you close the application without play the video don't happen. :)

I don't have any idea WHY... ^-
But it's very interesting...

Same for why "delete IStr" don't work...
But I know that the delete don't work because this line:

pPersistStreamInit->Load(*IStr);

Without this, the delete works properly... :) The program no, of corse ;)
Re: TCPPWebBrowser causing an AV
#317
Author: Jos�
Date: Thu, 08 Mar 2007 14:56
9 lines
1067 bytes
On Sun, 18 Feb 2007 07:22:15 -0600, "Tom" <tom@nospam.net> wrote in
borland.public.cppbuilder.internet.web:

>Place a TCPPWebBrowser on a form and this in the constructor
>to reproduce.

What is a TCPPWebBrowser ?
-- 
Jos�
Re: TCPPWebBrowser causing an AV
#319
Author: Remy Lebeau (TeamB)
Date: Thu, 08 Mar 2007 18:10
12 lines
1231 bytes
"Jos�" <jose@127.0.0.1> wrote in message
news:us80v2984npdl9o33so1kssfpalfp99ol6@4ax.com...

> What is a TCPPWebBrowser ?

TCppWebBrowser is a VCL component that ships with BCB.  It is a
wrapper for the Internet Explorer ActiveX control, which allows IE to
be embedded in applications.


Gambit
Re: TCPPWebBrowser causing an AV
#320
Author: Jos�
Date: Thu, 08 Mar 2007 20:29
12 lines
1261 bytes
On Thu, 8 Mar 2007 10:10:06 -0800, "Remy Lebeau \(TeamB\)"
<no.spam@no.spam.com> wrote in borland.public.cppbuilder.internet.web:

>> What is a TCPPWebBrowser ?
>
>TCppWebBrowser is a VCL component that ships with BCB.  It is a
>wrapper for the Internet Explorer ActiveX control, which allows IE to
>be embedded in applications.

Can I obtain it for use in CPP Builder?
-- 
Jos�
Re: TCPPWebBrowser causing an AV
#321
Author: Remy Lebeau (TeamB)
Date: Thu, 08 Mar 2007 20:31
11 lines
1300 bytes
"Jos�" <jose@127.0.0.1> wrote in message
news:5gs0v21m01eaams9skiiau5h78h8m3aarf@4ax.com...

> Can I obtain it for use in CPP Builder?

Like I said, it already ships with BCB.  It is on the "Internet" tab
of the Component Palette.


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