Or even better,
var
PersistStream: IPersistStreamInit;
MemStream: TStream ;
OutStream: TOLEStream ;
Stream: IStream;
SaveResult: HRESULT;
begin
PersistStream := WB.Document as IPersistStreamInit;
MemStream := TMemoryStream.Create ;
try
Stream := TStreamAdapter.Create(MemStream, soReference) as IStream;
SaveResult := PersistStream.Save(Stream, True);
OutStream := TOLEStream.Create(Stream) ;
OutStream.Position := 0 ;
Memo1.Lines.LoadFromStream(OutStream) ;
if FAILED(SaveResult) then
MessageBox(Handle, 'Fail to save HTML source', 'Error', 0);
finally
MemStream.Free ;
end;
end;
Dave.
----- Original Message -----
From: Dave <[EMAIL PROTECTED]>
To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
Sent: Sunday, March 25, 2001 11:03 AM
Subject: Re: [DUG]: Accessing page in TWebBrowser
> Just found this code. May be what you are after. (If you haven't solved
this
> already)
>
> procedure TForm1.SaveHTMLSourceToFile(const FileName: string;
> WB: TWebBrowser);
> var
> PersistStream: IPersistStreamInit;
> FileStream: TFileStream;
> Stream: IStream;
> SaveResult: HRESULT;
> begin
> PersistStream := WB.Document as IPersistStreamInit;
> FileStream := TFileStream.Create('c:\temp\temp.tmp', fmCreate);
> try
> Stream := TStreamAdapter.Create(FileStream, soReference) as IStream;
> SaveResult := PersistStream.Save(Stream, True);
> if FAILED(SaveResult) then
> MessageBox(Handle, 'Fail to save HTML source', 'Error', 0);
> finally
> { we are passing soReference in TStreamAdapter constructor,
> it is our responsibility to destroy the TFileStream object. }
> FileStream.Free;
> end;
> end;
>
> Dave.
> ----- Original Message -----
> From: Alex Kouznetsov <[EMAIL PROTECTED]>
> To: Multiple recipients of list delphi <[EMAIL PROTECTED]>
> Sent: Thursday, March 01, 2001 4:49 PM
> Subject: [DUG]: Accessing page in TWebBrowser
>
>
> > How can I access html text of the page currently displayed in the
> > TWebBrowser component ?
> >
> > Thanks
> > Alex
> >
>
> --------------------------------------------------------------------------
> -
> > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> > Website: http://www.delphi.org.nz
> > To UnSub, send email to: [EMAIL PROTECTED]
> > with body of "unsubscribe delphi"
> >
>
> --------------------------------------------------------------------------
-
> New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
> Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"