Board index » delphi » getting color n my RichEdit

getting color n my RichEdit

Hi all,

I have a problem here.
I've wrote a texteditor, first for plain text. This is now
finished, it does syntaxhighlighting for '.pas', '.java', '.cpp'
and some other file extensions.
I'm now adding an rtf_mode, this works well too, the userinterface
for changing textattributes is done, but when i save the file
with the Lines.SaveToFile() method and open it again
with the Lines.LoadFromFile() method all color are gone.
I've looked in the file and there is color information stored, an
I also opened it with other programms e.g. WORD and it
displayed it right. So the Conversion in Delphi is not right.
After some search in the source I've found out that Delphi
creates a stream to the file and then sends a message
EM_STREAMIN with ConversionFormat SF_RTF and
the Stream as parameters, But I could not find the procedure
handling this message to change it. Do I have to do the whole
parsing myself if I want the color to be displayed right, or
can somebody tell me where this procedure is ???
Or is there a newer Version of TCustomRichEdit which fix
my problems ???

Thanks in advance

Bieber

 

Re:getting color n my RichEdit


Alex Bieber <A...@NightLabs.de> schreef in berichtnieuws
3B285137.47A45...@NightLabs.de...
Quote
> Hi all,

> I have a problem here.
> I've wrote a texteditor, first for plain text. This is now
> finished, it does syntaxhighlighting for '.pas', '.java', '.cpp'
> and some other file extensions.
> I'm now adding an rtf_mode, this works well too, the userinterface
> for changing textattributes is done, but when i save the file
> with the Lines.SaveToFile() method and open it again
> with the Lines.LoadFromFile() method all color are gone.
> I've looked in the file and there is color information stored, an
> I also opened it with other programms e.g. WORD and it
> displayed it right. So the Conversion in Delphi is not right.

[SNIP]

From OL-Help :

TRichEdit.PlainText;
--------------------
Controls whether the rich edit control treats the text as plain text or rich
text when streaming to or from a file.

property PlainText: Boolean;

Description

To write the rich text in the control to a plain text file, set PlainText to
True before streaming the text to a file. To ignore the rich text
information encoded in a file, set PlainText to True before streaming the
text to the control. To stream in the rich text attributes encoded in a
file, or save the encoding of the rich text attributes to a file, set
PlainText to False.

If the rich text attributes of a file are encoded in some format other than
rich text format (RTF), it is necessary to use a converter on the text, even
when PlainText is True.

Note: Rich edit controls do not directly support streaming. Use the Lines
property to stream to or from a file.

--
Regards,

Dirk Claessens
---------------------------------------------------------
http://www.claessens16.yucom.be
Attention: All spamshields raised; E-mails will bounce!
---------------------------------------------------------

Re:getting color n my RichEdit


A doh question, is PlainText set to false?
Quote
Alex Bieber wrote:

> I'm now adding an rtf_mode, this works well too, the userinterface
> for changing textattributes is done, but when i save the file
> with the Lines.SaveToFile() method and open it again
> with the Lines.LoadFromFile() method all color are gone.
> I've looked in the file and there is color information stored, an
> I also opened it with other programms e.g. WORD and it
> displayed it right. So the Conversion in Delphi is not right.

Re:getting color n my RichEdit


OK, seems I didn't express well.
Of course PlainText ist False and everything
workst, the Numbering, the Fonts and so on,
except the Color, I ment, all colors are gone.
I thought this was clear when I wrote that
color information was stored in the file and
WORD could display it, so again my question:
Why does my RichEdit does not come up with the colors that
are actually saved in the file.
Or, where ist this:
procedure SomeName(var Msg: TMessage); message EM_STREAMIN;

Thanks again ...

Bieber

Quote
Dirk Claessens wrote:
> Alex Bieber <A...@NightLabs.de> schreef in berichtnieuws
> 3B285137.47A45...@NightLabs.de...
> > Hi all,

> > I have a problem here.
> > I've wrote a texteditor, first for plain text. This is now
> > finished, it does syntaxhighlighting for '.pas', '.java', '.cpp'
> > and some other file extensions.
> > I'm now adding an rtf_mode, this works well too, the userinterface
> > for changing textattributes is done, but when i save the file
> > with the Lines.SaveToFile() method and open it again
> > with the Lines.LoadFromFile() method all color are gone.
> > I've looked in the file and there is color information stored, an
> > I also opened it with other programms e.g. WORD and it
> > displayed it right. So the Conversion in Delphi is not right.
> [SNIP]

> From OL-Help :

> TRichEdit.PlainText;
> --------------------
> Controls whether the rich edit control treats the text as plain text or rich
> text when streaming to or from a file.

> property PlainText: Boolean;

> Description

> To write the rich text in the control to a plain text file, set PlainText to
> True before streaming the text to a file. To ignore the rich text
> information encoded in a file, set PlainText to True before streaming the
> text to the control. To stream in the rich text attributes encoded in a
> file, or save the encoding of the rich text attributes to a file, set
> PlainText to False.

> If the rich text attributes of a file are encoded in some format other than
> rich text format (RTF), it is necessary to use a converter on the text, even
> when PlainText is True.

> Note: Rich edit controls do not directly support streaming. Use the Lines
> property to stream to or from a file.

> --
> Regards,

> Dirk Claessens
> ---------------------------------------------------------
> http://www.claessens16.yucom.be
> Attention: All spamshields raised; E-mails will bounce!
> ---------------------------------------------------------

Other Threads