delphi3
asked on
Stream html directly into Netscape or IE
Hi all,
I have D4 and Win2K with NT. I use ICS and want to stream a xxxx.html directly into netscape.
My present practice is to stream the html file onto the drive first saving it , then launch netscape and then load the html from the drive into netscape.
If it is possible an example would be appreciated.
Delphi3
I have D4 and Win2K with NT. I use ICS and want to stream a xxxx.html directly into netscape.
My present practice is to stream the html file onto the drive first saving it , then launch netscape and then load the html from the drive into netscape.
If it is possible an example would be appreciated.
Delphi3
ASKER
Mike,
It is having a difficult time with
IPersistStreamInit
Any suggestions?
and the address listed above has no DNS entry
Delphi3
It is having a difficult time with
IPersistStreamInit
Any suggestions?
and the address listed above has no DNS entry
Delphi3
oooh, sorry, try .com instead of .net . As far as the interface, what ver of delphi are you useing? perhaps it maybe related to that.
GL
Mike
GL
Mike
ASKER
Mike,
Let's skip Netscape for the moment.
Answering your Q:
I have D4 standard edition and Win2K with NT
Delphi3
Let's skip Netscape for the moment.
Answering your Q:
I have D4 standard edition and Win2K with NT
Delphi3
Oooh, I guess I prob. should have mentioned that the interface is declared in axcitveX.pas - so you'll need to add activeX to your uses clause. Sorry about that. Also, because the code refrences a webBrowser's document property you'll need to make sure that it has one. When you first drop the control on a form it doesn't - until it gets 'navigated' somewhere. I like to do somehting like this:
procedure TForm1.FormCreate(Sender: TObject);
begin
webBrowser1.navigate('abou t:blank');
end;
GL
Mike
procedure TForm1.FormCreate(Sender: TObject);
begin
webBrowser1.navigate('abou
end;
GL
Mike
ASKER
Mike,
This is going no where.
your hints or snips are too vague and incomplete. Or I am too stuupid to make it all happen.
And the prompts and programming from D4 help are of no use when using this activeX. I tried to use
IE instead of webbrowser so that it read
function TForm1.LoadFromStream(cons t AStream: TStream): HRESULT;
begin
AStream.seek(0, 0);
Result := (IE.Document as IPersistStreamInit).Load(T StreamAdap ter.Create (AStream)) ;
end;
and even with the change not being made to IE, and keeping the WebBrowser1 it still does not know
what to do with the IPersistStreamInit.
Please if you have no more help say so and I will put the Q out to pasture: close up and put the Q to electronic
heaven or into the recycle bin
Delphi3
This is going no where.
your hints or snips are too vague and incomplete. Or I am too stuupid to make it all happen.
And the prompts and programming from D4 help are of no use when using this activeX. I tried to use
IE instead of webbrowser so that it read
function TForm1.LoadFromStream(cons
begin
AStream.seek(0, 0);
Result := (IE.Document as IPersistStreamInit).Load(T
end;
and even with the change not being made to IE, and keeping the WebBrowser1 it still does not know
what to do with the IPersistStreamInit.
Please if you have no more help say so and I will put the Q out to pasture: close up and put the Q to electronic
heaven or into the recycle bin
Delphi3
We'll try an example. This assumes you've got a for with a button, a memo & an embeded IE ActiveX called webBrowser1. If you've got the netmasters components install your IE might be called something else - adjust as nec. The project should take html entered in the memo & render it in the webBrowser:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,activeX,
StdCtrls, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender : TObject);
var
ms : TMemoryStream;
begin
webBrowser1.navigate('abou t:blank');
while webBrowser1.busy do
application.processMessage s;
ms := TMemoryStream.create;
memo1.lines.saveToStream(m s);
ms.seek(0, 0);
(webBrowser1.Document as IPersistStreamInit).Load(T StreamAdap ter.Create (ms));
ms.free;
end;
end.
This code was successfully compiled & tested with D5 Pro, srv pack 1.
GL
Mike
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,activeX,
StdCtrls, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
var
ms : TMemoryStream;
begin
webBrowser1.navigate('abou
while webBrowser1.busy do
application.processMessage
ms := TMemoryStream.create;
memo1.lines.saveToStream(m
ms.seek(0, 0);
(webBrowser1.Document as IPersistStreamInit).Load(T
ms.free;
end;
end.
This code was successfully compiled & tested with D5 Pro, srv pack 1.
GL
Mike
ASKER
Mike,
I would want to report that I had success all the way.
Since my version is D4 standard edition, I am going no where fast.
I do see that you load from a memo, and I was looking to load from a stream. So all in all
this is a no go anywhere situation.
For now I will let this sit here a while unless you have any more bright ideas.
Delphi3
I would want to report that I had success all the way.
Since my version is D4 standard edition, I am going no where fast.
I do see that you load from a memo, and I was looking to load from a stream. So all in all
this is a no go anywhere situation.
For now I will let this sit here a while unless you have any more bright ideas.
Delphi3
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Mike,
No, Actually I have a strange set of things. First, my D4 TWebBrowser was obtained is on the palet by
install instructions by looking at the import ActiveX, selecting Microsoft internet controls version 1.1 and
what results is a TWebBrowser_V1.
Here is what I have:
unit GetWebBrowserUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, activeX,
StdCtrls, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
//WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
WebBrowser_V11: TWebBrowser_V1;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender : TObject);
var
V:OleVariant;
ms: TMemoryStream;
begin
webBrowser_V11.navigate('a bout:blank ',V,V,V,V) ; // had to add the V.V.V.V this to keep it happy
while webBrowser_V11.busy do
application.processMessage s;
ms := TMemoryStream.create;
memo1.lines.saveToStream(m s);
ms.seek(0, 0);
(webBrowser_V11.Document as IPersistStreamInit).Load(T StreamAdap ter.Create (ms));
ms.free;
end;
end.
There is no way that I can get it to accept the form. I can't get D4 to open it after once I have
failure to run it. A bunch of violations result.
on the other hand I have this thing that runs well and uses IE, puts the HTML
text into the memo window and for which I want to stream it.
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Author: Fran?ois PIETTE
Creation: January 17, 1998 notes: removed
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit HttpGet1;
interface
uses
WinTypes, WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, HttpProt, StdCtrls, IniFiles, ExtCtrls, ComObj, ComCtrls, OleCtrls;
// Added ComObj, ComCtrls, OleCtrls to the original list of uses
type
THttpGetForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
InfoLabel: TLabel;
URLEdit: TEdit;
ProxyHostEdit: TEdit;
ProxyPortEdit: TEdit;
FileNameEdit: TEdit;
GetButton: TButton;
AbortButton: TButton;
Button1: TButton;
Button2: TButton;
HttpCli1: THttpCli;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
RadioGroup1: TRadioGroup;
Memo1: TMemo;
procedure GetButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure HttpCli1DocData(Sender: TObject; Buffer: Pointer;
Len: Integer);
procedure HttpCli1HeaderData(Sender: TObject);
procedure AbortButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
FInitialized: Boolean;
FIniFileName: string;
public
end;
var
HttpGetForm: THttpGetForm;
implementation
{$R *.DFM}
const
SectionData = 'Data';
KeyURL = 'URL';
KeyProxyHost = 'ProxyHost';
KeyProxyPort = 'ProxyPort';
KeyFileName = 'FileName';
SectionWindow = 'Window';
KeyTop = 'Top';
KeyLeft = 'Left';
KeyWidth = 'Width';
KeyHeight = 'Height';
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.FormCreate(Se nder: TObject);
begin
FIniFileName := LowerCase(ExtractFileName( Applicatio n.ExeName) );
FIniFileName := Copy(FIniFileName, 1, Length(FIniFileName) - 3) + 'ini';
InfoLabel.Caption := '';
RadioGroup1.ItemIndex := 0;
Memo1.Clear;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.FormShow(Send er: TObject);
var
IniFile: TIniFile;
begin
//Statement placed here to prepare to Coinitialize
if InitProc <> nil then TProcedure(InitProc);
//*************
if not FInitialized then begin
FInitialized := TRUE;
IniFile := TIniFile.Create(FIniFileNa me);
URLEdit.Text := IniFile.ReadString(Section Data, KeyURL,
'http://www.rtfm.be/fpiette/images/overbyte.gif');
ProxyHostEdit.Text := IniFile.ReadString(Section Data, KeyProxyHost,
'');
ProxyPortEdit.Text := IniFile.ReadString(Section Data, KeyProxyPort,
'80');
FileNameEdit.Text := IniFile.ReadString(Section Data, KeyFileName,
'test.tmp');
Top := IniFile.ReadInteger(Sectio nWindow, KeyTop, Top);
Left := IniFile.ReadInteger(Sectio nWindow, KeyLeft, Left);
Width := IniFile.ReadInteger(Sectio nWindow, KeyWidth, Width);
Height := IniFile.ReadInteger(Sectio nWindow, KeyHeight, Height);
IniFile.Free;
end;
RadioGroup1.ItemIndex := 0;
URLEdit.Text := 'http://users.swing.be/francois.piette/wsocketu.htm';
FileNameEdit.Text := 'View1.html';
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.RadioGroup1Cl ick(Sender : TObject);
begin
if RadioGroup1.ItemIndex = 0 then begin //ICS
URLEdit.Text := 'http://users.swing.be/francois.piette/wsocketu.htm';
FileNameEdit.Text := 'View1.html';
end;
if RadioGroup1.ItemIndex = 1 then begin //Delphi Tips
URLEdit.Text := 'https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20161215&jsessionid=200156996586977326'; // EE Q
FileNameEdit.Text := 'View2.html';
end;
end;
procedure THttpGetForm.FormClose(Sen der: TObject;
var Action: TCloseAction);
var
IniFile: TIniFile;
begin
IniFile := TIniFile.Create(FIniFileNa me);
IniFile.WriteString(Sectio nData, KeyURL, URLEdit.Text);
IniFile.WriteString(Sectio nData, KeyProxyHost, ProxyHostEdit.Text);
IniFile.WriteString(Sectio nData, KeyProxyPort, ProxyPortEdit.Text);
IniFile.WriteString(Sectio nData, KeyFileName, FileNameEdit.Text);
IniFile.WriteInteger(Secti onWindow, KeyTop, Top);
IniFile.WriteInteger(Secti onWindow, KeyLeft, Left);
IniFile.WriteInteger(Secti onWindow, KeyWidth, Width);
IniFile.WriteInteger(Secti onWindow, KeyHeight, Height);
IniFile.Free;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.GetButtonClic k(Sender: TObject);
var
S: string;
begin
HttpCli1.URL := URLEdit.Text;
HttpCli1.Proxy := ProxyHostEdit.Text;
HttpCli1.ProxyPort := ProxyPortEdit.Text;
HttpCli1.RcvdStream := TFileStream.Create(FileNam eEdit.Text , fmCreate);
GetButton.Enabled := FALSE;
AbortButton.Enabled := TRUE;
InfoLabel.Caption := 'Loading';
try
try
HttpCli1.Get;
InfoLabel.Caption := 'Received ' +
IntToStr(HttpCli1.RcvdStre am.Size) + ' bytes';
except
on E: EHttpException do begin
InfoLabel.Caption := 'Failed : ' +
IntToStr(HttpCli1.StatusCo de) + ' ' +
HttpCli1.ReasonPhrase; ;
end
else
raise;
end;
finally
GetButton.Enabled := TRUE;
AbortButton.Enabled := FALSE;
HttpCli1.RcvdStream.Seek(0 , soFromBeginning);
SetLength(S, HttpCli1.RcvdStream.Size);
HttpCli1.RcvdStream.Read(S [1], length(S));
Memo1.Text := S;
HttpCli1.RcvdStream.Destro y;
HttpCli1.RcvdStream := nil;
InfoLabel.Caption := 'Task Completed';
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.HttpCli1DocDa ta(Sender: TObject; Buffer: Pointer;
Len: Integer);
begin
InfoLabel.Caption := IntToStr(HttpCli1.RcvdCoun t);
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.HttpCli1Heade rData(Send er: TObject);
begin
InfoLabel.Caption := InfoLabel.Caption + '.';
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.AbortButtonCl ick(Sender : TObject);
begin
HttpCli1.Abort;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.Button1Click( Sender: TObject);
var
IE, Doc, Bod, V: oleVariant;
I, I1, X: integer;
S: string;
F: TStream;
begin
Memo1.Clear;
F := TFileStream.Create(Extract FilePath(A pplication .exeName) + FileNameEdit.Text, fmOpenRead or fmShareDenyNone);
try
SetLength(S, F.Size);
F.Read(S[1], Length(S));
finally
F.Free;
Memo1.lines.add(s);
end;
IE := CreateOleObject('InternetE xplorer.Ap plication' );
IE.Navigate('about:blank', V, V, V, V);
IE.Visible := true; //false keeps it hidden
while IE.Busy do
Application.ProcessMessage s;
Doc := IE.Document;
Bod := Doc.Body;
Bod.InnerHTML := Memo1.Text;
Memo1.Text := Bod.InnerText;
//IE.Quit;
InfoLabel.Caption := 'Saving Text File';
with TFileStream.Create(Extract FilePath(A pplication .exeName) + 'TextSavedSeenInView' + FileNameEdit.Text[5] + '.txt', fmCreate) do
try
I := 0;
X := Memo1.Lines.Count;
while I < X do
begin
Memo1.Lines[I];
I1 := Length(Memo1.Lines[I]);
Write(Pointer(Memo1.Lines[ I])^, I1);
Inc(I);
end;
finally free end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.Button2Click( Sender: TObject);
begin
Application.Terminate;
end;
end.
No, Actually I have a strange set of things. First, my D4 TWebBrowser was obtained is on the palet by
install instructions by looking at the import ActiveX, selecting Microsoft internet controls version 1.1 and
what results is a TWebBrowser_V1.
Here is what I have:
unit GetWebBrowserUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, activeX,
StdCtrls, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
//WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
WebBrowser_V11: TWebBrowser_V1;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
var
V:OleVariant;
ms: TMemoryStream;
begin
webBrowser_V11.navigate('a
while webBrowser_V11.busy do
application.processMessage
ms := TMemoryStream.create;
memo1.lines.saveToStream(m
ms.seek(0, 0);
(webBrowser_V11.Document as IPersistStreamInit).Load(T
ms.free;
end;
end.
There is no way that I can get it to accept the form. I can't get D4 to open it after once I have
failure to run it. A bunch of violations result.
on the other hand I have this thing that runs well and uses IE, puts the HTML
text into the memo window and for which I want to stream it.
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Author: Fran?ois PIETTE
Creation: January 17, 1998 notes: removed
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
unit HttpGet1;
interface
uses
WinTypes, WinProcs, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, HttpProt, StdCtrls, IniFiles, ExtCtrls, ComObj, ComCtrls, OleCtrls;
// Added ComObj, ComCtrls, OleCtrls to the original list of uses
type
THttpGetForm = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
InfoLabel: TLabel;
URLEdit: TEdit;
ProxyHostEdit: TEdit;
ProxyPortEdit: TEdit;
FileNameEdit: TEdit;
GetButton: TButton;
AbortButton: TButton;
Button1: TButton;
Button2: TButton;
HttpCli1: THttpCli;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
RadioGroup1: TRadioGroup;
Memo1: TMemo;
procedure GetButtonClick(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure HttpCli1DocData(Sender: TObject; Buffer: Pointer;
Len: Integer);
procedure HttpCli1HeaderData(Sender:
procedure AbortButtonClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure RadioGroup1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
FInitialized: Boolean;
FIniFileName: string;
public
end;
var
HttpGetForm: THttpGetForm;
implementation
{$R *.DFM}
const
SectionData = 'Data';
KeyURL = 'URL';
KeyProxyHost = 'ProxyHost';
KeyProxyPort = 'ProxyPort';
KeyFileName = 'FileName';
SectionWindow = 'Window';
KeyTop = 'Top';
KeyLeft = 'Left';
KeyWidth = 'Width';
KeyHeight = 'Height';
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.FormCreate(Se
begin
FIniFileName := LowerCase(ExtractFileName(
FIniFileName := Copy(FIniFileName, 1, Length(FIniFileName) - 3) + 'ini';
InfoLabel.Caption := '';
RadioGroup1.ItemIndex := 0;
Memo1.Clear;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.FormShow(Send
var
IniFile: TIniFile;
begin
//Statement placed here to prepare to Coinitialize
if InitProc <> nil then TProcedure(InitProc);
//*************
if not FInitialized then begin
FInitialized := TRUE;
IniFile := TIniFile.Create(FIniFileNa
URLEdit.Text := IniFile.ReadString(Section
'http://www.rtfm.be/fpiette/images/overbyte.gif');
ProxyHostEdit.Text := IniFile.ReadString(Section
'');
ProxyPortEdit.Text := IniFile.ReadString(Section
'80');
FileNameEdit.Text := IniFile.ReadString(Section
'test.tmp');
Top := IniFile.ReadInteger(Sectio
Left := IniFile.ReadInteger(Sectio
Width := IniFile.ReadInteger(Sectio
Height := IniFile.ReadInteger(Sectio
IniFile.Free;
end;
RadioGroup1.ItemIndex := 0;
URLEdit.Text := 'http://users.swing.be/francois.piette/wsocketu.htm';
FileNameEdit.Text := 'View1.html';
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.RadioGroup1Cl
begin
if RadioGroup1.ItemIndex = 0 then begin //ICS
URLEdit.Text := 'http://users.swing.be/francois.piette/wsocketu.htm';
FileNameEdit.Text := 'View1.html';
end;
if RadioGroup1.ItemIndex = 1 then begin //Delphi Tips
URLEdit.Text := 'https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20161215&jsessionid=200156996586977326'; // EE Q
FileNameEdit.Text := 'View2.html';
end;
end;
procedure THttpGetForm.FormClose(Sen
var Action: TCloseAction);
var
IniFile: TIniFile;
begin
IniFile := TIniFile.Create(FIniFileNa
IniFile.WriteString(Sectio
IniFile.WriteString(Sectio
IniFile.WriteString(Sectio
IniFile.WriteString(Sectio
IniFile.WriteInteger(Secti
IniFile.WriteInteger(Secti
IniFile.WriteInteger(Secti
IniFile.WriteInteger(Secti
IniFile.Free;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.GetButtonClic
var
S: string;
begin
HttpCli1.URL := URLEdit.Text;
HttpCli1.Proxy := ProxyHostEdit.Text;
HttpCli1.ProxyPort := ProxyPortEdit.Text;
HttpCli1.RcvdStream := TFileStream.Create(FileNam
GetButton.Enabled := FALSE;
AbortButton.Enabled := TRUE;
InfoLabel.Caption := 'Loading';
try
try
HttpCli1.Get;
InfoLabel.Caption := 'Received ' +
IntToStr(HttpCli1.RcvdStre
except
on E: EHttpException do begin
InfoLabel.Caption := 'Failed : ' +
IntToStr(HttpCli1.StatusCo
HttpCli1.ReasonPhrase; ;
end
else
raise;
end;
finally
GetButton.Enabled := TRUE;
AbortButton.Enabled := FALSE;
HttpCli1.RcvdStream.Seek(0
SetLength(S, HttpCli1.RcvdStream.Size);
HttpCli1.RcvdStream.Read(S
Memo1.Text := S;
HttpCli1.RcvdStream.Destro
HttpCli1.RcvdStream := nil;
InfoLabel.Caption := 'Task Completed';
end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.HttpCli1DocDa
Len: Integer);
begin
InfoLabel.Caption := IntToStr(HttpCli1.RcvdCoun
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.HttpCli1Heade
begin
InfoLabel.Caption := InfoLabel.Caption + '.';
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.AbortButtonCl
begin
HttpCli1.Abort;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.Button1Click(
var
IE, Doc, Bod, V: oleVariant;
I, I1, X: integer;
S: string;
F: TStream;
begin
Memo1.Clear;
F := TFileStream.Create(Extract
try
SetLength(S, F.Size);
F.Read(S[1], Length(S));
finally
F.Free;
Memo1.lines.add(s);
end;
IE := CreateOleObject('InternetE
IE.Navigate('about:blank',
IE.Visible := true; //false keeps it hidden
while IE.Busy do
Application.ProcessMessage
Doc := IE.Document;
Bod := Doc.Body;
Bod.InnerHTML := Memo1.Text;
Memo1.Text := Bod.InnerText;
//IE.Quit;
InfoLabel.Caption := 'Saving Text File';
with TFileStream.Create(Extract
try
I := 0;
X := Memo1.Lines.Count;
while I < X do
begin
Memo1.Lines[I];
I1 := Length(Memo1.Lines[I]);
Write(Pointer(Memo1.Lines[
Inc(I);
end;
finally free end;
end;
{* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *}
procedure THttpGetForm.Button2Click(
begin
Application.Terminate;
end;
end.
ASKER
Mike,
Sorry, but I just don't see how you are going from the internet download stream to stream into IE without going first
to a download on the disk..
Anyway , you tried = 'A' grade and 50 points.
Delphi3
Sorry, but I just don't see how you are going from the internet download stream to stream into IE without going first
to a download on the disk..
Anyway , you tried = 'A' grade and 50 points.
Delphi3
Ok, perhaps we need to restate the question. In my example I filled the webBrowser with data from a TMemoryStream, that's a delphi object that gives abstracted access to a chunk of memory like it was a file. If I understand your last comment correctly you said you wanted to grab a file off some remote internet site & display it in the webBrowser without saving it to disk first. If I understand right, why not something like:
webBrowser1.navigate('http://www.experts-exchange.com');
?
GL
Mike
webBrowser1.navigate('http://www.experts-exchange.com');
?
GL
Mike
ASKER
Mike,
Super!! , Well done!! Thanks.
unit GetWebBrowserUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, activeX,
StdCtrls, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
//WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
WebBrowser_V11: TWebBrowser_V1;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
URL: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender : TObject);
var
Doc, V, Bod: OleVariant;
I1, I, X: integer;
ms: TMemoryStream;
begin
webBrowser_V11.navigate(Ed it1.Text, V, V, V, V);
//webBrowser_V11.navigate( 'about:bla nk',V,V,V, V);
while webBrowser_V11.busy do
application.processMessage s;
Doc := webBrowser_V11.Document;
Bod := Doc.Body;
Memo1.Text := Bod.InnerText;
//Bod.InnerHTML := Memo1.Text;
//IE.Quit;
with TFileStream.Create(Extract FilePath(A pplication .exeName) + 'TextSavedSeenInView' + 'View'
+ '.txt', fmCreate) do
try
I := 0;
X := Memo1.Lines.Count;
while I < X do
begin
Memo1.Lines[I];
I1 := Length(Memo1.Lines[I]);
Write(Pointer(Memo1.Lines[ I])^, I1);
Inc(I);
end;
finally free end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Edit1.Text := 'https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20161215&jsessionid=200156996586977326';
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
Application.Terminate;
end;
end.
Thanks again.
Delphi3
Super!! , Well done!! Thanks.
unit GetWebBrowserUnit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, activeX,
StdCtrls, OleCtrls, SHDocVw_TLB;
type
TForm1 = class(TForm)
//WebBrowser1: TWebBrowser;
Memo1: TMemo;
Button1: TButton;
WebBrowser_V11: TWebBrowser_V1;
Button2: TButton;
Label1: TLabel;
Label2: TLabel;
Edit1: TEdit;
URL: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender
var
Doc, V, Bod: OleVariant;
I1, I, X: integer;
ms: TMemoryStream;
begin
webBrowser_V11.navigate(Ed
//webBrowser_V11.navigate(
while webBrowser_V11.busy do
application.processMessage
Doc := webBrowser_V11.Document;
Bod := Doc.Body;
Memo1.Text := Bod.InnerText;
//Bod.InnerHTML := Memo1.Text;
//IE.Quit;
with TFileStream.Create(Extract
+ '.txt', fmCreate) do
try
I := 0;
X := Memo1.Lines.Count;
while I < X do
begin
Memo1.Lines[I];
I1 := Length(Memo1.Lines[I]);
Write(Pointer(Memo1.Lines[
Inc(I);
end;
finally free end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Edit1.Text := 'https://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=delphi&qid=20161215&jsessionid=200156996586977326';
end;
procedure TForm1.Button2Click(Sender
begin
Application.Terminate;
end;
end.
Thanks again.
Delphi3
Q: How do I load a stream into the WebBrowser without Navigating to a file?
A: Here's some sample code:
function TForm1.LoadFromStream(cons
begin
AStream.seek(0, 0);
Result := (WebBrowser1.Document as IPersistStreamInit).Load(T
end;
I found this tip here: http://members.home.net/hfournier/
GL
Mike