Article View: borland.public.cppbuilder.internet.web
Article #750Getting TCppWebBrowser as Text From Stream
From: caleb
Date: Thu, 09 Mar 2006 02:16
Date: Thu, 09 Mar 2006 02:16
60 lines
2338 bytes
2338 bytes
Hi:
Can someone post code for getting the source of a TCppWebBrowser
doc?
(It is better if it is from stream and not from saving to file).
I have been using this code to get text from stream but it
does not always work (on complex pages it only gets part
of the html):
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();
}
*string = Source;
Thank you,
Caleb
Technical Details
Message-ID:
<440f9e16$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Thread: feeec,274260257bdc682e,start X-Google-Attributes: gidfeeec,public X-Google-Language: ENGLISH,ASCII-7-bit From: "caleb" <no@spam.com> Sender: "caleb" <no@spam.com> Reply-To: "caleb" <no@spam.com> Subject: Getting TCppWebBrowser as Text From Stream Newsgroups: borland.public.cppbuilder.internet.web X-User-Info: 71.99.27.59 NNTP-Posting-Host: 207.105.83.66 Message-ID: <440f9e16$1@newsgroups.borland.com> Date: 8 Mar 2006 19:16:38 -0700 X-Trace: newsgroups.borland.com 1141874198 207.105.83.66 (8 Mar 2006 19:16:38 -0700) Lines: 60 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news1.google.com!news4.google.com!news2.volia.net!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail