Article View: borland.public.cppbuilder.internet.web
Article #773Re: Getting TCppWebBrowser as Text From Stream
From: caleb
Date: Thu, 09 Mar 2006 20:36
Date: Thu, 09 Mar 2006 20:36
68 lines
2662 bytes
2662 bytes
>A better solution would be to not read the browser data into a file at all,
>but into your AnsiString dirctly. You already have the code to do that.
>
>
>Gambit
>
>
Thank you for the responses.
This below code normally works for what you recommend.
For some reason it is giving me fits now.
I also tried getting the innerHTML of the body of the doc
I could ShowMessage the entire innerHTML but putting the BSTR
bstr val into an AnsiString again gave a truncated string.
AnsiString Source;
IHTMLDocument2 *htm = NULL; // #include <mshtml.h>
if(wb->Document
&&
SUCCEEDED(wb->Document->QueryInterface(IID_IHTMLDocument2,
(LPVOID*)&htm))
)
{
IPersistStreamInit *spPsi = NULL; // ocidl.h
if(SUCCEEDED(htm->QueryInterface(IID_IPersistStreamInit,
(LPVOID*)&spPsi)) && spPsi)
{
IStream *spStream = NULL; // objidl.h
OleCheck(CreateStreamOnHGlobal(NULL, true, &spStream));
if(spStream)
{
__int64 nSize = 0;
STATSTG ss;
LARGE_INTEGER nMove;
nMove.QuadPart = 0;
OleCheck(spPsi->Save(spStream, true));
OleCheck(spStream->Seek(nMove, STREAM_SEEK_SET,
(ULARGE_INTEGER *)&nSize));
OleCheck(spStream->Stat(&ss, STATFLAG_NONAME));
nSize = ss.cbSize.QuadPart;
Source.SetLength(nSize);
OleCheck(spStream->Read((void *)Source.data(), nSize,
(ULONG *)&nSize));
OleCheck(spStream->Release());
}
spPsi->Release();
}
htm->Release();
}
Technical Details
Message-ID:
<44109fc5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<440f9e16$1@newsgroups.borland.com> <440fe89f$1@newsgroups.borland.com> <44103b71$1@newsgroups.borland.com> <44109c32$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: feeec,274260257bdc682e X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "caleb" <n@spam.com> Sender: "caleb" <n@spam.com> Reply-To: "caleb" <n@spam.com> Subject: Re: Getting TCppWebBrowser as Text From Stream Newsgroups: borland.public.cppbuilder.internet.web X-User-Info: 71.99.27.59 References: <440f9e16$1@newsgroups.borland.com> <440fe89f$1@newsgroups.borland.com> <44103b71$1@newsgroups.borland.com> <44109c32$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <44109fc5$1@newsgroups.borland.com> Date: 9 Mar 2006 13:36:05 -0700 X-Trace: newsgroups.borland.com 1141940165 207.105.83.66 (9 Mar 2006 13:36:05 -0700) Lines: 68 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail