OnCustomLinePaintAfter property

Applies to
TWPPreview

Declaration
property OnCustomLinePaintAfter: TWPVirtPagePaintEvent;

Description
This event is used like OnCustomLinePaintBefore but is triggered after the text has been rendered. This makes it possible to draw over the text. Param is an object which is usually reused for each paragraph. FirstRect is initialized to the rectangle of the first line of this paragraph on the page. Rect is the current rectangle. If the property UseUntilIncludingPar is set to a certain paragraph the object is reused for all paragraphs until the given one. If CallAgainToClose has been set to TRUE the event is triggered again after the last line.
The following example draws a line around each paragraph or consecuative paragraphs starting with one which contains $start and ends with one which containes $end.
    procedure Form1.WPRichText1CustomLinePaintAfter(Sender: TObject;
  RTFEngine: TWPRTFEngineBasis; Param: TWPVirtPagePaintParam;
  EndOfPageRun: Boolean);
var r: TRect; par: TParagraph;
begin
  if not EndOfPageRun then
  begin
    if Param.Tag = 0 then
    begin
      par := Param.Par;
      if par.HasText('$start') then
      begin
        while par <> nil do
        begin
          if par.HasText('$end') then
            break;
        par := par.next;
        end;
        Param.UseUntilIncludingPar := par;
      end;
    end;
    Param.Tag := 1;
    Param.CallAgainToClose := TRUE;
  end
else
  begin
    r := Param.UnionRect;
    Param.Canvas.Brush.Style := bsClear;
    Param.Canvas.Pen.COlor := clRed;
    Param.Canvas.Pen.Width := 0;
    Param.Canvas.Rectangle(
      r.Left, r.Top, r.Right, r.Bottom);
  end;
end; 

Note: The API UnionRect() deals differently with rectangle which have a height of 0 than Param.UnionRect!.

Category
Paragraph-Reference


Copyright (C) by WPCUBED GmbH - Munich
http://www.wpcubed.com