OnGetSpecialText Event

<< Click to Display Table of Contents >>

Navigation:  Programming > Create text under program control > Header/Footer API >

OnGetSpecialText Event

Please note, the above puts the cursor into a certain header/footer text. It does not change which header or footer is currently displayed on the page. If you need to modify the way header and footer are selected for the display in page layout mode use the OnGetSpecialText event.

 

This event receives this parameters:

 

Sender: TObject;

par: TParagraph;

PosInPar: Integer;

PageNr: Integer;

Kind: TWPPagePropertyKind;

var IsLastPage: Boolean;

var UseThis: Boolean;

var SpecialText: TWPRTFDataBlock

 

You can set UseThis to true to let the RTF Engine use as header or footer whatever item you have chosen in 'SpecialText'. To switch off the header or footer set this parameter to nil:

 

 SpecialText := nil;

if PageNr=1 then

      UseThis := TRUE

else UseThis := FALSE;

 

This event handler selects the ALL PAGES header or footer for all pages, also first, odd and even no matter what other header or footer are there:

 

procedure TForm1.WPRichText1GetSpecialText(Sender: TObject;

 par: TParagraph; PosInPar, PageNr: Integer; Kind: TWPPagePropertyKind;

var IsLastPage, UseThis: Boolean; var SpecialText: TWPRTFDataBlock);

begin

// We use 'Get' to find the header or footer

 SpecialText := WPRichtext1.HeaderFooter.Get(Kind, wpraOnAllPages, '');

// Only then the variable is actually used

 UseThis := TRUE;

end;