Control Rendering

<< Click to Display Table of Contents >>

Navigation:  Programming > Mail Merge (replace fields with data) and data forms > Forms & Edit Fields (data forms) >

Control Rendering

All procedures which work with mail merge fields will work for the edit fields, too. Like with mail merge fields the presentation of the start and end markers is controlled by the property InsertPointAttr. The text within the markers is controlled by AutomaticTextAttr.

 

The editor for the example above had been set up with:

 

DataEdit.ProtectedProp := [ppAllExceptForEditFields];

DataEdit.EditOptionsEx := [wpTABMovesToNextEditField,wpRepaintOnFieldMove];

DataEdit.InsertPointAttr.Hidden := FALSE;

DataEdit.InsertPointAttr.CodeTextColor := $E0FFE0;

DataEdit.InsertPointAttr.CodeOpeningText := '[';

DataEdit.InsertPointAttr.CodeClosingText := ']';

 

The most important property change is ProtectedProp := [ppAllExceptForEditFields]. This makes it impossible for the cursor to move anywhere else than within edit field tags.

 

To make it possible to highlight the current field (yellow background) the property UseOnGetAttrColorEvent and the event OnGetAttributeColor has been used:

 

DataEdit.AutomaticTextAttr.UseOnGetAttrColorEvent := TRUE;

 

procedure TWPEdTest.DataEditGetAttributeColor(Sender: TObject;

var CharStyle: TCharacterAttr; par: TParagraph; posinpar: Integer);

var obj : TWPTextObj;

begin

 obj := DataEdit.CodeInsideOf(par,posinpar,wpobjMergeField);

if obj = DataEdit.FieldAtCP then

begin

    CharStyle.BackgroundColor := $A0FFFF;

    CharStyle.UseBackgroundColor := TRUE;

end;

end;