trichview.com

trichview.support




Re: Add text with color


Return to index


Author

Message

Sergey Tkachenko

Posted: 04/07/2003 13:37:12


You need to pass an appropriate index of text style (the second parameter of

AddNL).

This is an index in the collection RVStyle.TextStyles.

Item of this collection defines font, color, and other properties of text.

There is an initial set of items (it can be edited at design time). When you

load RTF file, new items may be added to the end of this collection.


So, you have 2 possible solutions:

1) If you need to use some limited set of styles, you can add them at design

time in Delphi and then use their indices in AddNL

2) If you need to create formatting dynamically, use this code:


{

  adding line with font having all properties of

RVStyle1.TextStyles[StyleNo], but red.

}


var StyleNo: Integer;


StyleNo := RVStyle1.FindStyleWithColor(0, clRed, clNone);

if StyleNo=-1 then begin

  RVStyle1.TextStyles.Add;

  StyleNo := RVStyle1.TextStyles.Count-1;

  RVStyle1.TextStyles[StyleNo].Assign(RVStyle1.TextStyles[0]);

  RVStyle1.TextStyles[StyleNo].Color := clRed;

  RVStyle1.TextStyles[StyleNo].Standard := False;

end;

rv.AddNL('Red text', StyleNo, 0);


There are several Find*** methods of TextStyles, with the most general

FindSuchStyle

(example of using: http://www.trichview.com/support/files/chatcodes.zip)


> Hi,

>

> I need to add a string with a given color. Is there a method similar to

> AddNL that will take an additional color parameter?

>

> Thanks,

> Martin

>

>






Powered by ABC Amber Outlook Express Converter