BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TCPPWebBrowser causing an AV

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web)
View previous topic :: View next topic  
Author Message
Tom
Guest





PostPosted: Sun Feb 18, 2007 7:22 pm    Post subject: TCPPWebBrowser causing an AV Reply with quote



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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Wed Feb 21, 2007 12:52 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote



"Tom" <tom (AT) nospam (DOT) net> wrote in message
news:45d852e5$1 (AT) newsgroups (DOT) borland.com...

Quote:
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.

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

You are not freeing the TStreamAdapter anywhere.


Gambit
Back to top
Tom
Guest





PostPosted: Wed Feb 21, 2007 3:11 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote



Quote:
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
Back to top
Eduardo Jauch
Guest





PostPosted: Wed Feb 21, 2007 4:18 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

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:

Quote:
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?


Quote:
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...
Back to top
Tom
Guest





PostPosted: Wed Feb 21, 2007 7:41 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

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
Back to top
Eduardo Jauch
Guest





PostPosted: Wed Feb 21, 2007 9:10 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

Tom escreveu:
Quote:
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.

Quote:
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... Smile The program no, of corse Wink
Back to top
José
Guest





PostPosted: Thu Mar 08, 2007 8:56 pm    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

On Sun, 18 Feb 2007 07:22:15 -0600, "Tom" <tom (AT) nospam (DOT) net> wrote in
borland.public.cppbuilder.internet.web:

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

What is a TCPPWebBrowser ?
--
José
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Mar 09, 2007 12:10 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

"José" <jose (AT) 127 (DOT) 0.0.1> wrote in message
news:us80v2984npdl9o33so1kssfpalfp99ol6 (AT) 4ax (DOT) com...

Quote:
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
Back to top
José
Guest





PostPosted: Fri Mar 09, 2007 2:29 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

On Thu, 8 Mar 2007 10:10:06 -0800, "Remy Lebeau \(TeamB\)"
<no.spam (AT) no (DOT) spam.com> wrote in borland.public.cppbuilder.internet.web:

Quote:
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é
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Fri Mar 09, 2007 2:31 am    Post subject: Re: TCPPWebBrowser causing an AV Reply with quote

"José" <jose (AT) 127 (DOT) 0.0.1> wrote in message
news:5gs0v21m01eaams9skiiau5h78h8m3aarf (AT) 4ax (DOT) com...

Quote:
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
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Internet Web) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.