Forum
Grundkurs
»Introduktion
»Snabbguide
»Komponenter
»Händelser
»Strängar
»Räkna med Delphi »Egna
typer
»Selektion
»Iteration
»Menyer
»Funktioner
»Arraystrukturer
Tips & Tricks
»Nya tips
»Blandat
»Databaser
»Filer
»Forms
»Grafik
»Internet
»Komponenter
»Matematik
»Multimedia
»Objekt/ActiveX
»Skrivare
»Strängar
»System
»Mest lästa tips
Artiklar
»Delphi och ADO
»Bygga en DLL
»Skapa en enkel rapport
»Hantera registret
»Enheter, units
»Klassen TCanvas
»Använd LookUp Controls
Nya
tips
Lägg
till tips
Delphilänkar
Gästbok
|
|
|
|
Markera HTML-taggar i en TRichEdit
|
Kategori: Blandat
Inlagt: 2006-04-02
Läst: 1398
Inlagt av: Staffan Berg
|
Beskrivning |
Så här ser du till att HTML-taggarna i en TRichEditkontroll blir markerade.
|
Kod |
procedure HTMLSyntax(RichEdit: TRichEdit; TextCol, TagCol, DopCol: TColor); var i, iDop : integer; s : string ; Col : TColor; isTag, isDop: boolean; begin //HTMLSyntax iDop := 0; isDop := False; isTag := False; Col := TextCol; RichEdit.SetFocus; for i := 0 to Length(RichEdit.Text) do begin RichEdit.SelStart := i; RichEdit.SelLength := 1; s := RichEdit.SelText; if (s='<') or (s=char(123)) then isTag := True; if isTag then if (s=char(34)) then if not isDop then begin iDop := 1; isDop := True end { not isDop } else isDop := False; if isTag then if isDop then begin if iDop<>1 then Col := DopCol end { isDop } else Col := TagCol else Col := TextCol; RichEdit.SelAttributes.Color := Col; iDop := 0; if (s='>') or (s=char(125)) then isTag := False end; //for i RichEdit.SelLength := 0 end; //HTMLSyntax procedure TForm1.Button1Click(Sender: TObject); begin //TForm1.Button1Click RichEdit1.Lines.BeginUpdate; HTMLSyntax(RichEdit1, clBlue, clRed, clGreen); RichEdit1.Lines.EndUpdate end; //TForm1.Button1Click
|
|
|