Ho to get/set paragraph color?

  • Hello,

    for a status display and an external toolbar (no WPTools-Toolbar) i need to get and set the color of the current paragraph (or the paragraph color of the selected text if ans is selected)

    I have tried it with CurrAttr.ParColor and CurrAtr.GetColorEx with no success. The help says that GetColorEx can be used with WPAT_ParColor but i can not find WPAT_ParColor anywhere.

    I als also tried:

    WPRichText.ActivePar.ASetColor(WPAT_BGColor, aColor); and
    WPRichText.SelectedTextAttr.ASetColor(WPAT_BGColor, aColor);

    both with no success. What goes wrong with my code? (The set methods were followed by a ReformatAll)

    Can cou give me a short hint?

    Thanks in advance,
    Ralf

  • Zitat von wpsupport

    What value do you use for 'aColor' ? That is not a TColor value, you need to combert it to an index value using CurrAttr.AddColor (as it was in V4).

    Julian

    Hi Julian,

    according to the helpfile this value is a TColor:

    Zitat


    Form the helpfile:
    procedure ASetColor(WPAT_Code: Byte; Value: TColor);

    So i had assigned a TColor value (clRed for example).

    I will try to assign a color index this evening.

    BTW: Is there a complete list of all WPAT_ codes somewhere, i havn't fond one yet.

    Thanky,
    Ralf

    • Offizieller Beitrag

    ASetColor indded expects a TColor, internalöly it does the conversion. But the CurrArr ParColor does not.

    See the list here:


    Maybe you should also set

    WPAT_ShadingValue, 100

    The easiest is to use CurrAttr since it changes sxome pros at once:

    function TWPSetModeControl.GetParColor: Integer;
    var a : Integer;
    begin
    Result := AGetDefault(WPAT_FGColor, 0);
    if (AGet(WPAT_ShadingValue, a) and (a=0)) or
    (AGet(WPAT_ShadingType, a) and (a=WPSHAD_solidbg)) then
    Result := AGetDefault(WPAT_BGColor, Result);
    end;

    procedure TWPSetModeControl.SetParColor(x: Integer);
    begin
    if x <= 0 then
    begin
    ADel(WPAT_FGColor);
    ADel(WPAT_BGColor);
    end
    else
    begin
    ADel(WPAT_ShadingType);
    ASet(WPAT_FGColor, x);
    ASet(WPAT_BGColor, x);
    end;
    end;

    Julian

  • Hi,

    i am using this to set the par color:

    Code
    var aColor: TColor;
    
    
      aColor := clRed;
      WPRichText.CurrAttr.ParColor := WPRichText.CurrAttr.ColorToNr(aColor, true);
      WPRichText.CurrAttr.ASet(WPAT_ShadingValue, 100);
      WPRichText.ReformatAll();

    but still no other color then the default is shown, the paragraph background is alway white.

    I use this code with an empty WPRichText directly after the for has been displayed. Are there any options that influence the display of the paragraph color?

    What can cause this? (i mean, this code is not that complicated...)

    TIA,
    Ralf

  • Hi Julian,

    i had tried your code with no success.

    Then i have completely removed WPTools (BPLs, DCUs, whatever looked like WPTools), reinstalled from scatch and suddenly it works.

    I really cannot say what went wrong.

    Ciao,
    Ralf