WPCubed Product Support

CustomDraw Fields

Hi,

Does anyone knows if it is possible to custom draw fields (basically the color) based on a specified condition? I would like to have my 'special fields' being draw in a different color from the one defined in AutomaticTextAttr.TextColor.

Thanks in advance

Alessandro Fragnani

#1 ♥ 0
2.4k Views 2 users read 1 min
support

Hi,

Usuall the best is it to apply the attribute durin mailmerge, see Contents.MergeAttr

To use the event to mark the text with red color use in case a field is negative use this code:

procedure TWPTBXForm.WPRichText1GetAttributeColor(Sender: TObject;
  var CharStyle: TCharacterAttr; par: TParagraph; posinpar: Integer);
var txtobj: TWPTextObj; s : string;
begin
  txtobj := WPRichText1.CodeInsideOf(par, posinpar, wpobjMergeField);
  if txtobj <> nil then
  begin
     s := txtobj.EmbeddedText;
     if (s<>'') and (s[1]='-') then
          CharStyle.TextColor := clRed
     else CharStyle.TextColor := clNone;
  end;
end;
#2 ♥ 0
This category is archived. No new posts are possible.