TextObjects.InsertClass

Top  Previous  Next

This is alternative low level code to be used to create a text box in the header text:

 

var par : TParagraph;

   block, block2 : TWPRTFDataBlock;

   obj : TWPTextObj;

begin

  block :=  WPRichText1.HeaderFooter.Get(wpIsHeader,wpraOnAllPages,'');

 block.Clear(true);

par := block.AppendNewPar();

// We create the text box in the paragraph we just appended to the header:

obj := WPRichText1.TextObjects.InsertClass('TWPORTFTextBox', 1440, 1440, wpobjSingle, par);

if obj <> nil then

begin

   obj.ObjRef.MakeUniqueName;

   obj.Frame := [wpframe1pt];

  // wpobjRelativeToParagraph must be set!

   obj.Mode := [wpobjCreateAutoName, wpobjRelativeToParagraph];

   obj.RelX := WPRichText1.Header.LeftMargin;

  // Create a TWPRTFDataBlock for this box

   block2 := WPRichText1.HeaderFooter.Get(wpIsOwnerSelected, wpraNamed, obj.ObjRef.objname);

   par := block2.AppendNewPar();

   par.Append('Some Text in box');

end;

 

 WPRichText1.ReformatAll(false, true);