Article View: borland.public.cppbuilder.internet.web
Article #756Re: Getting TCppWebBrowser as Text From Stream
From: caleb
Date: Thu, 09 Mar 2006 13:53
Date: Thu, 09 Mar 2006 13:53
53 lines
2292 bytes
2292 bytes
"Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote:
>
>"caleb" <no@spam.com> wrote in message
>news:440f9e16$1@newsgroups.borland.com...
>
>> Can someone post code for getting the source of a
>> TCppWebBrowser doc?
>
>Such code has been posted many times before. Please go to
>http://www.deja.com and search through the newsgroup archives.
>
>> 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):
>
>When exactly are you calling that code? Did you verify that the entire
>document is actually available yet?
>
>Try this code instead:
>
> #include <mshtml.h>
> #include <utilcls.h>
> #include <memory>
>
> AnsiString Source;
>
> TComInterface<IHTMLDocument2> htm = wb->Document;
> if( htm )
> {
> TComInterface<IPersistStreamInit> psi = htm;
> if( psi )
> {
> std::auto_ptr<TStringStream> Stream(new TStringStream(""));
> std::auto_ptr<TStreamAdapter> Adapter(new
>TStreamAdapter(Stream.get(), soReference));
> OleCheck(psi->Save(*Adapter, TRUE));
> Source = Stream->DataString;
> }
> }
>
>
>Gambit
>
>
Thanks. This code throws an exception on this line:
TComInterface<IHTMLDocument2> htm = wb->Document;
It is not the get source code to stream code chunk though
as I mentioned. It appears to be something with AnsiString
truncating the document.
Technical Details
Message-ID:
<44104179$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<440f9e16$1@newsgroups.borland.com> <440fe89f$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" <nos@pam.com> Sender: "caleb" <nos@pam.com> Reply-To: "caleb" <nos@pam.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> NNTP-Posting-Host: 207.105.83.66 Message-ID: <44104179$1@newsgroups.borland.com> Date: 9 Mar 2006 06:53:45 -0700 X-Trace: newsgroups.borland.com 1141916025 207.105.83.66 (9 Mar 2006 06:53:45 -0700) Lines: 54 Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!newsfeeder.wxs.nl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail