ProtectedTextAttr.BackgroundColor and CurrAttr.BKColor

  • Hi,

    I have created a highlight procedure in my text editor, to be used in a 'Find' method. So, I need to highlight every ocurrence of the found words. I defined that the found word would have its background as clLime. This code is done like this:

    for every found word...

    Code
    oWPRichText.Finder.SelectText;
    oWPRichText.CurrAttr.BKColor := oWPRichText.CurrAttr.ColorToNr(clLime, false);

    But I also have defined that ProtectedTexts would have a defined color to its background (ProtectedTextAttr.UseBackgroundColor is TRUE and ProtectedTextAttr.BackgroundColor is $00D9FDFF).

    The problem is simple. The color defined in BKColor never appears, if the found word is inside a protected area.

    I tried to find a way to define 'which color is the boss', but with no success.

    Does anyone has an idea?

    Thanks for your help

    • Offizieller Beitrag

    The special text attr are "the boss"

    Please note that there is an event to adjust the color according to the context of the "special" text (OnGetAttrColor)

    V6 also has "on the fly" formatting, may be useful. It also has word highlighting.


    Julian

  • Hi Julian,

    Yes, I did find this event, but I couldn't figure out how to use it to have the behavior I want. The special text attr must be painted normally, just as defined, but the BKColor should be 'the boss' in this case.

    I found some code about word highlight in V5 (cafsWordHighlight), but it appears to be incomplete (no read/write routines). Is this? And this word highlight will be 'the boss', or will the special text attr remains on top?

    I could accomplish my need with a minor change in WPRTEPaint, method TWPRTFEnginePaint.SetCanvasAttr, while checking for cpa.UseHotBackgroundColor (adding check for Props.Values[WPAT_CharBGColor]). I was intending to create a property (OptionsEx, or something like this) in TWPRichText to define the behavior (who should be the boss), so it should work in both situations. Is this something that you could add to WPTools original code?

    Thanks in advance

    Alessandro Fragnani