- Offizieller Beitrag
Q: How to delete characters with special attribute, i.e. Hidden or Bold
A: The following code loops to all the text and marks all characters which have a certain character style with the deletion marker. Later all text with that marker is deleted by DeleteMarkedChar.
Code
par : TParagraph;
i: Integer;
c : Cardinal;
begin
par := WPRichText1.HeaderFooter.FirstPar;
while par<>nil do
begin
for I := 0 to par.CharCount-1 do
begin
c := par.CharAttr[i];
WPRichText1.AttrHelper.CharAttr := c;
if WPRichText1.AttrHelper.HasAStyle(afsBold) then // afsHidden
begin
c := c or cafsDelete;
par.CharAttr[i] := c;
end;
end;
par := par.globalnext;
end;
WPRichText1.DeleteMarkedChar(true);
end;
Alles anzeigen