Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Object-Pascal / Delphi-Language (https://www.delphipraxis.net/32-object-pascal-delphi-language/)
-   -   Delphi Bestimmtest Wort in RichEdit hervorgeben (https://www.delphipraxis.net/73899-bestimmtest-wort-richedit-hervorgeben.html)

Christian18 25. Jul 2006 12:17


Bestimmtest Wort in RichEdit hervorgeben
 
Hallo,

ich möchte gerne in meiner RichEdit Komponente ein Wort immer hervorheben. Das wort Hallo soll immer wenn es geschrieben wird hervorgehoben werden. Wie kann ich das machen???

MFG Christian18

Flips 25. Jul 2006 12:28

Re: Bestimmtest Wort in RichEdit hervorgeben
 
Hi.
Meinst du Syntaxhighlighting?

Wenn ja dann sie mal hier nach
FAQsen Tutorial
Delphi-Tutorials - Syntaxhighlighting

marabu 25. Jul 2006 12:46

Re: Bestimmtest Wort in RichEdit hervorgeben
 
Hallo Christian,

ein erster Ansatz könnte so aussehen:

Delphi-Quellcode:
procedure TDemoForm.RichEditChange(Sender: TObject);
var
  iStart, iLength: Integer;
  ida: TIntegerDynArray;
  i: Integer;
  sText: String;
begin
  sText := 'Hallo';
  with RichEdit do
  begin
    LockWindowUpdate(Handle);
    iStart := SelStart;
    iLength := SelLength;
    SelStart := 0;
    SelLength := MaxInt;
    SelAttributes.Assign(DefAttributes);
    ida := FindAll(Lines.Text, sText);
    for i := Low(ida) to High(ida) do
    begin
      SelStart := Pred(ida[i]);
      SelLength := Length(sText);
      SelAttributes.Color := clRed;
      SelAttributes.Style := [fsBold];
    end;
    SelStart := iStart;
    SelLength := iLength;
    LockWindowUpdate(0);
  end;
end;
Grüße vom marabu

Flips 25. Jul 2006 12:49

Re: Bestimmtest Wort in RichEdit hervorgeben
 
ich bin grad auf da arbeit, ich kann ned soviel auf einma schreibe :-D :stupid:


Alle Zeitangaben in WEZ +1. Es ist jetzt 17:01 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz