- Offizieller Beitrag
Q: Can WPTools create a background (water mark) of green bar, i.e. one line green and one line white alternately?
A: The solution can be made using the event: OnCustomLinePaintBefore
This code will color complete paragraphs:
Code
procedure TForm1.WPRichText1CustomLinePaintBefore(Sender: TObject; RTFEngine: TWPRTFEngineBasis; Param: TWPVirtPagePaintParam; EndOfPageRun: Boolean);var r : TRect;begin if not EndOfPageRun then begin Param.CallAgainToClose := TRUE; // Make sure we get that EndOfPageRun! end else begin if (Param.Par.ParNr and 1)=0 then begin r := Param.UnionRect; Param.Canvas.Brush.Color := $00A0F5B8; Param.Canvas.FillRect(r); end; end;end;
To color the lines (a paragraph may have multiple lines) as simple as:
Code
procedure TForm1.WPRichText1CustomLinePaintBefore(Sender: TObject;
RTFEngine: TWPRTFEngineBasis; Param: TWPVirtPagePaintParam;
EndOfPageRun: Boolean);
begin
if (Param.Par.Lines[Param.Line].PageLineNr and 1)=1 then
begin
Param.Canvas.Brush.Color := $00A0F5B8;
Param.Canvas.FillRect(Param.Rect);
end;
end;