 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jon Jacobs Guest
|
Posted: Tue Oct 28, 2003 9:27 pm Post subject: Put a string of HTML into a TWebBrowser |
|
|
I have a TWebBrowser on a form. I construct HTML in my app into a string.
How can I get that HTML into the TWebBrowser for Display. Also, how can I
print it?
Thanks,
Jon
|
|
| Back to top |
|
 |
Nick Hodges (TeamB) Guest
|
Posted: Tue Oct 28, 2003 9:33 pm Post subject: Re: Put a string of HTML into a TWebBrowser |
|
|
On Tue, 28 Oct 2003 15:27:34 -0600, "Jon Jacobs" <jqjacobsATgte.net>
wrote:
I don't know about printing from the control, but
| Quote: | How can I get that HTML into the TWebBrowser for Display.
|
procedure AssignDocument(Browser: TWebBrowser; Text: string);
var
Document: OleVariant;
{$ifdef PERSIST_STREAM}
InStream: TStream;
Persist: IPersistStreamInit; // Declared in ActiveX
{$endif}
begin
{$ifdef WRITE_FILE}
Document := LocalServerPath('temp.html');
WriteTextFile(Document, Text); // utility function
Browser.Navigate2(Document);
{$endif}
{$ifdef PERSIST_STREAM}
Document := 'about:blank';
Browser.Navigate2(Document);
InStream := TStringStream.Create(Text);
try
Persist := (Browser.Document as IPersistStreamInit);
Persist.Load(TStreamAdapter.Create(InStream));
finally
InStream.Free;
end;
{$endif}
{$ifdef DISPATCH_DOC}
Document := 'about:blank';
Browser.Navigate2(Document);
Document := Browser.Document as IDispatch;
Document.Open;
try
Document.Write(Text);
finally
Document.Close;
end;
{$endif}
end;
Nick Hodges - TeamB
Lemanix Corporation
Please always follow the newsgroup guidelines --
http://www.borland.com/newsgroups
|
|
| Back to top |
|
 |
Ignacio Vazquez Guest
|
Posted: Tue Oct 28, 2003 9:40 pm Post subject: Re: Put a string of HTML into a TWebBrowser |
|
|
"Jon Jacobs" <jqjacobsATgte.net> wrote in message
[email]3f9edf24 (AT) newsgroups (DOT) borland.com[/email]...
| Quote: | I have a TWebBrowser on a form. I construct HTML in my app into a string.
How can I get that HTML into the TWebBrowser for Display.
|
TWebBrowser.OleObject.document.write(<whatever>);
| Quote: | Also, how can I print it?
|
TWebBrowser.OleObject.document.execCommand('Print');
Cheers,
Ignacio
--
The strange part isn't so much that he had an accent. No accent was
detectable. It was just sounds and burbs and gurgles coming from him. He
was a like a chubby, old R2-D2.
- La Üter
|
|
| Back to top |
|
 |
Jon Jacobs Guest
|
Posted: Tue Oct 28, 2003 11:29 pm Post subject: Re: Put a string of HTML into a TWebBrowser |
|
|
Thank you! I never would have imagined it took that much code.
Jon
"Nick Hodges (TeamB)" <nickhodges (AT) yahoo (DOT) com> wrote
| Quote: | On Tue, 28 Oct 2003 15:27:34 -0600, "Jon Jacobs"
wrote:
I don't know about printing from the control, but
How can I get that HTML into the TWebBrowser for Display.
procedure AssignDocument(Browser: TWebBrowser; Text: string);
var
Document: OleVariant;
{$ifdef PERSIST_STREAM}
InStream: TStream;
Persist: IPersistStreamInit; // Declared in ActiveX
{$endif}
begin
{$ifdef WRITE_FILE}
Document := LocalServerPath('temp.html');
WriteTextFile(Document, Text); // utility function
Browser.Navigate2(Document);
{$endif}
{$ifdef PERSIST_STREAM}
Document := 'about:blank';
Browser.Navigate2(Document);
InStream := TStringStream.Create(Text);
try
Persist := (Browser.Document as IPersistStreamInit);
Persist.Load(TStreamAdapter.Create(InStream));
finally
InStream.Free;
end;
{$endif}
{$ifdef DISPATCH_DOC}
Document := 'about:blank';
Browser.Navigate2(Document);
Document := Browser.Document as IDispatch;
Document.Open;
try
Document.Write(Text);
finally
Document.Close;
end;
{$endif}
end;
Nick Hodges - TeamB
Lemanix Corporation
Please always follow the newsgroup guidelines --
http://www.borland.com/newsgroups
|
|
|
| Back to top |
|
 |
Jon Jacobs Guest
|
Posted: Tue Oct 28, 2003 11:29 pm Post subject: Re: Put a string of HTML into a TWebBrowser |
|
|
Thank you very much.
Jon
"Ignacio Vazquez" <ivazquezATorioncommunications.com> wrote
| Quote: | "Jon Jacobs" <jqjacobsATgte.net> wrote in message
[email]3f9edf24 (AT) newsgroups (DOT) borland.com[/email]...
I have a TWebBrowser on a form. I construct HTML in my app into a
string.
How can I get that HTML into the TWebBrowser for Display.
TWebBrowser.OleObject.document.write(<whatever>);
Also, how can I print it?
TWebBrowser.OleObject.document.execCommand('Print');
Cheers,
Ignacio
--
The strange part isn't so much that he had an accent. No accent was
detectable. It was just sounds and burbs and gurgles coming from him. He
was a like a chubby, old R2-D2.
- La Üter
|
|
|
| Back to top |
|
 |
Nick Hodges (TeamB) Guest
|
Posted: Wed Oct 29, 2003 12:05 am Post subject: Re: Put a string of HTML into a TWebBrowser |
|
|
On Tue, 28 Oct 2003 17:29:09 -0600, "Jon Jacobs" <jqjacobs (AT) gte (DOT) net>
wrote:
| Quote: | Thank you! I never would have imagined it took that much code.
Jon
|
Note that it's actually three different methods, depending on the
compiler define. I keep meaning to split that up.....
Nick Hodges - TeamB
Lemanix Corporation
Please always follow the newsgroup guidelines --
http://www.borland.com/newsgroups
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|