trichview.com

trichview.support




Re: Selected text color ?


Return to index


Author

Message

Yernar FoxTail

Posted: 12/03/2002 16:15:41


Very simple example:

1. Drop RichViewEdit, RVStyle, ColorDialog and SpeedButton components on

the form.

2. Declare constant for ApplyStyleConversion:

const

  TEXT_COLOR      = 7;

3. Write an event handler (of clicking the SpeedButton):

procedure TForm1.SpeedButton1Click(Sender: TObject);

begin

  ColorDialog1.Color := RVStyle1.TextStyles[RichViewEdit1.CurTextStyleNo].Color;

  if ColorDialog1.Execute then

    RichViewEdit1.ApplyStyleConversion(TEXT_COLOR);

end;


4. And finally you should handle OnStyleConversion event like this:


procedure TForm1.RichViewEdit1StyleConversion(Sender: TCustomRichViewEdit;

  StyleNo, UserData: Integer; AppliedToText: Boolean;

  var NewStyleNo: Integer);

var

  FontInfo: TFontInfo;

begin

  FontInfo := TFontInfo.Create(nil);

  try

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

    case UserData of

      TEXT_COLOR:

        FontInfo.Color := ColorDialog1.Color;

    end;

    NewStyleNo := RVStyle1.TextStyles.FindSuchStyle(StyleNo,FontInfo,RVAllFontInfoProperties);

    if NewStyleNo=-1 then begin

      RVStyle1.TextStyles.Add;

      NewStyleNo := RVStyle1.TextStyles.Count-1;

      RVStyle1.TextStyles[NewStyleNo].Assign(FontInfo);

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

    end;

  finally

    FontInfo.Free;

  end;

end;



That's all!


Hope it helps.


"visitorrr" <[email protected]> wrote:

>

>Excuse-me but I have try and there are many issues ! Can you explain me

more

>please ?

>

>"Yernar FoxTail" <[email protected]> wrote:

>>

>>Use ApplyStyleConversion method. This method applies custom conversion

of

>>text styles of selected text.

>>

>>

>>"visitorrr" <[email protected]> wrote:

>>>

>>>When I do this:

>>>FormeCourrante.RVStyle1.TextStyles[FormeCourrante.RichViewEdit1.CurTextStyleNo].Color

>>>:= ColorDialog1.Color;

>>>

>>>It's all my text who change color !

>>>

>>>How to do for change color of the selected text only ? Thank you !





Powered by ABC Amber Outlook Express Converter