Autor Beitrag
retnyg
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.12.04 19:21 
Ist es möglich in einem Memo verschiedene Zeilen verschieden zu färben, und wenn ja, wie ?
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:03 
Versuch mal mit:

memo1.Brush.color:=clnavy;

Natürlich musst du es dann immer wieder verändern.

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 07.12.04 20:07 
Mit einem TMemo nicht, schau dir die Komponente RichEdit an.
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:09 
Ich habs gerade getest und es funktioniert:
es ändert die Hintergrundfarbe des Textes, sodass du so auch nur ein Wort mit einer bestimmten Hintergrundfarbe färben kannst.

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
Karlson
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 2088



BeitragVerfasst: Di 07.12.04 20:14 
Sorry, ich dachte es geht um die Schriftfarbe. Hab nur den Titel gelesen und den Beitrag kurz überflogen :roll: Sorry.
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:17 
No problem.
Das nächste mal besser lesen.

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.12.04 20:20 
hallo titan, also wenn ich den Brush color ändere ändert sich bei mir immer die farbe des kompletten memos !
möchte aber eigentlich nur einige zeilen färben...
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 07.12.04 20:25 
Moin!

Mag sein, ich habe den Ansatz für
Zitat:
memo1.Brush.color:=clnavy;

verpasst, aber ich sehe bei TMemo kein OnDraw-Ereignis. Wie soll man da zeilenabhängig die Pinselfarbe austauschen... ?

cu
Narses
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:29 
Fantasie ist dabei gefragt.
Musst es OnChange oder OnKeyDown oder sonst noch was machen.
Wie du es genau haben willst, das weiß ich ja nicht.

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 07.12.04 20:32 
Moin!

Zitat:
Fantasie ist dabei gefragt.

Hm, also ohne ein eigenes Draw-Ereignis sehe ich da keine Chance, Fantasie hin oder her. Dann kann ich auch gleich die Kompo neu erstellen oder aber: RichEdit nehmen! :D

cu
Narses

@Titan Sorry, aber ohne einen Beweis-Beispiel-Code von dir halte ich deinen Vorschlag für nicht durchführbar.
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.12.04 20:34 
titan, das ändert aber nichts daran, dass sich das GANZE memofeld färbt !!
wie zb hier
ausblenden Quelltext
1:
2:
if edit1.Text = 'abc' then memo1.Brush.Color := clnavy else memo1.Brush.Color := clsilver;
  memo1.lines.add(edit1.Text);
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:43 
procedure TForm1.Memo1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key=VK_RETURN then
begin
if memo1.Brush.color=clnavy
then memo1.Brush.color:=clred {muss aber zuerst zum ende der zeile gehen}
else memo1.Brush.color:=clnavy; {muss aber zuerst zum ende der zeile gehen}
end;
end;

So muss das gehen, ich weiß nur nicht wie man zum Ende der Zeile kommt, aber ist schon eine Idee, wahrscheinlich gibts noch mehr Lösungen.

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 07.12.04 20:45 
Mach einen Redraw und deine Farben sind futsch...

Sorry, aber das wird nix, echt.
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.12.04 20:48 
kommt mir langsam auch so vor, wie mache ich es in einem richedit ?
die lines besitzen mal dort auch keine color eigenschaft
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:48 
Ok, hast recht, aber bis jetzt der best Ansatz. :D

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:50 
Übrigens das mit dem Brush hab ich erst heute zum ersten mal ausprobiert, deswegen kannte ich die ganzen Nachteile davon nicht. :wink:

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
retnyg Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2754

SNES, GB, GBA, CPC, A500, 486/66, P4/3.0HT: NintendOS, AmigaOS, DoS
Delphi 5, Delphi 7
BeitragVerfasst: Di 07.12.04 20:51 
es geht um einen chat client, wenn ein user den raum betritt soll eine andere schrift oder hintergrundsfarbe verwendet werden als wenn eine chatnachricht daherkommt...
kann ja wohl nicht so schwer sein ? :gruebel:
Titan
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 43

Win 95, Win XP
D5 Ent
BeitragVerfasst: Di 07.12.04 20:55 
Wenn du zeit hast, guck dir den Quelltext von der RichEdit-Unit an, vielleicht findest du da nützliche Informationen zu deinem Problem.

_________________
Wissen ist nicht gleich Intelligenz.
Intelligenz hat man oder nicht.
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Di 07.12.04 20:57 
Such mal im Forum nach SelStart und SelEnd, dann findet sich auch was.

(Mir scheint, der "Chat" ist auch eine beliebte Aufgabe in der Schule... :wink: )
Benutzername
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 210

Win XP Pro
Delphi 7 PE, D2005 Prof. SSL
BeitragVerfasst: Di 07.12.04 21:07 
Zitat:
wenn ein user den raum betritt soll eine andere schrift oder hintergrundsfarbe verwendet werden als wenn eine chatnachricht daherkommt..


Das klingt in meinen Ohren so, als würde es reichen, die Schriftfarbe zu ändern?

Wenn ja, dann schau dir mal TRichedit.Selattributes an :-)