Board index » cppbuilder » TCppWebBrowser problem

TCppWebBrowser problem


2005-01-25 10:29:09 PM
cppbuilder77
I want to browse an html page, produced dynamiclly. I put a TCppWebBrowser
component (WB) then i called the
WB->Navigate(StringToOleStr("about:blank"));
function on form show (to initialize web browser). then on button click;
------------------------------------------------------
void __fastcall THTMLViewerW::Button1Click(TObject *Sender)
{
TMemoryStream* HTMLStream=new TMemoryStream();
// fill the HTMLStream ...
Mem->LoadFromFile("d:/progs/htmlview/SEP Output Template_page2.htm"); //
for example
IPersistStreamInit* pPersistStreamInit = NULL;
TStreamAdapter *IStr=new TStreamAdapter(HTMLStream,soReference);
WB->ControlInterface->get_Document()->QueryInterface(
IID_IPersistStreamInit, (void**)&pPersistStreamInit);
pPersistStreamInit->InitNew();
pPersistStreamInit->Load(*IStr);
pPersistStreamInit->Release();
pPersistStreamInit=NULL;
}
------------------------------------------------------
this works well , the problem is , sometimes the web browser component shows
the html source (not the html page - like to navigate a .txt file) . but it
is an html source (starts with <html>..... ). I think ie component couldn't
understand is it a html or something other type of source. i need to produce
source dynamically , so i couldn't navigate to html file. but i tried to
navigate the same source via file ;
WB->Navigate(StringToOleStr("file:/d:/progs/htmlview/SEP Output
Template_page2.htm"));
html shown as it is.
do you have any idea for this situation ? maybe i need to sign the source as
html , but i don't know how to ? thanks for help ...
--
________________________________________
Eyyub Volkan Çektimur
Proya Software & Trade Inc.
Head of Core Development Department
 
 

Re:TCppWebBrowser problem

Eyyub Volkan Çektimur wrote:
Quote
Mem->LoadFromFile("d:/progs/htmlview/SEP Output Template_page2.htm");
... i need to produce
source dynamically , so i couldn't navigate to html file. but i tried to
navigate the same source via file ;

WB->Navigate(StringToOleStr("file:/d:/progs/htmlview/SEP Output
Template_page2.htm"));

html shown as it is.
You are contradicting yourself as in both cases you load a html file.
One time first in a stream and then passing the stream to the WB.
The other time directly in the WB.
You can load a dynamically created page also in the WB directly.
Hans.
 

Re:TCppWebBrowser problem

"Eyyub Volkan Çektimur" < XXXX@XXXXX.COM >wrote in message
Quote
WB->Navigate(StringToOleStr("about:blank"));
I would suggest this instead:
WB->Navigate(WideString("about:blank"));
Quote
TMemoryStream* HTMLStream=new TMemoryStream();
That is a memory leak. You never freed the TMemoryStream instance.
Quote
TStreamAdapter *IStr=new TStreamAdapter(HTMLStream,soReference);
That is a memory leak. You never freed the TStreamAdapter instance.
Quote
WB->ControlInterface->get_Document()->QueryInterface(
IID_IPersistStreamInit, (void**)&pPersistStreamInit);
That should be this instead:
WB->Document->QueryInterface(IID_IPersistStreamInit,
(void**)&pPersistStreamInit);
Quote
pPersistStreamInit->InitNew();
pPersistStreamInit->Load(*IStr);
You cannot use those two methods together. They are mutually exclusive.
Get rid of InitNew(). Calling InitNew() first requires Load() to always
fails, and vice versa, calling Load() first requires InitNew() to fail.
Only call one or the other, never both.
Gambit
 

{smallsort}

Re:TCppWebBrowser problem

OK , this code was an example, not the real one so memory leaks may exist ,
anyway i'm changing the code;
//--------------------------------------------------------------------------
-
void __fastcall THTMLViewerW::FormShow(TObject *Sender)
{
WB->Navigate(WideString("about:blank")); // to initialize
}
//--------------------------------------------------------------------------
-
void __fastcall THTMLViewerW::Button1Click(TObject *Sender)
{
IPersistStreamInit* pPersistStreamInit = NULL;
TMemoryStream *Mem=new TMemoryStream();
Mem->LoadFromFile("d:/progs/htmlview/SEP Output Template_page2.htm");
TStreamAdapter *IStr=new TStreamAdapter(Mem,soReference);
WB->Document->QueryInterface( IID_IPersistStreamInit,
(void**)&pPersistStreamInit);
pPersistStreamInit->Load(*IStr);
pPersistStreamInit->Release();
pPersistStreamInit=NULL;
delete Mem;
//delete IStr; // if i delete IStr , borland gives an AV when closing
project...
}
//--------------------------------------------------------------------------
-
it still shows the source of HTML page in text format on WB;
<html>
<head>
<title>Results of Connection Design</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
....
...
...
</html>
not the page !!! , when i double click the file on explorer , it opens the
file in Web Browser and shows as it is , and also if i call
WB->Navigate(WideString(""d:/progs/htmlview/SEP Output
Template_page2.htm""));
separately , it also shows html page as it is in WB... what is the reason
that, when i load the same page dynamiclly, shown source of html (in text
format) on WB ?
thanks for help....
________________________________________
Eyyub Volkan Çektimur
Proya Software & Trade Inc.
Head of Core Development Department
 

Re:TCppWebBrowser problem

i don't know the reason but when i changed the html line ;
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
to
<meta http-equiv="Content-Type" content="text/html">
it worked well , shown as it is. i changed nothing else :))) thanks
anyway...
--
________________________________________
Eyyub Volkan Çektimur
Proya Software & Trade Inc.
Head of Core Development Department
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Eyyub Volkan Çektimur" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

>WB->Navigate(StringToOleStr("about:blank"));

I would suggest this instead:

WB->Navigate(WideString("about:blank"));


>TMemoryStream* HTMLStream=new TMemoryStream();

That is a memory leak. You never freed the TMemoryStream instance.

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

That is a memory leak. You never freed the TStreamAdapter instance.

>WB->ControlInterface->get_Document()->QueryInterface(
>IID_IPersistStreamInit, (void**)&pPersistStreamInit);

That should be this instead:

WB->Document->QueryInterface(IID_IPersistStreamInit,
(void**)&pPersistStreamInit);

>pPersistStreamInit->InitNew();
>pPersistStreamInit->Load(*IStr);

You cannot use those two methods together. They are mutually exclusive.
Get rid of InitNew(). Calling InitNew() first requires Load() to always
fails, and vice versa, calling Load() first requires InitNew() to fail.
Only call one or the other, never both.


Gambit


 

Re:TCppWebBrowser problem

Eyyub Volkan Çektimur wrote:
Quote
i don't know the reason but when i changed the html line ;

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

to

<meta http-equiv="Content-Type" content="text/html">

it worked well , shown as it is.
Did you try to change it to:
<meta http-equiv="Content-Type" content="text/html" charset="iso-8859-1">
Hans.
 

Re:TCppWebBrowser problem

no i don't. now i'm tring
...
...
results;
when ;
<meta http-equiv="Content-Type" content="text/html" charset="iso-8859-1">
shown wrong.
<meta http-equiv="Content-Type" content="text/html" charset="">
shown correctly ...
interesting...
________________________________________
Eyyub Volkan Çektimur
Proya Software & Trade Inc.
Head of Core Development Department
 

Re:TCppWebBrowser problem

"Hans Galema" < XXXX@XXXXX.COM >wrote in message
Quote
Did you try to change it to:

<meta http-equiv="Content-Type" content="text/html"
charset="iso-8859-1">
That is not valid. The meta tag does not have a charset attribute
available. The charset must be specified as part of the content.
Gambit
 

Re:TCppWebBrowser problem

Remy Lebeau (TeamB) wrote:
Quote
><meta http-equiv="Content-Type" content="text/html"

charset="iso-8859-1">

That is not valid. The meta tag does not have a charset attribute
available. The charset must be specified as part of the content.
Indeed. It was just a quick -wrong- tip. I see that my pageproducer
does it correct.
Hans.