![]() |
Delphi Richedit Parsen und Fontcolor auslesen
Hi,
ich möchte in einem Richedit den Text inkl. Fontcolor auslesen, und Fontcolor durch vorgegebene Strings ersetzen und in ein anderes Richedit Feld einlesen. als Beispiel: (clyellow)Hallo(clred)welt! -> _gelb_Hallo_rot_welt Nur leider finde ich keine Info wie ich die Fontfarbe parsen und ersetzen kann. Gruß |
AW: Delphi Richedit Parsen und Fontcolor auslesen
Erzeug Dir doch einfach mal bunten Text im Wordpad und schau dir den RTF-Code an. Ich bezweifle allerdings, das Du dort Farbennamen sehen wirst, höchstens RGB-Werte.
|
AW: Delphi Richedit Parsen und Fontcolor auslesen
Die RGB Werte reichen ja schon als Identifikation. Die könnte ich dann entsprechend ersetzen und den Text inkl. verarbeitetem RGB Code in ein anderes Richedit einfügen.
Nur wie Parse ich das? void __fastcall TForm7::Button1Click(TObject *Sender) { int textLength, i; TConsistentAttributes textAttribute; TColor textColor; textLength = RichEdit1->Text.Length() ; for (i = 0; i < textLength; i++) { RichEdit1->SelStart = i; RichEdit1->SelLength = 1; textAttribute = RichEdit1->SelAttributes->ConsistentAttributes; if (textAttribute.Contains(caColor)) { textColor = RichEdit1->SelAttributes->Color; if (textColor == clRed) { } } } So würde ich es in C++ machen. |
AW: Delphi Richedit Parsen und Fontcolor auslesen
Hallo,
warum ConsistentAttributes? Aus der OH: Zitat:
Mit Deinem Ansatz:
Delphi-Quellcode:
Sollte dann Hallowelt! -> _gelb_Hallo_rot_welt! als Ergebnis kommen.
procedure TForm1.Button1Click(Sender: TObject);
var s : string; i : Integer; c : TColor; begin RichEdit1.SelStart := i; c := RichEdit1.SelAttributes.Color; if c < $7FFFFFFF then Inc (c) else Dec (c); s := ''; for i := 1 to Length (RichEdit1.Text) do begin RichEdit1.SelStart := i; if c <> RichEdit1.SelAttributes.Color then begin c := RichEdit1.SelAttributes.Color; s := s + '_' + ColorToString (c) + '_' end; s := s + RichEdit1.Text [i] end end; Gruß |
AW: Delphi Richedit Parsen und Fontcolor auslesen
Vielen Dank Volker,
deshalb hat das mit ConsistentAttributes auch nicht funktioniert.. Gruß |
Alle Zeitangaben in WEZ +1. Es ist jetzt 10:22 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