WPCubed Product Support

Question about custom coloring

rackerson

WPTools 6
I create document templates with mail merge capabilities using your TWPRichText.InputMergeField method. I highlight these merge fields using the code such as:

TWPRichText.AutomaticTextAttr.UseBackgroundColor := True;
TWPRichText.AutomaticTextAttr.BackgroundColor := clYellow;

I have a request to display different types of merge fields in different colors (basically, I use data from multiple databases in my mailmerge process-the request is for data from DB1 to appear one color & DB2 to appear in another).
Is such a thing possible? Is so, how?

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

Hi,

Yes, it is possible.

OnGetAttrColor is triggered for text which uses a special
style, for example a bookmark. It makes it possible to change the canvas attributes for the text output according to other conditions.

This event is triggered frequentally, please make the handler fast.
To activate the event set the UseOnGetAttrColorEvent flag in the
properties for the special style (for example in property BookmarkTextAttr)

Julian

#3 ♥ 0
rackerson

Thanks Julian,

Just so I am clear then...
I currently have the AutomaticTextAttr properties set as I described earlier. This properly handles one of the two "types" of merge fields I am dealing with (the ones from DB1). If I use the event handler you mention, should I expect the settings defined in AutomaticTextAttr to be handled as my default settings and only have to add code for my "other" merge fields (those from DB2)?

Or should I have to add code to the event handler to handle all situations? Something like:

if <merge field from DB1> then
  CharStyle.TextColor := clYellow
else if <merge field from DB2> then
  CharStyle.TextColor := clBlue;
#4 ♥ 0
This category is archived. No new posts are possible.