![]() |
Mehrer FontStyles zuweisen
Ich habe mir eine Funktion geschrieben, die alle Wörter aus einer Liste in einem RichEdit markiert:
Delphi-Quellcode:
Aufruf mit
function MarkWords(RichEdit: TRichEdit; Words: TStrings; FontStyle: TFontStyle;
Color: TColor): Cardinal; var i: Integer; LastWordPos: Integer; begin LastWordPos := 0; for i := 0 to Words.Count - 1 do begin while LastWordPos < 500 do begin LastWordPos := FindWord(LastWordPos, RichEdit.Text, Words[i]); RichEdit.SelStart := LastWordPos; RichEdit.SelLength := length(Words[i]); RichEdit.SelAttributes.Color := Color; RichEdit.SelAttributes.Style := [FontStyle]; LastWordPos := LastWordPos + 1; end; LastWordPos := 0; end; RichEdit.SelStart := 0; result := 0; end;
Delphi-Quellcode:
Wie bekomme ich es jetzt hin, dass ich gleich mehrer Styles (fsBold, fsItalic) zuweisen kann? Und wie hebe ich es wieder auf?
MarkWords(RichEdit1, sl, fsBold, clRed);
|
Re: Mehrer FontStyles zuweisen
Hi,
der Zuweis ist nicht schwer:
Delphi-Quellcode:
mfG
function MarkWords(RichEdit: TRichEdit; Words: TStrings; FontStyles: TFontStyles;
Color: TColor): Cardinal; var i: Integer; LastWordPos: Integer; begin LastWordPos := 0; for i := 0 to Words.Count - 1 do begin while LastWordPos < 500 do begin LastWordPos := FindWord(LastWordPos, RichEdit.Text, Words[i]); RichEdit.SelStart := LastWordPos; RichEdit.SelLength := length(Words[i]); RichEdit.SelAttributes.Color := Color; RichEdit.SelAttributes.Style := FontStyles; LastWordPos := LastWordPos + 1; end; LastWordPos := 0; end; RichEdit.SelStart := 0; result := 0; end; // Aufruf: MarkWords(RichEdit1, sl, [fsBold, fsItalic], clRed); mirage228 |
Re: Mehrer FontStyles zuweisen
Ah ja. Danke. Dieses blöde "s". :roll:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 20:45 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz