Colours in dbrichviewedit text

General TRichView support forum. Please post your questions here
Post Reply
jota
Posts: 48
Joined: Fri Sep 16, 2011 10:56 am

Colours in dbrichviewedit text

Post by jota »

Hi

What is the easiest way to know how many colors there are in the text of a dbrichviewedit?

For example:

"This is the text in a dbdrichviewedit]" -> The result is three (black, red and blue)

Thanks in advance
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

For each RVStyle.TextStyles[], check Color property.

Also, list markers may have colors.
For each RVStyle.ListStyles[].Levels[], if UsesFont returns True, check Font.Color.
jota
Posts: 48
Joined: Fri Sep 16, 2011 10:56 am

Post by jota »

hi

I doubt

I need to know the different colors actually in the written text in tdbrichviewedit.

RVStyle.TextStyles gives me the information I need?

Or only contains information about colors and other styles possibilities. if so how can I get information that i want?

Thanks
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

Post by Sergey Tkachenko »

TextStyles actually represent formatting of text, not real styles (real styles are called StyleTemplates, and they are optional).

TextStyles contain information about attributes of all text. There can be only one problem: some styles may be unused (no text item uses them).
For DBRichViewEdit, it is HIGHLY recommended to set AutoDeleteUnusedStyles=True, so that unused styles are deleted when a new document is created.

You can call DeleteUnusedStyles(True, True, True) before enumerating colors, it will delete unused styles. However, this method clears undo buffer as well.
Another problem: DeleteUnusedStyles does not delete styles having property Standard=True. To solve this problem, delete at design time all RVStyle.TextStyles and RVStyle.ParaStyles, except the first item in the collection.
Post Reply