<< Click to Display Table of Contents >>

 

WPTools can be also used to create data forms. These are special texts which are generally protected.

The user may only edit the text in specially marked areas. We call this areas 'Edit Fields'.

 

You will find a Delphi demo to highlight this feature in the subdirectory Techniques/Editfields.

 

wptools_data_formular

 

Edit fields work like mail merge fields. The only difference is that the objects use the mode flag "wpobjWithinEditable". When saved to RTF a \formfield instead of a \field tag is written.  

 

Note: WPTools includes a component TWPMMDataProvider. This component establishes an automatic link between a mailmerge or editfield form to a datasource. Much of the functionality described in the topics below are automated by the TWPMMDataProvider component.

 

WPTools 8.20 introduces the component TWPTextObjectClasses.

This component can be used for different editors at the same time and makes it much easier to control the rendering and functionality of text objects and merge fields.

 

Using the TWPTextObjectClasses it is also possible to implement combobox controls for edit forms.

 

 

TWPTextObjectClasses

 

It contains items for each field type you need.

 

The event OnObjectClassCheckMatch is used to select the right item used for a field.

 

Once it is found by this event, the other events provided by the item in the collection are used.

 

The MouseDown and Paint events make the empty space a combobox, if you

do not use that, you can still create empty space using OnCalcSize:

 

procedure TWPEdTest.WPTextObjectClasses1Items0ObjectClassCalcSize(

 Sender: TWPCustomRTFControl; Memo: TWPRTFEngineBasis;

 ReferenceCanvas : TCanvas;

 CallMode: TWPMeasureObjectMode; ObjClass: TWPTextObjectClass; TextObj: TWPTextObj; XOff, XRes, YRes: Integer;

var Distance, Width, ExtraWidth, Height, ExtraHeight: Integer);

var emTextWidth, emTextLength, ReservedCharCount : Integer;

begin

 ExtraWidth := Xres div 5;

 Width := 0;

 ReservedCharCount := 30;

 TextObj.EmbeddedTextWidthAndLength(emTextWidth, emTextLength);

if emTextLength>=ReservedCharCount then

         Distance := 0

else

if XOff>emTextWidth then

         Distance := Distance + (ReferenceCanvas.TextWidth('Aa') div 2 ) * ReservedCharCount - emTextWidth

else Distance := Distance + (ReferenceCanvas.TextWidth('Aa') div 2 ) * ReservedCharCount  - XOFF;

end;

 

That  code  basically reduces the free space when the contents becomes longer.