Article View: borland.public.delphi.language.objectpascal
Article #105Re: RichEdit and Streams
From: Yehia Ahmed
Date: Mon, 26 Jan 2004 20:37
Date: Mon, 26 Jan 2004 20:37
62 lines
2837 bytes
2837 bytes
but when i used a Tstringlist an error occured:
Sstream := tstringstream.Create('');
MainText.Lines.SaveToStream(sstream);
rtfln.Text := sstream.datastring; ---------------------->Error Eaccess
violation
Sstream.Position := 0;
sstream.Write(pchar(rtfln.Text)^,length(rtfln.text) );
sstream.position := 0;
MainText.Lines.LoadFromStream(sstream);
"Peter Below (TeamB)" <100113.1101@compuXXserve.com> wrote in message
news:VA.0000a903.004ec87e@nomail.please...
> In article <4014d318@newsgroups.borland.com>, Yehia Ahmed wrote:
> > I read about tsreams object and how to modify the rtf code of the
richedit
> > control,
> > as this we too complicated for me, i tried to load the rtf code in a
> > memo,modify it, and then use the save to strem to return back to
richedit,
> >
> > var Reg:Tregistry;
> > SS:TstringStream;
> > ReStr : Tmemo;
> > begin
> > ReStr:= tmemo.Create(form1);
> > SS := tstringstream.Create('');
> > form1.MainText.Lines.SaveToStream(ss);
> > ReStr.Text := ss.datastring;
> > ReStr.Text := stringReplace(restr.Text,'Courier New','Tahoma',[]);
> > ss.Position := 0;
> > ss.WriteString(restr.Text ) ;
> > form1.MainText.Lines.LoadFromStream(ss);
> >
> > the problem is in the last line, when executed the richedit text becomes
'',
> > although the ss.datastring contain the right code, so why is this
happening,
>
> You forgot to reset the position of ss to 0 again before the last line,
the
> WriteString puts the position to the end of the stream.
> You don't need a memo here, by the way, a simple String variable would do
as
> well. Memos are for interaction with the user, not for manipulating text
in
> code.
>
>
> --
> Peter Below (TeamB)
> Use the newsgroup archives :
> http://www.mers.com/searchsite.html
> http://www.tamaracka.com/search.htm
> http://groups.google.com
> http://www.prolix.be
>
>
Technical Details
Message-ID:
<40157aa8@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<4014d318@newsgroups.borland.com> <VA.0000a903.004ec87e@nomail.please>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109d30,b3adc9c135a2402 X-Google-Attributes: gid109d30,public X-Google-ArrivalTime: 2004-01-26 12:40:37 PST From: "Yehia Ahmed" <yehiaeg@hotmail.com> Newsgroups: borland.public.delphi.language.objectpascal References: <4014d318@newsgroups.borland.com> <VA.0000a903.004ec87e@nomail.please> Subject: Re: RichEdit and Streams Date: Mon, 26 Jan 2004 22:37:53 +0200 Lines: 64 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2720.3000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2727.1300 NNTP-Posting-Host: 62.68.242.159 Message-ID: <40157aa8@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1075149480 62.68.242.159 (26 Jan 2004 12:38:00 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail