Autor Beitrag
Moritz M.
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Sa 05.10.02 13:49 
Hi

Wie der Betreff schon sagt wollte ich fragen ob man in einem Textfeld die Farbe und Schriftart usw. ändern kann.

_______________________
Blablabal
Lalala
meepmeepmeep
_______________________
Also halt so irgendwie...

cu

Onz
bis11
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1247
Erhaltene Danke: 2

Apple Mac OSX 10.11

BeitragVerfasst: Sa 05.10.02 14:26 
Hi Onz,

soweit ich weiß, ist die TMemo-Kompo eine reine Textkompo. Wenn Du sowas machen möchtest muß Du die RichEdit-Kompo benutzen.
Moritz M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Sa 05.10.02 14:30 
Titel: Hi
Hi Thanks für die Antwort.

Dann würde ich die Frage umformulieren:
Wie kann ich für bestimmte Textteile eines RichEdit eine Frabe bzw Breite definieren.

Z.B. Wie bei einem HTML-Editor, der den Systnax hervorhebt

cu

onz
Sven
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 314


D6 Ent, K3 Pro (patched)
BeitragVerfasst: Sa 05.10.02 14:54 
Folgenden Code habe ich auf dem SwissDelphiCenter-Forum in deren Tip-Sammlung gefunden.

ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
procedure HTMLSyntax(RichEdit: TRichEdit; TextCol, TagCol, DopCol: TColor); 
var  
  i, iDop: Integer; 
  s: string; 
  Col: TColor; 
  isTag, isDop: Boolean; 
begin 
  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 = '{') then isTag := True; 

    if isTag then 
      if (s = '"') then 
        if not isDop then 
        begin 
          iDop  := 1; 
          isDop := True; 
        end  
        else 
          isDop := False; 

    if isTag then 
      if isDop then 
      begin 
        if iDop <> 1 then Col := DopCol; 
      end  
      else 
        Col := TagCol 
    else 
      Col := TextCol; 

    RichEdit.SelAttributes.Color := Col; 

    iDop := 0; 

    if (s = '>') or (s = '}') then isTag := False; 
  end; 
   
  RichEdit.SelLength := 0; 
end; 

procedure TForm1.Button1Click(Sender: TObject); 
begin 
  RichEdit1.Lines.BeginUpdate; 
  HTMLSyntax(RichEdit1, clBlue, clRed, clGreen); 
  RichEdit1.Lines.EndUpdate; 
end;


Ich hoffe es hilft.

Sven

_________________
MDK 9.1, Kernel 2.4.21, KDE 3.1 Kylix 3 Pro (patched), nutze aber auch Windows
Moritz M. Threadstarter
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1672



BeitragVerfasst: Mo 07.10.02 12:46 
Titel: Hi
Thanks! :P