add and format text

  • Hi
    Somehow i don’t find the way to programmatically add and format text to a TWPRichText component.
    What I would like to do
    RichText.Add (‘My text’ , Text Size = 10, Text Style = [fsBold], Text Color = clRed, New line = true ).
    Or some thing similar.

    Any hint would be appreciated

  • Hi

    My Procedure call


    How could I write a procedure that adds a text to the end of a TWPRichText and using Font attributes?
    The way I'm trying doesn't work.

    Thanks
    Henry

    • Offizieller Beitrag

    Hi,

    >>How could I write a procedure that adds a text to the end of a TWPRichText and using Font attributes?
    The way I'm trying doesn't work. <<

    Code
    WPRichText.CPPosition := MaxInt;WPRichText.ApplyFont( aFont );WPRichText.InputString(...)

    or this

    [/code]

  • Thank very much. Now it works I had to modify it a little.

    aHrmResult.CurrAttr.AddStyle(aFontStyles);
    aHrmResult.CurrAttr.Color := aHrmResult.CurrAttr.ColorToNr( aColor, true );
    aHrmResult.CurrAttr.Size := aSize;
    aHrmResult.InputString( aStr );
    aHrmResult.CurrAttr.DeleteStyle(aFontStyles);

    Without DeleteStyle all text would be written as bold after the first bold word.

    Henry